File tree 3 files changed +5
-3
lines changed
3 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -6,5 +6,5 @@ python3 get-pip.py --user
6
6
export PATH=~/.local/bin:$PATH
7
7
8
8
pip install aws-ec2-assign-elastic-ip
9
- export AWS_DEFAULT_REGION=$(curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | awk -F\" '{ print $4} ')
9
+ export AWS_DEFAULT_REGION=$(curl -s -H "X-aws-ec2-metadata-token: $token" http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | awk -F\" '{ print $4} ')
10
10
/usr/local/bin/aws-ec2-assign-elastic-ip --valid-ips ${ eip}
Original file line number Diff line number Diff line change @@ -33,11 +33,11 @@ initial_position = start_of_file
33
33
EOF
34
34
35
35
# Set the region to send CloudWatch Logs data to (the region where the instance is located)
36
- region =$(curl -s 169.254.169.254 /latest /dynamic /instance-identity /document | jq -r .region)
36
+ region =$(curl -s -H " X-aws-ec2-metadata-token: $token " http: // 169.254.169.254 /latest /dynamic /instance-identity /document | jq -r .region)
37
37
sed -i -e " s/region = us-east-1/region = $region/g" /etc /awslogs /awscli.conf
38
38
39
39
# Replace instance id.
40
- instanceId =$(curl -s 169.254.169.254 /latest /dynamic /instance-identity /document | jq -r .instanceId)
40
+ instanceId =$(curl -s -H " X-aws-ec2-metadata-token: $token " http: // 169.254.169.254 /latest /dynamic /instance-identity /document | jq -r .instanceId)
41
41
sed -i -e " s/{ instanceId} /$instanceId/g" /etc /awslogs /awslogs.conf
42
42
43
43
if grep -q ' :2$' /etc /system-release-cpe ; then
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ tee /etc/hosts <<EOL
10
10
127.0.0.1 localhost localhost.localdomain $( hostname)
11
11
EOL
12
12
13
+ token=$( curl -f -X PUT " http://169.254.169.254/latest/api/token" -H " X-aws-ec2-metadata-token-ttl-seconds: 300" )
14
+
13
15
${eip}
14
16
15
17
for i in {1..7}; do
You can’t perform that action at this time.
0 commit comments