Created
May 7, 2019 10:40
-
-
Save grohiro/e555a3c8e207449b9c9706bee62c7a9c to your computer and use it in GitHub Desktop.
Bash functions for EC2
This file contains hidden or 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
| # EC2のインスタンスIDを出力する | |
| function ec2_instance_id() | |
| { | |
| curl -s http://169.254.169.254/latest/meta-data/instance-id/ | |
| } | |
| # EC2のインスタンス名を出力する | |
| function ec2_instance_name() | |
| { | |
| aws ec2 describe-instances --instance-ids $(ec2_instance_id) --output text --query 'Reservations[].Instances[].Tags[?Key==\`Name\`].[Value]' | |
| } | |
| export -f ec2_instance_id ec2_instance_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment