多个资源(S3、lambda等)在AWS中由不同的团队通过Terraform脚本创建;
我已经为CloudWatch监控开发了我的Terraform脚本,它们需要AWS ARN作为输入;
是否可以由每个团队使用我的监控terraform脚本,而不将它们复制到他们的repos中?
发布于 2019-01-28 21:01:49
是的,您可以通过将terraform脚本创建为一个模块来让每个团队使用它们。然后,团队可以使用module configuration section将它们加载到自己的脚本中。如果您不使用git,或者您将所有的terraform都放在一个存储库中,那么还有其他ways to load a module
这就是我们制作和使用大量模块的方式,以便在所有团队中具有一致的设置。我们为每个模块都有一个git存储库,比如(module_cloudwatch_monitoring)。定义模块没有什么特别之处,您只需要定义变量和输出即可。
当团队想要使用该模块时,他们可以使用如下模块语法:
module "cloudwatch_monitoring" {
source = "git::http://your-git-repository-url.git?ref=latest"
resource_arn = "${aws_s3_bucket.my_bucket.id}"
}
如果该模块位于同一存储库中的本地路径中,则可以执行以下操作:
module "cloudwatch_monitoring" {
source = "../../modules/cloudwatch_monitoring"
resource_arn = "${aws_s3_bucket.my_bucket.id}"
}
https://stackoverflow.com/questions/54400606
复制相似问题