aws_launch_configuration does not expose subnet/vpc parameter

375 views
Skip to first unread message

Russ M

unread,
Apr 10, 2016, 5:23:27 AM4/10/16
to Terraform
Ive been working on adding a ASG to my terraform config.

Its evident there is no parameter for launch config or ASG to define a subnet and consequently a VPC.

As a result, all launch configs launch in the default vpc default subnet showing no subnet vpc listed in their launch config when viewing through UI.

I've tried subnet_id= subnets=[] which all get rejected as invalid params

Ive checked official doc and without stating it it seems like this is a current technical limitation?

Does anyone know?



cosmo....@anchor.com.au

unread,
Apr 11, 2016, 12:03:11 AM4/11/16
to Terraform


On Sunday, April 10, 2016 at 7:23:27 PM UTC+10, Russ M wrote:
Its evident there is no parameter for launch config or ASG to define a subnet and consequently a VPC.

As per the official documentation located at https://www.terraform.io/docs/providers/aws/r/autoscaling_group.html, the parameter you're looking for is 'vpc_zone_identifier'.

I'm guessing this was chosen to match the 'VPCZoneIdentifier' field in the underlying API call.

Stuart Wong

unread,
Apr 26, 2016, 8:56:06 PM4/26/16
to Terraform
I know it's possible and I've seen code that must work (since some are using it), but every time I try I get:

* aws_autoscaling_group.bastion_asg: Error creating Autoscaling Group: ValidationError: The subnet ID 'subnet-d900a2bd' does not exist
status code: 400, request id: dc27cd7a-0bde-11e6-9eda-9d2404e4fc76

Pretty strange, this is aws_launch_configuration the code fragment:

  vpc_zone_identifier       = ["${element(split(",", terraform_remote_state.tfremote.output.public_subnets), count.index)}"]

cosmo....@anchor.com.au

unread,
Apr 26, 2016, 9:10:29 PM4/26/16
to Terraform
On Wednesday, April 27, 2016 at 10:56:06 AM UTC+10, Stuart Wong wrote:
I know it's possible and I've seen code that must work (since some are using it), but every time I try I get:

It definitely works. We're successfully using stanzas like this in quite a few of our configs.

resource "aws_autoscaling_group" "[...]" {
     name
= [...]
     launch_configuration
= [...]
     max_size
= [...]
     min_size
= [...]
     vpc_zone_identifier
= ["${split(",",var.private_subnet_ids)}"]
}
 
  vpc_zone_identifier       = ["${element(split(",", terraform_remote_state.tfremote.output.public_subnets), count.index)}"]

Do you receive the same error if you pass in the subnet ID manually rather than via the remote state? Are you certain that terraform is using the same AWS account and region for the local stack as was used in the stack referenced by the remote state?
Reply all
Reply to author
Forward
0 new messages