【问题标题】:Terraform - Receiving Error with CloudFormation CapabilitiesTerraform - CloudFormation 功能接收错误
【发布时间】:2022-11-03 23:30:55
【问题描述】:

我是 Terraform 的新手,所以我确信我只是遗漏了一些简单的东西,但是在尝试部署 CloudFormation 堆栈时,我在应用功能时遇到了错误。

这是我的堆栈资源:

resource "aws_cloudformation_stack" "member_remediation" {
  name         = "smx-sharr-member-remediation"
  capabilities = [CAPABILITY_IAM, CAPABILITY_AUTO_EXPAND]

  parameters = {
    SecHubAdminAccount                    = var.parameter_SecHubAdmin
    CreateS3BucketForRedshiftAuditLogging = var.parameter_CreateS3
    LogGroupName                          = var.parameter_LogGroupName
    LoadAFSBPMemberStack                  = var.parameter_LoadAFSBPStack
    LoadCIS120MemberStack                 = var.parameter_LoadCISStack
    LoadPCI321MemberStack                 = var.parameter_LoadPCIStack
  }

  template_body = file("${path.module}/cf-templates/aws-sharr-member.yml")
}

这是尝试在控制台中部署时堆栈提供的内容:

这是 Terraform 在执行计划时向我提供的错误:

Exception Error in plan -
Error: Invalid reference

on .terraform/modules/aws-securityhub-master/module/main.tf line 1120, in resource "aws_cloudformation_stack" "member_remediation":
1120: capabilities = [CAPABILITY_IAM, CAPABILITY_AUTO_EXPAND]

A reference to a resource type must be followed by at least one attribute
access, specifying the resource name.

Error: Invalid reference

on .terraform/modules/aws-securityhub-master/module/main.tf line 1120, in resource "aws_cloudformation_stack" "member_remediation":
1120: capabilities = [CAPABILITY_IAM, CAPABILITY_AUTO_EXPAND]

A reference to a resource type must be followed by at least one attribute
access, specifying the resource name.

我不确定该功能需要什么属性或资源引用,或者如何在资源布局中编写它。我没有找到很多利用功能选项部署 CF 堆栈的示例。

任何帮助是极大的赞赏!

注意:我已经在 Stack Overflow 上查看了以下问题 - 在这种情况下它对我没有帮助:

AWS CloudFormation Stack update error: Requires capabilities : [CAPABILITY_IAM]

【问题讨论】:

    标签: amazon-web-services terraform amazon-cloudformation terraform-provider-aws


    【解决方案1】:

    capabilities 的参数类型是 set(string)。您似乎正在尝试解析未定义的第一类表达式。您可能打算将元素转换为文字字符串,我们可以使用正常语法来做到这一点:

    capabilities = ["CAPABILITY_IAM", "CAPABILITY_AUTO_EXPAND"]
    

    【讨论】:

    • 啊,这么简单的事情,那是我的错。太感谢了!
    猜你喜欢
    • 2019-06-30
    • 1970-01-01
    • 2017-05-05
    • 2021-04-01
    • 2020-06-12
    • 2014-08-17
    • 2021-12-17
    • 1970-01-01
    • 2019-04-15
    相关资源
    最近更新 更多