diff --git a/examples/terraform-remote-exec-example/files/get-public-ip.sh b/examples/terraform-remote-exec-example/files/get-public-ip.sh index baea9620b..bcc35e604 100644 --- a/examples/terraform-remote-exec-example/files/get-public-ip.sh +++ b/examples/terraform-remote-exec-example/files/get-public-ip.sh @@ -1,5 +1,5 @@ #!/bin/bash -# For example purposes, print the public IP address of this instance -wget -q -O- http://169.254.169.254/latest/meta-data/public-ipv4 - +# For example purposes, print the public IP address of this instance. This example uses Instance Metadata Service version 2. +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/public-ipv4