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

aws.ec2.LaunchTemplate does not set LaunchTemplatMetadataOptions #2062

Closed
quodlibetor opened this issue Jul 24, 2022 · 3 comments
Closed

aws.ec2.LaunchTemplate does not set LaunchTemplatMetadataOptions #2062

quodlibetor opened this issue Jul 24, 2022 · 3 comments
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed

Comments

@quodlibetor
Copy link

What happened?

given a launchtemplate that includes:

aws.ec2.LaunchTemplate(
        f"{STACK}-{name}",
        metadata_options=aws.ec2.LaunchTemplateMetadataOptionsArgs(
            http_put_response_hop_limit=2,
            instance_metadata_tags="enabled",
        ),
        # snip ..
    )

Pulumi always shows the metadata options as needing to be set. And, indeed, the instances that come up as part of the ASG do not have any metadata options set.

Repeatedly running pulumi up shows the options as unset, but never sets them.

Steps to reproduce

This pulumi stack:

import pulumi
import pulumi_aws as aws

STACK = pulumi.get_stack()

ami = aws.ec2.get_ami(
    filters=[
        aws.ec2.GetAmiFilterArgs(
            name="name",
            values=["amzn2-ami-hvm-*-x86_64-ebs"],
        ),
        aws.ec2.GetAmiFilterArgs(
            name="root-device-type",
            values=["ebs"],
        ),
        aws.ec2.GetAmiFilterArgs(
            name="virtualization-type",
            values=["hvm"],
        ),
    ],
    most_recent=True,
    owners=["amazon"],
)

lc = aws.ec2.LaunchTemplate(
    f"{STACK}-test",
    name_prefix=f"{STACK}-test-",
    image_id=ami.id,
    instance_type="t2.micro",
    metadata_options=aws.ec2.LaunchTemplateMetadataOptionsArgs(
        http_put_response_hop_limit=2,
        instance_metadata_tags="enabled",
    ),
)

group = aws.autoscaling.Group(
    f"{STACK}-test",
    launch_template=aws.autoscaling.GroupLaunchTemplateArgs(id=lc.id),
    min_size=1,
    max_size=3,
    availability_zones=["us-east-2a"]
)

Seems to succeed:

$ pulumi up
Previewing update (test)

View Live: https://app.pulumi.com/quodlibetor/whatchow/test/updates/3

     Type                       Name           Status
 +   pulumi:pulumi:Stack        whatchow-test  created
 +   ├─ aws:ec2:LaunchTemplate  test-test      created
 +   └─ aws:autoscaling:Group   test-test      created

Resources:
    + 3 created

Duration: 1m18s

But then if you examine the infrastructure created it does not have the correct settings.
Additionally, running pulumi up again any number of times will not correctly set metadata
options:

$ pulumi up
Previewing update (test)

View Live: https://app.pulumi.com/quodlibetor/whatchow/test/previews/f78ce6c9-c13f-4cad-a996-b9c9a3ed30c2

     Type                       Name           Plan       Info
     pulumi:pulumi:Stack        whatchow-test
 ~   └─ aws:ec2:LaunchTemplate  test-test      update     [diff: ~metadataOptions]

Resources:
    ~ 1 to update
    2 unchanged

Do you want to perform this update? details
  pulumi:pulumi:Stack: (same)
    [urn=urn:pulumi:test::whatchow::pulumi:pulumi:Stack::whatchow-test]
    ~ aws:ec2/launchTemplate:LaunchTemplate: (update)
        [id=lt-058a942266ba298bc]
        [urn=urn:pulumi:test::whatchow::aws:ec2/launchTemplate:LaunchTemplate::test-test]
        [provider=urn:pulumi:test::whatchow::pulumi:providers:aws::default_5_10_0::8d876028-a449-4c6d-a729-344e3f783a27]
      ~ metadataOptions: {
          ~ httpPutResponseHopLimit: 0 => 2
          + instanceMetadataTags   : "enabled"
        }

Do you want to perform this update?  [Use arrows to move, enter to select, type to filter]
  yes
> no
  details

Expected Behavior

I expected metadata options to be correctly set from the LaunchTemplate, or to receive an error explaining why it can't be done.

Actual Behavior

Pulumi up seems to succeed but does not set the options.

Versions used

❯ pulumi about
CLI
Version      3.36.0
Go Version   go1.17.11
Go Compiler  gc

Plugins
NAME        VERSION
aws         5.10.0
aws-iam     0.0.5
awsx        1.0.0-beta.9
docker      3.2.0
eks         0.40.0
kubernetes  3.20.0
python      unknown

Host
OS       darwin
Version  12.4
Arch     x86_64

This project is written in python: executable='~/.asdf/shims/python3' version='3.10.3'

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@quodlibetor quodlibetor added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Jul 24, 2022
@stack72
Copy link
Contributor

stack72 commented Jul 25, 2022

Hi @quodlibetor

I apologise for the issue here - as we are pulling the required details from the upstream TF provider into our code, I can see the same issue is present there - hashicorp/terraform-provider-aws#25909

I will have a look and see if we can fix this up

Paul

@stack72 stack72 added awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). and removed needs-triage Needs attention from the triage team labels Jul 25, 2022
@aureq
Copy link
Member

aureq commented May 3, 2023

(Thank you Brian) AWS Premium Support told that at the moment, you cannot use instance metadata tags for EKS worker nodes because the tags require keys such as / which is not allowed when the feature is enabled. So the AWS provider code is likely handing it over correctly, it’s just being dropped silently by AWS.

@mikhailshilkov mikhailshilkov added resolution/fixed This issue was fixed and removed awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). labels Nov 15, 2023
@mikhailshilkov mikhailshilkov self-assigned this Nov 15, 2023
@mikhailshilkov
Copy link
Member

The upstream issue has been resolved. I tested the program above and it seems to be working successfully: the outputs are set correctly and there is no diff on update or refresh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

No branches or pull requests

4 participants