Skip to content

Set ECS host metadata hop limit to 1 - #258

Merged
ale210 merged 1 commit into
mainfrom
251-imds-hop-limit
Oct 10, 2026
Merged

ale210 merged 1 commit into
mainfrom
251-imds-hop-limit

Conversation

@ale210

@ale210 ale210 commented Oct 10, 2026

Copy link
Copy Markdown
Member

Fixes #251.

Adds metadata_options to aws_launch_template.ecs with http_put_response_hop_limit = 1, so containers on Docker's bridge network cannot fetch ecs-ec2-role's credentials from instance metadata. Must land before any service moves to bridge mode (#252–#254).

Expected plan: aws_launch_template.ecs updated in place (mints version 9), 0 to add, 0 to destroy. default_version stays 1; the ASG launches from $Latest. The user_data and default_version comments are updated because both named version 8.

This does not touch the two running instances. After merge they get the same setting by hand with modify-instance-metadata-options, one at a time — see the issue.

Validated locally with Terraform 1.16.0: init -backend=false, validate, and fmt -check on compute.tf.

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Terraform plan in terraform
With backend config files: terraform/prod.backend.tfvars

Plan: 0 to add, 1 to change, 0 to destroy.
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
!~  update in-place

Terraform will perform the following actions:

  # module.platform.aws_launch_template.ecs will be updated in-place
!~  resource "aws_launch_template" "ecs" {
        id                                   = "lt-0093b22d4b048e101"
!~      latest_version                       = 8 -> (known after apply)
        name                                 = "ecs-incubator-prod"
        tags                                 = {}
#        (18 unchanged attributes hidden)

+       metadata_options {
+           http_endpoint               = "enabled"
+           http_put_response_hop_limit = 1
+           http_tokens                 = "********"
        }

#        (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

✅ Plan applied in Terraform apply (OIDC) #99

@ale210
ale210 merged commit 65d8486 into main Oct 10, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Block containers from the ECS host's instance credentials by setting the metadata hop limit to 1

1 participant