Terraform-provider-aws: aws_launch_config fails with instance-store AMIs - new in 2.23.0

Created on 15 Aug 2019  ·  10Comments  ·  Source: hashicorp/terraform-provider-aws

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

$ terraform --version
Terraform v0.11.14

  • provider.aws v2.23.0

Affected Resource(s)

  • aws_launch_configuration

Terraform Configuration Files

provider "aws" {
  region = "us-east-1"
  assume_role {
    role_arn     = "ROLE OMITTED"
  }
}

variable "instance_store_ami" {
  description = "An instance-store AMI"
}

resource "aws_launch_configuration" "instance_store" {
  name_prefix   = "test-instance-store-ami"
  image_id      = "${var.instance_store_ami}"
  instance_type = "c3.large"

  lifecycle {
    create_before_destroy = true
  }
}

Debug Output

https://gist.github.com/jc-asdf/57da70548170c1a57bf20220de50bc37

Panic Output

N/A

Expected Behavior

A launch config should be created, with an instance store AMI.

Actual Behavior

Terraform aborts with an error - Instance store backed AMIs do not provide a root device name - Use an EBS AMI

Steps to Reproduce

  1. Create an aws_launch_configuration that references an Instance-Store AMI (they're rare, but they do exist!)
  2. Note that there's limited instance types that support instance-store; c3 and m3 families do and are generally available.
  3. Plan and apply the resource, and you will see the error

Important Factoids

This error is new as of version 2.23.0. Provider version 2.22.0 works fine. For now, the workaround would be to pin the provider to version v2.22.0

The error hints that perhaps the provider is trying to reference the root device name, which is not available on Instance Store AMIs.

References

bug regression servicautoscaling

Most helpful comment

May not be directly related but as of 2.23 aws_launch_configuration returns an error is the image_id in the saved state cannot be found. I our case we have updated the AMI several times and the old one has been deleted. In <=2.22

# module.compute.aws_launch_configuration.work must be replaced
+/- resource "aws_launch_configuration" "work" {
        associate_public_ip_address      = false
      ~ ebs_optimized                    = false -> (known after apply)
        enable_monitoring                = true
        iam_instance_profile             = "my-profile"
      ~ id                               = "my-foo" -> (known after apply)
      ~ image_id                         = "ami-0844543154aa2671b" -> "ami-0b45f7bbb1bfd5b79" # forces replacement

from 2.23

Error: No images found for AMI ami-0844543154aa2671b

All 10 comments

@jc-asdf sorry you are running into an issue here. Can you please take a minute to provide the requested information within the issue, especially a Terraform configuration for reproducing the issue, so that we can determine how to best proceed here.

In the meantime, if you haven’t already, you can pin your provider version to “2.22.0”. If this issue is only occurring with version "2.23.0” of the Terraform AWS provider.

provider “aws” {
  version = “2.22.0”
}

Oh what happened here; looks like my actual ticket content got gobbled up. I have edited the ticket and filled it in appropriately. Many apologies for the screw up there! And yes, the 2.22.0 provider works fine and is a suitable workaround for now.

Seeing this issue as well with Terraform 0.12.6 and provider.aws v2.23.0. Will pin to the previous release in the meantime.

I think this has been caused by https://github.com/terraform-providers/terraform-provider-aws/commit/3d330bd9e03a2a9503a2e2298d8618e61a36a9ca#diff-28aade55afa0cda57279a9d35d523488R1381
I'm not sure why though. Let's wait for someone to confirm it.

First go at a fix in PR #9810 above. Passes all the aws_launch_configuration and aws_instance acceptance tests.

May not be directly related but as of 2.23 aws_launch_configuration returns an error is the image_id in the saved state cannot be found. I our case we have updated the AMI several times and the old one has been deleted. In <=2.22

# module.compute.aws_launch_configuration.work must be replaced
+/- resource "aws_launch_configuration" "work" {
        associate_public_ip_address      = false
      ~ ebs_optimized                    = false -> (known after apply)
        enable_monitoring                = true
        iam_instance_profile             = "my-profile"
      ~ id                               = "my-foo" -> (known after apply)
      ~ image_id                         = "ami-0844543154aa2671b" -> "ami-0b45f7bbb1bfd5b79" # forces replacement

from 2.23

Error: No images found for AMI ami-0844543154aa2671b

Would appreciate some feedback on PR #9810 which reverts the problematic behaviour, and adds in some tests.

It works well for me but I'm seeing a variety of other issues being reported here. If it works for you please thumbs that PR so we can get approved :) Thanks!

The fix for this has been merged and will release with version 2.49.0 of the Terraform AWS Provider, tomorrow. Thanks to @jc-asdf for the implementation. 👍

This has been released in version 2.49.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

Was this page helpful?
0 / 5 - 0 ratings