我使用 terraform 模块设计了一个 AWS 代码管道模块,我有多个使用代码管道模块的实际代码管道。我使用模块作为设计模式是因为所有的代码管道看起来都很相似,只是有些代码管道需要批准阶段,有些不需要。如何设计 codepipeline 模块审批阶段,以便可以根据不同的需求创建实际的 codepipelines?
我尝试使用 count = 0 或 1 来控制舞台,但它不起作用,因为舞台不是资源级的。有什么棘手的方法或解决方法吗?
我觉得这个链接问了类似的问题,但我不知道答案是什么: Terraform & AWS CodePipeline - Dynamically define actions on a stage
这是我的代码管道 terraform 模块:
resource "aws_codepipeline" "dev" {
name = "my_codepipeline"
role_arn = ...
...
stage {
name = "Source"
...
}
stage {
name = "test"
...
}
stage {
# count = 0 # or 1. it does not work
name = "Approval"
action {
name = "Approval"
owner = "AWS"
category = "Approval"
provider = "Manual"
version = "1"
configuration {
NotificationArn = "..."
CustomData = "..."
ExternalEntityLink = "..."
}
}
}
stage {
name = "prod"
...
}
}