简体   繁体   中英

how to select a security-group id for the source when creating a security group in AWS with terraform

In the AWS console when you are creating a security group you can select a security group ID for the source IP (inbound rule). Is it possible to do this in terraform, and if so how would you do this?

AWS 控制台

You can use the aws_security_group_rule described here https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule It has a source_security_group_id field where you can specify the security group you want to allow traffic from.

Before that you'd probably create the security group with the aws_security_group resource https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group . And you can the pass the id of this security group in the security_group_id field of the aws_security_group_rule resource.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM