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

Fix default values for launch template metadata. #29024

Conversation

lvthillo
Copy link
Contributor

Description

Launch Template metadata options does not use default values as described in the docs.

Example (4.50):

resource "aws_launch_template" "lt" {
  name                   = "test-lt"
  image_id               = "ami-0fe0b2cf0e1f25c8a"
  instance_type          = "t3.small"
  vpc_security_group_ids = ["sg-12345678"]

  metadata_options {
    http_tokens = "optional"
  }
}

Plan:

  + metadata_options {
      + http_endpoint               = (known after apply)
      + http_protocol_ipv6          = "disabled"
      + http_put_response_hop_limit = (known after apply)
      + http_tokens                 = "optional"
      + instance_metadata_tags      = "disabled"
    }

Describe using AWS CLI after apply

  "LaunchTemplateData": {
      "ImageId": "ami-0fe0b2cf0e1f25c8a",
      "InstanceType": "t3.small",
      "UserData": "",
      "SecurityGroupIds": [
          "sg-12345678"
      ],
      "MetadataOptions": {
          "HttpProtocolIpv6": "disabled"
      }
}

By using this PR + same TF code:
Plan:

  + metadata_options {
      + http_endpoint               = "enabled"
      + http_protocol_ipv6          = "disabled"
      + http_put_response_hop_limit = 1
      + http_tokens                 = "optional"
      + instance_metadata_tags      = "disabled"
    }

Describe using CLI:

    "LaunchTemplateData": {
        "ImageId": "ami-0fe0b2cf0e1f25c8a",
        "InstanceType": "t3.small",
        "UserData": "",
        "SecurityGroupIds": [
            "sg-12345678"
        ],
        "MetadataOptions": {
            "HttpTokens": "optional",
            "HttpPutResponseHopLimit": 1,
            "HttpEndpoint": "enabled",
            "HttpProtocolIpv6": "disabled",
            "InstanceMetadataTags": "disabled"
        }
    }

Relations

Relates #12564

References

Output from Acceptance Testing

$ make testacc TESTS=TestAccEC2LaunchTemplate_metadataOptions PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccEC2LaunchTemplate_metadataOptions'  -timeout 180m
=== RUN   TestAccEC2LaunchTemplate_metadataOptions
=== PAUSE TestAccEC2LaunchTemplate_metadataOptions
=== CONT  TestAccEC2LaunchTemplate_metadataOptions
--- PASS: TestAccEC2LaunchTemplate_metadataOptions (62.61s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ec2        67.316s

...

@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • 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.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added size/S Managed by automation to categorize the size of a PR. service/ec2 Issues and PRs that pertain to the ec2 service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jan 21, 2023
@johnsonaj
Copy link
Contributor

Relates #30393

@gdavison
Copy link
Contributor

gdavison commented Apr 6, 2023

Thanks for taking the time to submit this PR, @lvthillo. In this case, the documentation is incorrect. The default values for a Launch Template should be to not specify a value, and require the instance to specify a value.

@github-actions
Copy link

github-actions bot commented May 7, 2023

I'm going to lock this pull request 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 related to this change, 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 May 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/ec2 Issues and PRs that pertain to the ec2 service. size/S Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants