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

Terraform AWS The security group does not exist when it does exists


I have a security group with name "basic connectivity" on my AWS.

I wrote a Terraform script to create an AWS instance but it states that the Security group does not exists when it actually does exist in the same Default VPC and region.

The part where it fails is here:

resource "aws_default_vpc" "default" {

  tags = {
    Name = "Default VPC"
  }
}

resource "aws_subnet" "subnet_olympus" {
  vpc_id            = aws_default_vpc.default.id
  cidr_block        = "172.31.150.0/24"
}

resource "aws_network_interface" "nint_olympus" {

  subnet_id   = aws_subnet.subnet_olympus.id
  private_ips = ["172.31.150.100"]

  security_groups = ["sg-09ef716b3eb847691"]

}

Can someone please help me ?


Solution

  • Can you try passing those sg ids via a data source Datasource SG