2015-12-12 44 views
1

如何從Terraform啓動CloudFormationTemplate。 Terraform已經創建了VPC和SecurityGroups。如何將vpcID和SecurityGroupID傳入CFT。我已經搜索,但無法找到任何相同的鏈接。 RTFM在這裏沒有任何幫助。使用Terraform啓動CloudFormationTemplate

回答

1

爲此,您應該將參數傳遞給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

+0

你可以嘗試採取一些相關的信息進行鏈接,並在直接回答有嗎?這樣,如果你的代碼改變了,那麼這個答案可能對其他人有用。 – ydaetskcoR

+0

@ydaetskcoR完成。 –