LoginSignup
2
0

More than 5 years have passed since last update.

Alibaba Cloud ECS でのインスタンスメタデータとユーザデータの取得方法

Posted at

実行中のインスタンス上で、インスタンスメタデータ・ユーザデータを取得する方法についてです。

ちなみに、Amazon EC2 の場合は以下で取得できます。

$ curl http://169.254.169.254/latest/meta-data
$ curl http://169.254.169.254/latest/user-data

Alibaba Cloud ECS の場合、アドレスを 100.100.100.200 に変更すればO.K.です。

curl http://100.100.100.200/latest/meta-data
curl http://100.100.100.200/latest/user-data

インスタンスメタデータ

$ curl http://100.100.100.200/latest/meta-data
dns-conf/
eipv4
hostname
image-id
instance-id
instance/
launch-index
mac
network-type
network/
ntp-conf/
owner-account-id
private-ipv4
region-id
serial-number
source-address
sub-private-ipv4-list
vpc-cidr-block
vpc-id
vswitch-cidr-block
vswitch-id
zone-id

いくつか取得してみました。

image-id

$ curl http://100.100.100.200/latest/meta-data/image-id
centos_7_04_64_20G_alibase_201701015.vhd

instance-type

$ curl http://100.100.100.200/latest/meta-data/instance/instance-type
ecs.n4.small

region-id

$ curl http://100.100.100.200/latest/meta-data/region-id
ap-northeast-1

ユーザデータ

$ curl http://100.100.100.200/latest/user-data
#!/bin/bash
echo "Hello! Test!"

まとめ

2
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
2
0