Skip to content

How do I enforce only IMDSv2 access to my EC2 instance metadata?

2 minute read
0

I want to use only Instance Metadata Service Version 2 (IMDSv2) to access instance metadata from my Amazon Elastic Compute Cloud (Amazon EC2) instance.

Short description

By default, you use one or both of the following methods to retrieve instance metadata from a running Amazon EC2 instance:

  • Instance Metadata Service Version 1 (IMDSv1), a request and response method
  • IMDSv2, a session-oriented method

To require the use of IMDSv2 on an instance, run the AWS Systems Manager AWSSupport-ConfigureEC2Metadata runbook.

Important: When you enforce IMDSv2, you deactivate IMDSv1. This might affect applications that rely on IMDSv1. Before you enforce IMDSv2, make sure that applications that use Amazon EC2 metadata are compatible with IMDSv2. For additional guidance on implementation best practices, see Recommended path to requiring IMDSv2.

Resolution

Prerequisite: Before you start the runbook, make sure that your AWS Identity and Access Management (IAM) user or role has the required permissions. For more information, see the Required IAM permissions section of AWSSupport-ConfigureEC2Metadata.

To run the Systems Manager runbook, complete the following steps:

  1. Open the Systems Manager console.
  2. In the navigation pane, choose Documents.
  3. In the search bar, enter AWSSupport-ConfigureEC2Metadata.
  4. Select AWSSupport-ConfigureEC2Metadata.
  5. Choose InstanceId of the Amazon EC2 instance whose metadata settings you want to configure.
  6. Choose Execute.
    Note: For a list of the steps that the runbook performs, see the Document Steps section of AWSSupport-ConfigureEC2Metadata.
  7. After the automation completes, review the detailed results in the Outputs section.

Related information

Run an automation step by step

Access instance metadata for an EC2 instance

Create the service roles for Automation using the console