Skip to content
Cloud Governance Tools

Require IMDSv2 for new EC2 instances (declarative policy)

Require IMDSv2 for new EC2 instances (declarative policy) is an AWS guardrail written in declarative policies. Sets instance metadata defaults to http_tokens required and enforced, so new EC2 launches use IMDSv2 token-backed sessions. AWS documents that the account status report shows the current status of the attributes a declarative policy supports for the accounts in scope.

More identity and privilege guardrails ยท About Declarative policies

{
  "ec2_attributes": {
    "instance_metadata_defaults": {
      "http_tokens": {
        "@@assign": "required"
      },
      "http_put_response_hop_limit": {
        "@@assign": "4"
      },
      "http_endpoint": {
        "@@assign": "enabled"
      },
      "instance_metadata_tags": {
        "@@assign": "enabled"
      },
      "http_tokens_enforced": {
        "@@assign": "enabled"
      }
    }
  }
}
Blocks
Sets instance metadata defaults to http_tokens required and enforced, so new EC2 launches use IMDSv2 token-backed sessions.
Breaks
AWS says to make sure no instances are making IMDSv1 calls before setting http_tokens to required, and recommends a hop limit of at least 2 when it is required. (source)
Test before applying
As for every Declarative policies guardrail: how to test before enforcing
Mechanism
Declarative policies: The configuration of a supported AWS service attribute in the accounts, OUs or organization they are attached to, including actions by service-linked roles.
Taken from
provider documentation, provider documentation

What the source says

"instance_metadata_defaults: {" (read 10 Nov 2026).

On what it breaks: "Before setting http_tokens to required (IMDSv2 must be used), make sure that none of your instances are making IMDSv1 calls."

Sources

  1. Require IMDSv2 for new EC2 instances (declarative policy), read 10 Nov 2026
  2. How to test it first, read 10 Nov 2026

Last reviewed 16 Nov 2026.