ish
ish

Reputation: 109

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 Console

Upvotes: 0

Views: 1263

Answers (1)

lapostoj
lapostoj

Reputation: 113

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.

Upvotes: 1

Related Questions