Terraform: Unable to create launch configuration when there is no default VPC

Created on 22 Oct 2015  ยท  3Comments  ยท  Source: hashicorp/terraform

I am having the following issue when trying to create a launch configuration using terraform

* aws_launch_configuration.mib-stepcheck-tf-service-launch-configuration: Error creating launch configuration: ValidationError: No default VPC for this user

My launch configuration is configured in the *.tf in the following way:

resource "aws_launch_configuration" "mib-stepcheck-tf-service-launch-configuration" {
   name = "mib-stepcheck-tf"
   image_id = "${lookup(var.aws_amis, var.aws_region)}"
   instance_type = "${var.instance_type}"
   security_groups = ["${aws_security_group.mib-stepcheck-tf-autoscaling-group.name}"]
   key_name = "mib_stepcheck"
}

Looking through the doc, it doesn't seem there is a way to specify the VPC id anywhere in the launch configuration resource.

Am I missing something ?

provideaws question

Most helpful comment

I hit this issue just now. It turned out to be because I had incorrectly specified the security groups by name rather than id.

eg -

WRONG

Note use of "$aws_security_group.bastion_sg.name"

resource "aws_launch_configuration" "bastion_lc" {
  name = "bastion-lc"
  image_id = "${var.bastion_image}"
  instance_type = "t2.micro"
  # Security group
  security_groups = ["${aws_security_group.bastion_sg.name}"]
  key_name = "${var.key_name}"
}

CORRECT

Note use of "$aws_security_group.bastion_sg.id "

resource "aws_launch_configuration" "bastion_lc" {
  name = "bastion-lc"
  image_id = "${var.bastion_image}"
  instance_type = "t2.micro"
  # Security group
  security_groups = ["${aws_security_group.bastion_sg.id}"]
  key_name = "${var.key_name}"
}

All 3 comments

I hit this issue just now. It turned out to be because I had incorrectly specified the security groups by name rather than id.

eg -

WRONG

Note use of "$aws_security_group.bastion_sg.name"

resource "aws_launch_configuration" "bastion_lc" {
  name = "bastion-lc"
  image_id = "${var.bastion_image}"
  instance_type = "t2.micro"
  # Security group
  security_groups = ["${aws_security_group.bastion_sg.name}"]
  key_name = "${var.key_name}"
}

CORRECT

Note use of "$aws_security_group.bastion_sg.id "

resource "aws_launch_configuration" "bastion_lc" {
  name = "bastion-lc"
  image_id = "${var.bastion_image}"
  instance_type = "t2.micro"
  # Security group
  security_groups = ["${aws_security_group.bastion_sg.id}"]
  key_name = "${var.key_name}"
}

Hi folks, this is odd behavior from the AWS API.

You can read a bunch more details in this AWS Support forum thread: https://forums.aws.amazon.com/thread.jspa?threadID=128896

Based on my interpretation, it seems like you can either request AWS Support restore a Default VPC for the region in question, or you can omit the security_groups parameter to work around the error. I'd also guess that you can fix the error by specifying a security group that is already attached to a VPC you have created.

Hope this help! :+1:

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings