Skip to content

Commit 0df641b

Browse files
committed
force enable IMDSv2 on EC2.
1 parent 2568c02 commit 0df641b

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

infra-iac/packer/main.pkr.hcl

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,44 @@ source "amazon-ebs" "orch" {
2626
owners = ["amazon"] // 或实际拥有此 AMI 的 AWS 账户 ID
2727
most_recent = true
2828
}
29-
29+
3030
ssh_username = "ubuntu"
31-
31+
3232
# Enable nested virtualization
3333
ami_virtualization_type = "hvm"
34-
35-
# Use EBS for the root volume
34+
35+
# Force IMDSv2
36+
metadata_options {
37+
http_endpoint = "enabled"
38+
http_tokens = "required"
39+
http_put_response_hop_limit = 1
40+
}
41+
42+
# Tags for the temporary instance and AMI
43+
tags = {
44+
team = "GenAI"
45+
service = "GenAI"
46+
owner = "GenAI"
47+
cost_center = "GenAI"
48+
component = "GenAI"
49+
}
50+
51+
# Tags for the temporary instance only
52+
run_tags = {
53+
team = "GenAI"
54+
service = "GenAI"
55+
owner = "GenAI"
56+
cost_center = "GenAI"
57+
component = "GenAI"
58+
}
59+
60+
# Use EBS for the root volume with encryption
3661
launch_block_device_mappings {
3762
device_name = "/dev/sda1"
3863
volume_size = 10
3964
volume_type = "gp3"
4065
delete_on_termination = true
66+
encrypted = true
4167
}
4268
}
4369

0 commit comments

Comments
 (0)