amazon-web-services - 使用 Terraform 启动 CloudFormationTemplate

标签 amazon-web-services aws-cloudformation terraform

如何从 Terraform 启动 CloudFormationTemplate。 Terraform 创建了 VPC 和 SecurityGroups。如何将 vpcID 和 SecurityGroupID 传入 CFT。我已经搜索过,但找不到任何相同的链接。 RTFM 在这里没有任何帮助。

最佳答案

为此,您应该将参数传递给 aws_cloudformation_stack 资源。

resource "template_file" "redshift_cloudformation" {
  template = "${file("redshift.cloudformation")}"

  vars {
    redshift_public_subnet_id  = "${element(split(",", terraform_remote_state.shared.output.public_subnet_ids), 0)}"
    redshift_security_group_id = "${aws_security_group.redshift.id}"
  }
}

resource "aws_cloudformation_stack" "heavy_redshift" {
  name          = "heavy-redshift"
  template_body = "${template_file.redshift_cloudformation.rendered}"

  parameters {
    MasterUsername     = "master"
    MasterUserPassword = "MasterPassword123"
  }
}

查看完整代码以获取更多示例 - https://github.com/antonbabenko/terraform-aws-devops/blob/master/extra/heavy_cf_redshift.tf#L40-L48

关于amazon-web-services - 使用 Terraform 启动 CloudFormationTemplate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34245005/

相关文章:

amazon-web-services - CloudFormation 中 Aurora Serverless 的日志保留

amazon-s3 - s3-cloudformation-template.json 上的本地更改在放大推送时被覆盖

google-cloud-platform - 由于架构更新,如何更新 google_bigquery_table_iam_member 以指向重新创建的新表

python - 我们如何获取 IAM 用户、他们的组和策略?

javascript - HTTP API 在 AWS Lambda 测试环境之外返回未定义的值

java - 从 AWS Lambda 获取 URL 时出现无提示错误

amazon-web-services - cloudformation ECS 强制新部署

image - 从 Amazon s3 获取图像会出现 CORS 错误。 ( Chrome 问题)

unit-testing - Terratest - 使用模拟 AWS 服务

amazon-web-services - 在多个 AWS Organizations 账户上部署资源