Terraform-provider-aws: Cannot update aws_launch_configuration with at least one root_block_device attribute specified when the old AMI has been deregistered

Created on 20 Sep 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 v0.11.14

  • provider.aws v2.28.1

Affected Resource(s)

  • aws_launch_configuration

Terraform Configuration Files

provider "aws" {
  region  = "us-east-1"
}

resource "aws_launch_configuration" "launch_configuration" {
  name_prefix   = "test-launch-configuration"
  image_id      = "ami-XXXXX"
  instance_type = "t3.small"

  root_block_device = {
    volume_type  = "standard"
  }
}

Expected Behavior

The AMI should be changed regardless of the fact that the old AMI has been deregistered.

Actual Behavior

An error is thrown by Terraform that the old AMI is not found:

$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

aws_launch_configuration.launch_configuration: Refreshing state... (ID: test-launch-configuration20190920144712144900000001)

Error: Error refreshing state: 1 error occurred:
        * aws_launch_configuration.launch_configuration: 1 error occurred:
        * aws_launch_configuration.launch_configuration: aws_launch_configuration.launch_configuration: No images found for AMI ami-XXXXX

Steps to Reproduce

  1. terraform apply with any version of provider.aws
  2. delete ami-XXXXX that was originally referenced
  3. change the code to reference a different AMI: ami-YYYYY
  4. terraform apply with a version of provider.aws >= 2.23

References

It seems that this bug has been introduced in version 2.23 as mentioned in the references.

  • bug #9775 seems to have the same root cause
  • PR #9810 seems to be fixing this
bug regression servicautoscaling

Most helpful comment

no error when version
provider "aws" {
version = "<=2.22"

All 10 comments

It actually appears that the initial apply of the code can be done with any version of the AWS provider, so I have reflected this in the steps to reproduce.

I'm also seeing this issue. Resolved by doing AMI changes manually and then importing resources back into Terraform state.

no error when version
provider "aws" {
version = "<=2.22"

๐Ÿ‘

A temporary workaround (other than @ernetas's)... if you're able, manually delete the resource then plan/apply. That worked for me. TF seems to deal with not finding the resource at all and then just puts it back but with the updated details.

Hi folks ๐Ÿ‘‹ We recently merged #9810 and with further testing from the original issue report here, it appears additional changes are needed to handle this condition. Hopefully will be able to submit a fix this week.

The fix for this has been merged and will release with version 2.49.0 of the Terraform AWS Provider, tomorrow. ๐Ÿ‘

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