Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling instance_metadata_tags doesn't work unless http_endpoint is explicitly enabled #25079

Closed
rcsheets opened this issue May 27, 2022 · 3 comments
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@rcsheets
Copy link

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 other comments that do not add relevant new information or questions, 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 CLI and Terraform AWS Provider Version

Terraform v1.2.1
on darwin_arm64

  • provider registry.terraform.io/hashicorp/aws v4.15.1

Affected Resource(s)

  • aws_launch_template

Terraform Configuration Files

variable "ami_id" {
  type = string
  default = "ami-02efa03fea3ec336e"
}

variable "region" {
  type = string
  default = "us-west-2"
}

resource "aws_launch_template" "repro" {
  name = "xyz"
  image_id = var.ami_id
  instance_type = "t3a.micro"
  metadata_options {
    instance_metadata_tags = "enabled"
  }
  tag_specifications {
    resource_type = "instance"
    tags = {
      foo = "bar"
    }
  }
  update_default_version = true
}

Debug Output

https://gist.github.com/rcsheets/c7aed2a81c856d3d6a90f5f34502dd68

Panic Output

N/A

Expected Behavior

The produced launch template should have the metadata option InstanceMetadataTags=enabled

Actual Behavior

The produced launch template does not have the metadata option InstanceMetadataTags=enabled. Instead, it is necessary to specify

  metadata_options {
    http_endpoint = "enabled"
    instance_metadata_tags = "enabled"
  }

This is unexpected, as "enabled" is the default for http_endpoint.

Steps to Reproduce

  1. terraform apply
  2. terraform apply

The bug has already been reproduced on the first invocation, but it's especially apparent on the second invocation, since it appears that the configuration has drifted, even though nothing has changed. A plan such as the following will be observed:

Terraform will perform the following actions:

  # aws_launch_template.repro will be updated in-place
  ~ resource "aws_launch_template" "repro" {
      ~ default_version         = 1 -> (known after apply)
        id                      = "lt-0b55f789a752d4089"
      ~ latest_version          = 1 -> (known after apply)
        name                    = "xyz"
        tags                    = {}
        # (8 unchanged attributes hidden)

      ~ metadata_options {
          + instance_metadata_tags      = "enabled"
            # (2 unchanged attributes hidden)
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/ec2 Issues and PRs that pertain to the ec2 service. labels May 27, 2022
@justinretzolk justinretzolk added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Jun 6, 2022
@kelcya
Copy link

kelcya commented Jun 11, 2022

Just ran into this issue 😢 .

The workaround of adding http_endpoint = "enabled" works! Thank you!

  metadata_options {
    http_endpoint = "enabled"
    instance_metadata_tags = "enabled"
  }

@justinretzolk
Copy link
Member

Hey @rcsheets 👋 Thank you very much for taking the time to raise this! This was addressed with #30545, which was included in version 5.0.0 of the provider. With that in mind, we'll close this issue. If you experience additional issues with the provider, please do open a new issue to let us know.

@github-actions
Copy link

github-actions bot commented Jul 1, 2023

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

No branches or pull requests

3 participants