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::Instance - MetadataOptions #655

Open
michaelwittig opened this issue Oct 15, 2020 · 23 comments
Open

AWS::EC2::Instance - MetadataOptions #655

michaelwittig opened this issue Oct 15, 2020 · 23 comments
Labels

Comments

@michaelwittig
Copy link

1. AWS::EC2::Instance-MetadataOptions

2. Scope of request

Add support to configure the EC2 IMDS to support:

  • Enable/disable the endpoint
  • Set the HTTP response hop limit
  • Make HTTP tokens optional (default) or required (disables IMDSv1)

3. Expected behavior

Allow CloudFormation to launch EC2 instance with IMDS disabled or restricted to v2.

5. Helpful Links to speed up research and evaluation

6. Category

  1. Compute (EC2, ECS, EKS, Lambda...)

7. Context

related #273 for for WS::AutoScaling::LaunchConfiguration

@0xdabbad00
Copy link

Looks like this is now possible via Launch Templates: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-launchtemplate-launchtemplatedata.html#cfn-ec2-launchtemplate-launchtemplatedata-metadataoptions

@mildebrandt
Copy link

@0xdabbad00 Right, that has been true for quite a while. This issue is to add it to the AWS::EC2::Instance type: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html

@coreylane
Copy link

Any update?

1 similar comment
@yoroto
Copy link

yoroto commented Mar 18, 2022

Any update?

@fortygigserver
Copy link

This would also be useful to set the feature "instance-metadata-tags" to enabled

@r-azh
Copy link

r-azh commented Mar 25, 2022

I agree this is a useful feature to set the feature "instance-metadata-tags" to enabled.

@kenlawrie1
Copy link

Hi, any update on this? Having to use launch templates to enable ImdsV2 on EC2 instance is causing us issues.
Launch template don't allow tags with spaces, and our SCP policies fail if we enforce both tags and ImdsV2 at the same time, hopefully when this CloudFormation limitation is resolved.

@edc1934
Copy link

edc1934 commented Jul 25, 2022

Any updates? Also need this feature.

@JohnPeacockMessageSystems

Going on two years for this trivial feature. I'm still trying to use Service Catalog, which requires vanilla CloudFormation. The InstanceMetadataTags option is missing from Launch Templates, so I can't use that either.

@donwalter
Copy link

Add me to the list of people who would like this feature added.

@torabTech
Copy link

Hi everyone,

Is there any example of enabling IMDSv2 in Autoscaling:Launchconfiguration cloudformation template? I would highly appreciate any reference or example.

@otakusid
Copy link

otakusid commented Oct 31, 2022

@torabTech HttpPutResponseHopLimit set to 2 is required because the IMDSv2 will bring the extra hop in communication with metadata service

"LaunchTemplate":{
  "Properties":{
    "LaunchTemplateData":{
      "MetadataOptions":{
        "HttpTokens":"required",
        "HttpPutResponseHopLimit":2
      }
    }
  },
  "Type":"AWS::EC2::LaunchTemplate"
}

"AutoScalingGroup": {
  "Properties": {
    "LaunchTemplate": {
      "LaunchTemplateId": {
        "Ref": "LaunchTemplate"
      },

      "Version": {
        "Fn::GetAtt": [
          "LaunchTemplate",
          "LatestVersionNumber"
        ]
      }
    }
  "Type": "AWS::AutoScaling::AutoScalingGroup"
}

@cs-dww
Copy link

cs-dww commented Nov 9, 2022

Adding a +1 here. We need this option as well.

AWS - What if we said Pretty Please?

@Rob-El
Copy link

Rob-El commented Dec 12, 2022

IMDSv2 is also part of the Security Hub standards - EC2.8 EC2 instances should use Instance Metadata Service Version 2 (IMDSv2). Our security score gets dinged when we don't use IMDSv2, but we're also supposed to use code to provision resources. This creates a catch-22 situation. I hope this helps as far as prioritizing. Thank you!

@siebrand
Copy link

@Rob-El : use a launch template for your instance with only those parts that you need, and include that in the instance. It also allows you to tag network interfaces and volumes as a bonus. But beware of changes in the launch template once deployed, as that can cause a redeploy.

@Rob-El
Copy link

Rob-El commented Dec 12, 2022

@siebrand Thanks for the tip! I do understand that launch templates are a workaround, I read through all the previous comments. In my opinion, Launch Templates adds a cumbersome amount of config, for various reasons.

Also, redeployment is highly undesirable in our environment, as we have a lot of 3rd-party, static applications that are long-lived. (We create the server, install the OS, hand it off to another team.) Over time we add additional tags, add a volume, etc. If any of those operations (or the dozen other reasons we update a CF template) caused a re-deploy, it would wipe the app and force a restore from backups, etc.

I'm happy to use ELB, ASGs, and Launch Templates for their own particular use cases, but these applications are not designed for use in those environments. Thanks again!

@josephhernandezphd
Copy link

Extremely useful option. This should be roadmapped.

@smorgant
Copy link

Same here, having to rewrite all my template to be able to get "instance-metadata-tags" to enabled, 2 years seems a long time for this to be at minimum reviewed.

@kylegibson
Copy link

Ugh

@kz974
Copy link

kz974 commented Jun 15, 2023

Oh yes please. Been wishing for this since 2019!

@anjanasilva
Copy link

Have you guys realised you can disable IMDSV1 in a running AMI?

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-IMDS-new-instances.html

Run the following from a place where you can run AWS commands,

aws ec2 modify-image-attribute \ --image-id ami-0123456789example \ --imds-support v2.0

Any EC2 instances launched using the above AMI will have IMDSV1 disabled.

I hope this helps,
Thanks

@jpSimkins
Copy link

2024 check in on the status. Still would like to have this for systems that don't need or require a launch template.

@mdgm88
Copy link

mdgm88 commented Oct 16, 2024

You can now set the account level defaults for a region in an account. If you don't explicitly override the defaults it should use the defaults you have set e.g.

aws ec2 modify-instance-metadata-defaults --http-tokens required --http-put-response-hop-limit 2

As AWS::EC2::Instance doesn't support overriding the defaults currently it should use the account level defaults

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests