簡體   English   中英

Terraform 將新安全組添加到現有安全組

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM