imdsv2.devEC2 metadata, from the docs

IMDSv2: what it is and how to require it

IMDSv2 is version 2 of the EC2 Instance Metadata Service (IMDS) at 169.254.169.254, where code on an instance reads its settings and role credentials. Code must PUT for a token, valid up to 6 hours, and send it with each request. Tokenless IMDSv1 stays on until you set HttpTokens to required.

Require and enforce it in every RegionRun steps 1-3 first
for r in $(aws ec2 describe-regions \
  --query "Regions[*].RegionName" \
  --output text); do
 aws ec2 modify-instance-metadata-defaults \
  --region "$r" --http-tokens required \
  --http-tokens-enforced enabled
done

AWS's own loop. After it, any new launch in this account that allows IMDSv1 fails.

Published December 1, 2026 · Updated December 2, 2026. From AWS's IMDS docs, each tool's own page, and the Terraform IMDS defaults dataset: 35 modules read in their source.

Versions

How does IMDSv2 differ from IMDSv1?

IMDSv1 answers any GET from the instance; IMDSv2 answers only requests carrying a token, and getting one takes a PUT.

IMDSv1IMDSv2
First requestGET the path you wantPUT /latest/api/token
Every request carriesNothingX-aws-ec2-metadata-token
Token lifetimeNo token1 second to 6 hours (21,600 seconds)
Relayed by a proxyAnsweredNo token if the PUT has X-Forwarded-For
Token travelsNo token1 hop by default
Bad or missing tokenNot checked401 once IMDSv2 is required

From AWS's IMDS documentation, read December 1, 2026.

AWS's security blog (November 2019) explains: most open web application firewalls don't pass a PUT, the X-Forwarded-For refusal stops open reverse proxies, and the hop limit keeps the token on the instance. Azure, Google Cloud and Oracle Cloud answer at the same address with their own headers: see 169.254.169.254 in each cloud.

Require it

How do you require IMDSv2 across an AWS account?

AWS's recommended path has five steps:

  1. Find instances that allow IMDSv1.List those whose HttpTokens is optional and check their MetadataNoToken metric. Find the instances that still allow IMDSv1 has the commands.
  2. Update software that calls IMDS.AWS's supported SDK list gives the first IMDSv2 versions, such as AWS CLI 1.16.289 and Boto3 1.12.6. Scripts that call IMDS themselves need the token too: the curl and PowerShell calls.
  3. Require it on running instances.Immediate, with no restart:
    aws ec2 modify-instance-metadata-options \
      --instance-id i-1234567890abcdef0 \
      --http-tokens required --http-endpoint enabled
  4. Make it the default for new instances.Per Region; running instances are unchanged:
    aws ec2 modify-instance-metadata-defaults --region us-east-1 \
      --http-tokens required --http-put-response-hop-limit 2
  5. Enforce it.Launches that allow IMDSv1 then fail. The loop above does every Region; an AWS Organizations declarative policy does every account:
    aws ec2 modify-instance-metadata-defaults --region us-east-1 \
      --http-tokens required --http-tokens-enforced enabled

Launch values beat the account default, which beats the AMI. AMIs with ImdsSupport v2.0, such as Amazon Linux 2023, launch with tokens required.

Infrastructure as code

How do you require IMDSv2 in Terraform, CloudFormation and launch templates?

Write it into every template: http_tokens = "required" in Terraform's metadata_options block, HttpTokens: required in CloudFormation's MetadataOptions. Neither the Terraform AWS provider nor CloudFormation picks a value for you; left out, the Region's default decides, then the AMI.

resource "aws_launch_template" "nodes" {
  metadata_options {
    http_endpoint               = "enabled"
    http_tokens                 = "required"
    http_put_response_hop_limit = 2
  }
}
LaunchTemplateData:
  MetadataOptions:
    HttpEndpoint: enabled
    HttpTokens: required
    HttpPutResponseHopLimit: 2

The hop limit of 2 is for EKS and other container hosts, where pods sit one hop further from the instance. Use 1 where no container needs metadata.

AWS's security blog (September 28, 2023) gives the same rule for CloudFormation launch templates. It also shows an SCP that denies ec2:RunInstances unless ec2:MetadataHttpTokens is required, and the Systems Manager runbook EnforceEC2InstanceIMDSv2 for instances already running.

Slack ran about 60,000 instances in 17 Regions in 2023. It changed its shared Terraform modules to write required unless an account was on an IMDSv1 list, then took accounts off the list as teams moved (Slack Engineering, December 12, 2023).

Measured

Do popular Terraform modules and EKS tools require IMDSv2 by default?

Most popular modules do: 20 of the 35 most-downloaded Terraform modules that launch EC2 instances require tokens unless you change them. Those 20 hold 98.6% of the 35 modules' downloads. AWS CDK, Pulumi EKS and the Terraform provider itself set nothing.

What the module setsModulesShare
Tokens requiredterraform-aws-modules eks 21.30.2, ec2-instance 6.4.1 and autoscaling 9.3.2; cloudposse ec2-instance 2.0.02098.6%
Nothing: the Region's default or the AMI decidessquareops eks 5.4.4, infrablocks ecs-cluster 6.1.0, hashicorp vault 0.17.0111.1%
IMDSv1 allowed until you flip a variableGuimove bastion 3.0.6, boldlink ecs-cluster 3.0.020.2%
Depends on the submodulePaloAltoNetworks vmseries-modules 1.1.6 and swfw-modules 2.2.720.1%

The latest version of each module, read in its source on December 1, 2026. Share is of downloads: each module's all-time count on the Terraform Registry, out of the 35 modules' 310 million.

Age matters most. Of the 8 modules whose latest release is older than 2024, only 1 requires tokens; of the 20 released in 2025 or 2026, 16 do.

Tool, latest releaseDefault for new nodes or instances
eksctl 0.232.0Required, hop limit 2 (1 with disablePodIMDS)
Karpenter 1.15.3Required, hop limit 1
kops 1.37.0Required, hop limit 1
AWS CDK 2.278.0Nothing unless requireImdsv2 is true
Pulumi EKS 4.6.0Nothing unless enableIMDSv2 is set
Terraform AWS provider 6.74.0Nothing: http_tokens has no default
CloudFormationNothing: the AMI and the account default decide

Each name links to the line or page that sets the default, read December 1, 2026. Where a tool sets nothing, the Region's default applies, then the AMI's ImdsSupport; with neither, IMDSv1 stays on.

The Terraform IMDS defaults dataset. It takes the Terraform Registry's 500 most-downloaded AWS modules on December 1, 2026, keeps the 35 whose latest version creates an instance, launch template or launch configuration, and records the http_tokens default in each one's source at that version. The six tools were read in their source at their latest release, and CloudFormation in AWS's template reference. Every module and tool, with its version and source line, is in terraform-modules-imds-defaults.csv (CC BY 4.0), and the IMDSv1 page lists the 15 modules that don't require tokens, with what Checkov found in each.

A sketch, not a census: 35 modules from one registry, and a default is only where a template starts. Set the Region's default (step 4) so that whatever a template leaves out is still covered.

Containers

What hop limit does IMDSv2 need for containers?

2, when code in a container needs metadata. The token's PUT response stops after 1 hop by default, too short to reach a container; AWS recommends 2 there, within a range of 1 to 64.

Amazon Linux 2023 starts at 2. AWS's AL2023 guide says instances launched from its AMI require IMDSv2 and get a default hop limit of 2, to support container workloads. So containers on an AL2023 instance can reach the token. Where none needs metadata, set --http-put-response-hop-limit 1 (the IMDSv1 page shows the call).

Compared

Which ways enforce IMDSv2 or flag IMDSv1, and what do they cost?

The EC2 and IAM settings are free and block IMDSv1 on AWS itself. Checkov, Trivy and KICS stop it in Terraform code before apply; the last three report on what is already running.

WayBlocks IMDSv1PriceWhat it doesThe limit that decides
Account default and enforcementYesFreeTokens on new launches; enforcement refuses IMDSv1 launchesPer Region; running instances unchanged
Instance settingYesFreeTokens on one running instanceOne call per instance
IAM or SCP condition keysYesFreeDenies launches and changes that allow IMDSv1You write the policy
Checkov CKV_AWS_79In codeFree, Apache-2.0Fails Terraform that doesn't set tokens to requiredReads code, not running instances
Trivy AVD-AWS-0028 and 0130In codeFree, Apache-2.00028 flags instances, 0130 launch templates and configurations, without required tokensReads code, not running instances
KICS IMDSv1 queryIn codeFree, Apache-2.0Flags the same three resources, and modules that make themRated Low severity
AWS Config ec2-imdsv2-checkNo$0.003 a change + $0.001 an evaluationFlags instances with HttpTokens optionalA record, no fix
Security Hub EC2.8 and EC2.170No30-day free trial, then per resource unitEC2.8 checks instances (High); EC2.170 launch templates (Low)Needs AWS Config
ProwlerNoFree open source; Cloud $79 to $99 an account a monthSame check from a scanner you runSnapshot unless scheduled

Prices read December 1, 2026; Checkov, Trivy, KICS and Security Hub read December 2, 2026. AWS Config, US East, first 100,000 evaluations: 200 changes, each evaluated once, is 200 × ($0.003 + $0.001) = $0.80.

1

EC2 account defaults and enforcement

Best for every new launch

Price: Free, part of EC2.

A Region default that makes new launches require tokens, plus a switch that refuses IMDSv1 launches.

Good for

  • Every new launch, whatever the template
  • Enforcement stops IMDSv1 coming back

Watch out

  • Set in each Region
  • Running instances keep their setting

AWS docs: new instances

2

The instance setting (HttpTokens)

Best to fix one instance now

Price: Free, part of EC2.

modify-instance-metadata-options switches one running instance to tokens only.

Good for

  • Immediate, no restart
  • Also sets the hop limit, or turns IMDS off

Watch out

  • One instance per call
  • Reversible unless enforcement is on

AWS docs: existing instances

3

IAM or SCP condition keys

Best for many accounts

Price: Free, part of IAM.

Deny launches and changes unless ec2:MetadataHttpTokens is required, in an IAM policy or SCP.

Good for

  • Blocks IMDSv1 at the API, across accounts
  • Can also pin the hop limit

Watch out

  • You write and test the policy
  • Doesn't fix running instances

AWS docs: example policies

4

Checkov CKV_AWS_79

Best for Terraform in CI

Price: Free, open source under Apache-2.0 (version 3.4.14).

Fails any aws_instance, aws_launch_template or aws_launch_configuration whose http_tokens isn't required, unless the endpoint is off. Run on the source of the 15 popular modules that don't require tokens on December 2, 2026, it failed 10.

checkov -d . --check CKV_AWS_79

Good for

  • Catches IMDSv1 before terraform apply
  • No AWS account or Config needed

Watch out

  • Reported nothing for 5 of the 15, including one whose default is optional
  • Says nothing about running instances

Checkov's CKV_AWS_79 source

5

Trivy AVD-AWS-0028 and 0130

Best if Trivy already scans your images

Price: Free, open source under Apache-2.0 (version 0.77.0).

AVD-AWS-0028 (High) flags an aws_instance whose http_tokens isn't required unless the endpoint is off; AVD-AWS-0130 does the same for launch configurations and templates.

trivy config .

Good for

  • One scanner for images, IaC and code
  • Covers templates and configurations too

Watch out

  • Says nothing about running instances
  • Not run on this site's 15 modules

Trivy AVD-AWS-0028

6

KICS IMDSv1 query

Best for checking module calls too

Price: Free, open source under Apache-2.0 (version 2.2.1).

“Instance Uses Metadata Service IMDSv1” flags aws_instance, aws_launch_template and aws_launch_configuration without http_tokens = "required", and module calls that create them.

Good for

  • Also reads module calls
  • Same query for CloudFormation and Ansible

Watch out

  • Rated Low severity, so easy to filter out
  • Not run on this site's 15 modules

KICS query source

7

AWS Config rule ec2-imdsv2-check

Best for audit evidence

Price: $0.003 per configuration item recorded plus $0.001 per rule evaluation (first 100,000 a month, US East).

Marks an instance NON_COMPLIANT while HttpTokens is optional, checking again on each change.

Good for

  • A dated record for audits
  • Nothing to write: a managed rule

Watch out

  • Reports only
  • Cost grows with recorded changes

AWS Config rule docs

8

Security Hub controls EC2.8 and EC2.170

