TRY AND ERRΦR

気になったこと、勉強したこと、その他雑記など色々メモしていきます。。Sometimes these posts will be written in English.,

My convenient snippet for showing information of EC2 instance.

If you want to make sure ec2 instance information from inner itself, you should check this post.
(Describes about in the case of EC2-AmazonLinux which has already installed `aws` command.)

For instance this is an alias named `me` that output instance's specified tag, type, private ip and public ip to the console.

/etc/profile.d/me.sh

alias me="me"
function me() {
	aws ec2 describe-instances \
		--region [region] \
		--instance-ids `/usr/bin/curl -s http://169.254.169.254/latest/meta-data/instance-id` \
		--query 'Reservations[].Instances[].Tags[?Key==`[tag key]`].Value' \
		--output text;

	curl http://169.254.169.254/latest/meta-data/instance-type;
	echo;

	curl http://169.254.169.254/latest/meta-data/local-ipv4;
	echo;

	curl http://169.254.169.254/latest/meta-data/public-ipv4;
	echo
}


Type `me` on the console.

$ me