From fa66efaf6ef09098c889bccd9b1eb1f39d878f92 Mon Sep 17 00:00:00 2001 From: Wilken Rivera Date: Fri, 3 Nov 2023 10:49:58 -0400 Subject: [PATCH] Add legacy JSON example --- .../ubuntu-imdsv2-enabled.json | 41 +++++++++++++++++++ .../ubuntu-imdsv2-enabled.pkr.hcl | 1 - 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 example/instance-metadata/ubuntu-imdsv2-enabled.json diff --git a/example/instance-metadata/ubuntu-imdsv2-enabled.json b/example/instance-metadata/ubuntu-imdsv2-enabled.json new file mode 100644 index 000000000..d5e69f066 --- /dev/null +++ b/example/instance-metadata/ubuntu-imdsv2-enabled.json @@ -0,0 +1,41 @@ +{ + "_comment": "Template used for testing issue 8157", + "variables": { + "region": "us-east-1" + }, + "builders": [ + { + "type": "amazon-ebs", + "ami_name": "packer-example-{{ timestamp }}", + "region": "{{ user `region`}}", + "instance_type": "t2.micro", + "source_ami_filter": { + "filters": { + "virtualization-type": "hvm", + "name": "ubuntu/images/*ubuntu-jammy-22.04-amd64-server-*", + "root-device-type": "ebs" + }, + "owners": [ + "099720109477" + ], + "most_recent": true + }, + "ssh_username": "ubuntu", + "communicator": "ssh", + "metadata_options":{ + "http_endpoint" : "enabled", + "http_tokens": "required", + "http_put_response_hop_limit": 1 + }, + "imds_support":"v2.0" + } + ], + "provisioners": [ + { + "type": "shell", + "inline": [ "TOKEN=`curl -s -X PUT \"http://169.254.169.254/latest/api/token\" -H \"X-aws-ec2-metadata-token-ttl-seconds: 21600\"` && curl -H \"X-aws-ec2-metadata-token: $TOKEN\" -s http://169.254.169.254/latest/meta-data/"] + } + ] + } + + diff --git a/example/instance-metadata/ubuntu-imdsv2-enabled.pkr.hcl b/example/instance-metadata/ubuntu-imdsv2-enabled.pkr.hcl index b2f8402e8..ec36ab1cd 100644 --- a/example/instance-metadata/ubuntu-imdsv2-enabled.pkr.hcl +++ b/example/instance-metadata/ubuntu-imdsv2-enabled.pkr.hcl @@ -42,5 +42,4 @@ build { provisioner "shell" { inline = ["TOKEN=`curl -s -X PUT \"http://169.254.169.254/latest/api/token\" -H \"X-aws-ec2-metadata-token-ttl-seconds: 21600\"` && curl -H \"X-aws-ec2-metadata-token: $TOKEN\" -s http://169.254.169.254/latest/meta-data/"] } - provisioner "breakpoint" {} }