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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

metadata_options is ignored in aws_spot_instance_request #25896

Open
gawdn opened this issue Jul 20, 2022 · 0 comments
Open

metadata_options is ignored in aws_spot_instance_request #25896

gawdn opened this issue Jul 20, 2022 · 0 comments
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@gawdn
Copy link

gawdn commented Jul 20, 2022

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.5
on linux_amd64

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

Affected Resource(s)

  • aws_spot_instance_request
    (maybe more)

Terraform Configuration Files

My actual TF is much more complex but this is a minimal repro.

terraform {
  required_version = ">= 1.2"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 4.22"
    }
  }
}

provider "aws" {
  region = "ap-southeast-2"
}


resource "aws_spot_instance_request" "ec2_spot_instance" {
  ami           = "ami-044db034021ea23f7"
  instance_type = "t2.micro"

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

Debug Output

https://gist.github.com/gawdn/26e52d96c9d4b4b87ee011faf49bc7ab

Expected Behavior

metadata_options should be applied to instance requested by aws_spot_instance_request

Actual Behavior

metadata_options is ignored in aws_spot_instance_request

Steps to Reproduce

  1. terraform apply
  2. Run describe-instances to get instance information and see MetadataOptions has not been set correctly.
    Irrelevant fields dropped:
{
    "Reservations": [
        {
            "Groups": [],
            "Instances": [
                {
                    "ImageId": "ami-044db034021ea23f7",
                    "InstanceId": "redacted",
                    "InstanceType": "t2.micro",
                    "MetadataOptions": {
                        "State": "applied",
                        "HttpTokens": "optional",
                        "HttpPutResponseHopLimit": 1,
                        "HttpEndpoint": "enabled",
                        "HttpProtocolIpv6": "disabled",
                        "InstanceMetadataTags": "disabled"
                    },
                    "PlatformDetails": "Linux/UNIX",
                    "UsageOperation": "RunInstances",
                }
            ],
        }
    ]
}

The tfstate does believe it is set though.

"metadata_options": [
  {
    "http_endpoint": "enabled",
    "http_put_response_hop_limit": 0,
    "http_tokens": "required",
    "instance_metadata_tags": "enabled"
  }
],

References

@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 Jul 20, 2022
@ewbankkit ewbankkit added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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

2 participants