amazon-web-services - Terraform 将新安全组添加到现有安全组
问题描述
我在 terraform 的 Autoscaling 模块中创建了一个新的安全组。我想将此安全组添加到模块数据库中的现有安全组中。数据库模块中使用的安全组已经通过控制台创建。如何将新的安全组添加到 terraform 中的现有安全组?
解决方案
如果要更改控制台创建的 SG,则必须手动对其进行编辑。
如果更改terraform创建的SG,可以手动获取已存在SG的id,添加到SG的规则中
编辑:
你需要输出:
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
]
这就是我正在使用的
推荐阅读
- c - 关于如何制作启发式和目标状态的问题。C语言中的15个难题
- git - Git:在处理该项目的克隆后创建项目的分支
- r - 制作一个 4d 数组,其中每个点对应于函数的结果
- c# - 我可以长期固定静态值类型字段吗?
- python - Scipy curve_fit 给出错误答案
- css - CSS对齐框彼此相邻
- java - 未找到给定包括的测试:[***Test](filter.includeTestsMatching)
- php - Codeigniter错误:fsockopen():php_network_getaddresses:getaddrinfo失败:名称或服务未知
- sql - 根据另一个表中的列值选择一个表中的行?
- php - 开发 Directus 扩展时如何设置单元测试?