Legitimate_Figure_4430
Legitimate_Figure_4430

Reputation: 105

Issue while adding AWS Security Group via Terraform

I am adding security group via terraform, and after terraform apply the SG is successfully made but when i go and check on AWS portal only the ingress rule is updated and not the egress rule.

  vpc_id      = var.vpc_id
  name        = "${var.env_code}-testsg"
  description = "Test SG"

  ingress {
    from_port       = 8080
    to_port         = 8080
    protocol        = "tcp"
    cidr_blocks = ["10.0.0.0/8"]
    description = "Incoming traffic "
  }

  egress {
    from_port   = 8000
    to_port     = 8000
    protocol    = "tcp"
    description = "Outbound traffic "
  }

Any suggestions what can be done to resolve this ?

Upvotes: 0

Views: 219

Answers (1)

Marcin
Marcin

Reputation: 238051

Your egress is missing a destination, such as cidr_blocks or security_groups, thus it is invalid. To fix that, you need some destination for the rule to apply, e.g.:

  egress {
    from_port   = 8000
    to_port     = 8000
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
    description = "Outbound traffic "
  }

Upvotes: 4

Related Questions