Help us understand the problem. What is going on with this article?

EC2インスタンスにtagで付けた名前をサーバー内から取得する

More than 5 years have passed since last update.

EC2起動時にName=my-web-serverというtagを付けたとき、
立ち上げたサーバー内からこのタグを取得する方法。

[ec2-user@ip-10-150-000-00 ~]$ ec2-describe-instances | grep `/usr/bin/curl -s http://169.254.169.254/latest/meta-data/instance-id` | grep TAG | grep Name | cu
t -f5
my-web-server

EC2インスタンスから169.254.169.254(全region共通らしい)にHTTPリクエストを送ることで、自身のメタデータをREST的に取得することが出来る。

自身のinstance-id, TAG行, keyがNameのもの、とgrep絞り込んでcutする。
grepの積集合マッチ、正規表現でもっと簡単に書けそう...。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away