I am trying to allow all tcp traffic between instances, otherwise deny all ingress and egress traffic.
Problem with "cidr_blocks", in aws console i can select security group but in terraform how can achieve something like that.
resource "aws_security_group" "default" {
name = "terraform_example"
ingress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ????
}
}
In your ingress rule specification set self = true to allow traffic inside your Security Group. To allow traffic from a different Security Group, use the security_groups parameter. In both cases you can leave out the cidr_blocks parameter.
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
cidr_blocks = [aws_vpc.main.cidr_block]
ipv6_cidr_blocks = [aws_vpc.main.ipv6_cidr_block]
security_groups = [ "aws_security_group.main_sg1.name", "aws_security_group.main_sg2.name" ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With