LoginSignup
0
0

More than 5 years have passed since last update.

EC2 インスタンス内からインスタンスのメタ情報を取得する

Last updated at Posted at 2018-08-16

概要

EC2 インスタンスで作業しててふとこのインスタンスなんだっけってなった時に,いちいちブラウザでコンソール開かなくてもインスタンスの中からメタ情報取得できますよって話です.

How?

AWS さんが公式にメタ情報を取得する術を用意してくれてます.

以下のようにして,取得可能なインスタンスメタデータの一覧を表示できます

$ curl http://169.254.169.254/latest/meta-data/
ami-id
ami-launch-index
ami-manifest-path
block-device-mapping/
hostname
instance-action
instance-id
instance-type
local-hostname
local-ipv4
mac
metrics/
network/
placement/
profile
public-hostname
public-ipv4
public-keys/
reservation-id
security-groups
services/

例えば instance type が欲しい時は,

$ curl http://169.254.169.254/latest/meta-data/instance-type
p2.xlarge

のように取得可能です.

重要の有無はともかく,以上です.

出典

AWS 公式

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0