Skip to content

Commit

Permalink
Merge pull request #989 from gruntwork-io/IAC-1847-IMDSv2-migration
Browse files Browse the repository at this point in the history
Migrate ip sanity check script to IMDSv2
  • Loading branch information
zackproser authored Sep 17, 2021
2 parents c00bbe0 + 898b351 commit af551b5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/terraform-remote-exec-example/files/get-public-ip.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit af551b5

Please sign in to comment.