Search code examples
amazon-web-servicesterraformaws-security-groupcidr

Terraform: Allow all internal traffic inside aws security group


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 =  ????
  }

}

Solution

  • 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.