我有一个Terraform的CodePipeline如下:
resource "aws_codepipeline" "main" {
stage {
name = "Source"
....
}
stage {
name = "Test"
....
}
stage {
name = "Approval"
....
}
stage {
name = "Deployment"
....
}
}
是否可以配置是否需要上述阶段之一,例如,如果变量enable_approval_stage = 1,则创建Approval阶段,如果enable_approval_stage = 0,则不创建Approval阶段?就像我们在资源{}中设置count = 0一样?
答案 0 :(得分:1)
我的想法是创建两个不同的管道,一个具有批准阶段,另一个没有批准阶段。并让他们这样:
如果manual_approve为true(值为1):
resource "aws_codepipeline" "pipeline-manualapprove" {
count = "${var.manual_approve}"
如果manual_approve为false(值为0):
resource "aws_codepipeline" "pipeline-automatic" {
count = "${1-var.manual_approve}"