【发布时间】:2018-06-05 04:47:27
【问题描述】:
我在 dev_account 创建了一个 codepipeline,它在 dev_account、test_account 和 prod_account 都触发了 codedeploy,三个帐户的 codedeploy 看起来相同,只是它们在不同的帐户中。
以下是我的 terraform 文件的组织结构。我使用 terraform 模块重用代码,但我仍然认为我的代码有很多重复代码,如何优化它们?
common_infr/
codepipeline.tf # dev_account has codepipeline, codedeploy
codedeploy.tf
test_account/
codedeploy.tf # test_account has a codedeploy
prod_account/
codedeploy.tf # prod_account has a codedeploy
pipeline1/
main.tf #run terraform apply here using dev account
test_account/
main.tf #run terraform apply here using test account
prod_account/
main.tf #run terraform apply here using prod account
这是 pipeline1/main.tf:
module "pipeline1" {
source = "../common_infra"
variable1 = "..."
...
}
这是 pipeline1/test_account/main.tf:
module "pipeline1" {
source = "../../common_infra/test_account"
variable1 = "..."
...
}
这是 pipeline1/prod_account/main.tf:
module "pipeline1" {
source = "../../common_infra/prod_account"
variable1 = "..."
...
}
三个帐户的 codedeploy.tf 看起来相同。如何优化?
【问题讨论】:
标签: terraform aws-codepipeline