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

Support setting EC2 instance metadata to require token (IMDSv2) #10949

Closed
alex opened this issue Nov 20, 2019 · 4 comments · Fixed by #12491
Closed

Support setting EC2 instance metadata to require token (IMDSv2) #10949

alex opened this issue Nov 20, 2019 · 4 comments · Fixed by #12491
Assignees
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.
Milestone

Comments

@alex
Copy link
Contributor

alex commented Nov 20, 2019

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 "me too" comments, 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

Description

Launched here: https://aws.amazon.com/blogs/security/defense-in-depth-open-firewalls-reverse-proxies-ssrf-vulnerabilities-ec2-instance-metadata-service/

EC2 instances can be set to require IMDSv2 only. This can be done to running instances with https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#EC2.ModifyInstanceMetadataOptions or new instances with the MetadataOptions field of RunInstancesInput.

New or Affected Resource(s)

  • aws_instance

Potential Terraform Configuration

resource "aws_instance" "this" {
    // ...
    metadata_options {
        http_tokens = "required"
    }
}

References

@alex alex added the enhancement Requests to existing resources that expand the functionality or scope. label Nov 20, 2019
@ghost ghost added the service/ec2 Issues and PRs that pertain to the ec2 service. label Nov 20, 2019
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Nov 20, 2019
@atpoirie
Copy link

atpoirie commented Nov 21, 2019

This should also support optionally setting the PUT response hop limit

Such as outlined by the following AWS CLI command
aws ec2 modify-instance-metadata-options --instance-id i-1234567898abcdef0 --http-put-response-hop-limit 3

resource "aws_instance" "this" {
    // ...
    metadata_options {
        http_tokens = "required"
        http_put_response_hop_limit = "1"
    }
}

@bflad
Copy link
Contributor

bflad commented Mar 27, 2020

Support for configuring metadata options in the aws_instance and aws_launch_template resources has been merged and will release with version 2.55.0 of the Terraform AWS Provider, later today. Thanks to @stefansundin and @ewbankkit for the implementation. 👍

@ghost
Copy link

ghost commented Mar 27, 2020

This has been released in version 2.55.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Apr 27, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
4 participants