Reputation: 109
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?
Upvotes: 0
Views: 1263
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