hashicorp / packer-plugin-amazon

Packer plugin for Amazon AMI Builder
https://www.packer.io/docs/builders/amazon
Mozilla Public License 2.0
75 stars 112 forks source link

IMDS option `instance_metadata_tags` does not work on packer 1.8.5 #428

Closed blueprismo closed 1 year ago

blueprismo commented 1 year ago

Overview of the Issue

I am using packer with ebs-volume builder to create an AMI, the goal is to create an AMI with the "Access to tags in instance metadata" feature enabled.
To do so: add the instance_metadata_tags to "enabled" in the template.pkr.hcl file. sauce

Reproduction Steps

Have an ebs volume as source like:

source "amazon-ebs" "watever" {
ami_name = "whatever"
  metadata_options {
    instance_metadata_tags = "enabled"
  }
[...]
}

Then packer build it. Afterwards, try to create a new instance with the generated AMI. You'll see that accessing tags from IMDS is disabled

Plugin and Packer version

From packer version 1.8.5

Simplified Packer Buildfile

build {
  sources = ["source.amazon-ebs.whatever"]

  post-processor "manifest" {
    output = "manifest.json"
    strip_path = true
  }
}

Operating system and Environment details

running on ubuntu20.04 (amd/64)

Log Fragments and crash.log files

No log errors, all executes smoothly

lbajolet-hashicorp commented 1 year ago

Hi @blueprismo,

The metadata_options are only for the instance during the build, not all the future instances the AMI created by Packer will be using, for those, you will need to explicitly select that option when creating them.

I'm not sure what you're asking for is supported by the APIs, but if so, do you have a reference to share? We could maybe implement it later, or if you feel comfortable in Go, please feel free to give it a shot, and we'll happily review!

I'll mark this as not a bug for now, but please let us know if I'm misunderstanding your issue.

blueprismo commented 1 year ago

Hello @lbajolet-hashicorp Thanks for your fast response, Oh what a big facepalm, thought that metadata_options would also apply for the future instances created by Packer. Sorry for the inconvenience, this issue can be closed :)