![](/img/trans.png)
[英]Terraform add existing security group to new auto scaling ec2 group
[英]Terraform add new security group to an existing security group
我在 terraform 的 Autoscaling 模块中创建了一个新的安全组。 我想将此安全组添加到模块数据库中的现有安全组中。 数据库模块中使用的安全组已经通过控制台创建。 如何在 terraform 中的现有安全组中添加新的安全组?
如果要更改控制台创建的 SG,则必须手动对其进行编辑。
如果更改terraform创建的SG,可以手动获取已存在SG的id,添加到SG的规则中
编辑:
您需要 output:
output "security_group_id" {
description = "Security group ID attached to the EKS workers."
value = module.auto_scaling_module.security_group_id
}
比使用 data.tf 中的数据导入
data "terraform_remote_state" "autoscaling" {
backend = "s3"
config = {
region = "us-west-1"
bucket = "wherestatelocate"
key = "path"
}
}
比在数据库模块中使用它
security_groups = [data.terraform_remote_state.autoscaling.outputs.security_group_id
]
这就是我正在使用的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.