Best if you run CIS or PCI DSS

Price: 30-day free trial, then a monthly price per resource unit (no flat figure on AWS's page).

EC2.8 checks instances (High; CIS AWS Foundations v5.0.0 5.7, PCI DSS v4.0.1 2.2.6). EC2.170 fails a launch template whose HttpTokens is optional (Low).

Good for

  • Findings from all accounts in one console
  • Catches templates before they launch anything

Watch out

  • Needs AWS Config in each account and Region
  • Price it first

Security Hub EC2 controls

9

Prowler

Best without AWS Config

Price: Free open source; Prowler Cloud $99 per cloud account a month, or $79 billed annually.

Its check passes an instance when tokens are required or the endpoint is off:

prowler aws --checks ec2_instance_imdsv2_enabled

Good for

  • Runs from a laptop or CI, no AWS Config
  • Also scans Azure and Google Cloud

Watch out

  • A snapshot unless scheduled
  • Hosted plan per account

Prowler check page

Choose

Which way should you pick?

  • One account: the instance setting, then defaults and enforcement in each Region.
  • Many accounts: an SCP on ec2:MetadataHttpTokens, plus defaults and enforcement in each.
  • An auditor wants evidence: AWS Config's rule, or Security Hub EC2.8 and EC2.170 if you run it for CIS or PCI DSS.
  • No AWS Config, or several clouds: Prowler on a schedule.
  • Infrastructure as code: required in every template, Checkov, Trivy or KICS in CI, and the Region's default behind it.
Questions

What else do people ask about IMDSv2?

Why is IMDSv2 better than IMDSv1?

It needs a PUT and a token. Most open firewalls and reverse proxies won't pass that on, so an SSRF bug can't read the instance's credentials as easily.

What does IMDS stand for in AWS?

Instance Metadata Service. It tells code on an EC2 instance about that instance and hands out its IAM role's temporary credentials, at 169.254.169.254.

Does Terraform require IMDSv2 by default?

No. The AWS provider sets no default for http_tokens. Many modules do, such as terraform-aws-modules' ec2-instance and eks.

Does requiring IMDSv2 need a restart?

No. modify-instance-metadata-options changes a running instance immediately.

Does IMDSv2 cost anything?

No. AWS doesn't bill metadata requests, and the settings are free.

Will requiring IMDSv2 break my software?

Only software that calls IMDS without a token. The MetadataNoToken metric shows it; the IMDSv1 page says how to read it.

Is IMDSv2 on by default?

Not on most instances: both versions work unless a launch value, the Region's default or an AMI with ImdsSupport v2.0 requires tokens. Console Quick Starts have launched IMDSv2-only since November 2023, Amazon Linux 2023 starts that way, and AWS said instance types released from mid-2024 would too.

Can I turn the metadata service off?

Yes: --http-endpoint disabled. Nothing on the instance can then read metadata.

Sources

How was this page checked?

35Terraform modules read in their source
Dec 1-2, 2026when each source was read
0tools bought or accounts touched

The commands are AWS's own examples. We ran Checkov 3.4.14 with only CKV_AWS_79 on the source of the 15 modules on December 2, 2026; its result for each is a column in the CSV. Errors: support@winding.ai.

  1. AWS: Use the Instance Metadata Service, Transition to IMDSv2, IMDS options, new instances, existing instances, example policies, access instance metadata
  2. AWS Security Blog, November 19, 2019; AWS Security Blog, September 28, 2023; Slack Engineering, December 12, 2023
  3. Use a supported AWS SDK, CloudFormation MetadataOptions, Terraform Registry AWS modules; each module's source line is in the CSV
  4. ec2-imdsv2-check, AWS Config pricing, Security Hub EC2 controls, Security Hub pricing, IAM cost, Organizations cost
  5. Prowler check, Prowler pricing; Checkov CKV_AWS_79, Checkov license; Trivy AVD-AWS-0028 and AVD-AWS-0130; KICS query (read December 2, 2026)
  6. Amazon Linux 2023 User Guide: IMDSv2 (read December 2, 2026)

About this site

imdsv2.dev is published by Winding AI, Inc., which makes IonCipher. It explains one EC2 setting from AWS's own documentation and is not affiliated with or endorsed by Amazon Web Services.