Created
September 25, 2021 15:25
-
-
Save jwieder/9d1cbb0cf9e5f5423aaff63b80864c61 to your computer and use it in GitHub Desktop.
This is a very hacky bash script to help get a the publicly assigned hostname of an ec2 instance.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
### this is a very hacky bash script to help get a the publicly assigned hostname of an ec2 instance. | |
### it will only work with instances within us-east-1 because we arent checking region, amazonaws suffix, etc. | |
# Get my public IP | |
publicIP=$(curl -s whatismyip.akamai.com) | |
# Make up AWS EC2 host name with public DNS | |
publicName=ec2-${publicIP//./-}.us-east-1.compute.amazonaws.com | |
# Echo host name | |
echo ${publicName} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment