我该如何修复Terraform文件中的错误

时间:2019-04-01 05:07:44

标签: amazon-web-services terraform

aws_cloudformation_stack在使用terraform时无法更新参数更改

我正在尝试使用Terraform创建一个dynamodb。我有一个文件,该文件位于yaml中,我们已将该文件转换为JSON并使用了它,但出现很多错误。我点击了此链接

https://www.terraform.io/docs/providers/aws/r/cloudformation_stack.html

当我使用vpc时,第一部分给了我错误,我已经将其删除,并且当我继续删除它们时,我一直在获取新的错误..所以我遇到了一个tf_terraform命令,我在寻找警告 下面是代码段

2019/03/31 11:55:08 [TRACE] dag/walk: vertex "provider.aws (close)", waiting for: "aws_cloudformation_stack.dynamodb" 2019/03/31 11:55:08 [TRACE] dag/walk: vertex "root", waiting for: "meta.count-boundary (count boundary fixup)" 2019/03/31 11:55:08 [TRACE] dag/walk: vertex "meta.count-boundary (count boundary fixup)", waiting for: "aws_cloudformation_stack.dynamodb" 2019/03/31 11:55:13 [TRACE] dag/walk: vertex "aws_cloudformation_stack.dynamodb", waiting for: "provider.aws" 2019/03/31 11:55:13 [TRACE] dag/walk: vertex "root", waiting for: "meta.count-boundary (count boundary fixup)" 2019/03/31 11:55:13 [TRACE] dag/walk: vertex "provider.aws (close)", waiting for: "aws_cloudformation_stack.dynamodb" 2019/03/31 11:55:13 [TRACE] dag/walk: vertex "meta.count-boundary (count boundary fixup)", waiting for: "aws_cloudformation_stack.dynamodb"

它一直在做我在做什么错,这是我附上了tfplan文件的错误

我的代码就是这样

resource "aws_cloudformation_stack" "network" {
name = "networking-stack"
template_body = <<STACK
{
"Parameters": {
"ParamReadCapacityUnitsDynamoDB": {
"Description": "ReadCapacityUnits",
"Type": "Number",
"MinValue": 1,
"MaxValue": 5,
"Default": 1
},
"ParamWriteCapacityUnitsDynamoDB": {
"Description": "WriteCapacityUnits",
"Type": "Number",
"MinValue": 1,
"MaxValue": 5,
"Default": 1
}
},
"Resources": {
"DynamoDB": {
"Type": "AWS::DynamoDB::Table",
"Properties": {
"TableName": "Name",
"AttributeDefinitions": [
{
"AttributeName": "PartitionKey",
"AttributeType": "S"
},
{
"AttributeName": "SortKey",
"AttributeType": "S"
}
],
"KeySchema": [
{
"AttributeName": "PartitionKey",
"KeyType": "HASH"
},
{
"AttributeName": "SortKey",
"KeyType": "RANGE"
}
],
"ProvisionedThroughput": {
"ReadCapacityUnits": 20,
"WriteCapacityUnits": 20
},
"GlobalSecondaryIndexes": [
{
"IndexName": "userGSI",
"KeySchema": [
{
"AttributeName": "SortKey",
"KeyType": "HASH"
},
{
"AttributeName": "PartitionKey",
"KeyType": "RANGE"
}
],
"Projection": {
"ProjectionType": "ALL"
},
"ProvisionedThroughput": {
"ReadCapacityUnits": 20,
"WriteCapacityUnits": 20
}
}
],
"StreamSpecification": {
"StreamViewType": "NEW_IMAGE"
},
"Tags": [
{
"Key": "System",
"Value": dynamodb
}
]
}
}
}
}
STACK
}

我希望从嵌入的json文件创建dynamo db文件

1 个答案:

答案 0 :(得分:0)

看看直接使用DynamoDB表资源,而不是在Terraform中使用CloudFormation堆栈。

样品/文档: https://www.terraform.io/docs/providers/aws/r/dynamodb_table.html https://github.com/cloudposse/terraform-aws-dynamodb/tree/master/examples/complete