Skip to content

EC2 launch templates should use Instance Metadata Service Version 2 (IMDSv2)

This control checks whether an Amazon EC2 launch template is configured with Instance Metadata Service Version 2 (IMDSv2). The control fails if HttpTokens is set to optional.

How to fix

Attribute metadata_options[0].http_tokens of aws_launch_template must be "required".

Implementation options

Choose the option that matches how you manage Terraform. All options satisfy this control.

Option 1: Terraform AWS provider resources

If you manage resources directly, configure the relevant Terraform AWS provider resources to meet this control. See docs for the resources involved: aws_launch_template.

resource "aws_launch_template" "this" {
  metadata_options {
    http_tokens = "required"
  }
}
Which option should I choose?
  • Compliance.tf module (recommended): controls enforced by default and mapped to frameworks.
  • Open source module (terraform-aws-modules): compatible by design with compliance.tf. Same variable names for an easy, low-change migration path when you are ready.
  • Terraform AWS provider resources: manage Terraform resources directly.

Tool mappings

Use these identifiers to cross-reference this control across tools, reports, and evidence.

  • Compliance.tf (CTF) Control: ec2_launch_template_default_version_uses_imdsv2

  • AWS Config Managed Rule: EC2_LAUNCH_TEMPLATE_IMDSV2_CHECK

  • Powerpipe Control: aws_compliance.control.ec2_launch_template_default_version_uses_imdsv2