CircleCI-Public / CircleCI-Public/circleci-server-linux-image-builder
[memo] setting IMDS support to IMDSv2 (for AWS AMI)
- Dominant language
- Shell
- Stars
- 3
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
⚠️ **Disclaimer**: I have not verified this solution.
Based on [the AWS docs here](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-IMDS-new-instances.html#configure-IMDS-new-instances-ami-configuration), we can configure the AMI to require IMDSv2 when registering the AMI image:
```
aws ec2 register-image \
--name \
--imds-support v2.0 \
...
```
This repo uses Hashicorp Packer.
I understand, to set IMDS support to v2, we can set `imds_support: "v2.0"` for the AMI configuration:
https://developer.hashicorp.com/packer/integrations/hashicorp/amazon/latest/components/builder/ebs#ami-configuration
I _think_ this is simply adding `imds_support: "v2.0"` at the **same level** as where `ami_name` is configured then:
https://github.com/CircleCI-Public/circleci-server-linux-image-builder/blob/main/ubuntu-20.04/packer.yaml#L59-L72
For example:
```diff
instance_type: "t3a.medium"
ami_name: "ubuntu-2004-vm-circleci-classic-{{timestamp}}"
ssh_username: "circleci"
ami_groups: "all"
+ imds_support: "v2.0"
launch_block_device_mappings:
- device_name: "/dev/sda1"
volume_size: 10
volume_type: "gp2"
delete_on_termination: true
user_data: |
#cloud-config
system_info:
default_user:
name: circleci
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Open ubuntu-20.04/packer.yaml around lines 59-72 and compare its AMI configuration with the linked Packer documentation and AWS IMDS guidance. Verify the proposed setting in the image-building process; done means the AMI registers successfully with IMDSv2 required.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, yaml
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100