Skip to content
This repository was archived by the owner on Jul 20, 2024. It is now read-only.

Commit c9894cd

Browse files
authored
Export AWS_DEFAULT_REGION (#7)
1 parent 13bc40f commit c9894cd

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ EOF
105105
}
106106
```
107107

108+
The current region is exported as `AWS_DEFAULT_REGION` and you can use awscli without a region option.
109+
108110
### Open SSH port
109111

110112
You can open the SSH port to the NAT instance.

data/init.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/bin/bash -x
22

3+
# Determine the region
4+
export AWS_DEFAULT_REGION="$(/opt/aws/bin/ec2-metadata -z | sed 's/placement: \(.*\).$/\1/')"
5+
36
# Attach the ENI
4-
region="$(/opt/aws/bin/ec2-metadata -z | sed 's/placement: \(.*\).$/\1/')"
57
instance_id="$(/opt/aws/bin/ec2-metadata -i | cut -d' ' -f2)"
6-
aws --region "$region" ec2 attach-network-interface \
8+
aws ec2 attach-network-interface \
79
--instance-id "$instance_id" \
810
--device-index 1 \
911
--network-interface-id "${eni_id}"

0 commit comments

Comments
 (0)