Amazon EC2ã§èµ·åããä»®æ³ãµã¼ã(ã¤ã³ã¹ã¿ã³ã¹)ã§ã¯ããµã¼ãã®å é¨ããããã®ãµã¼ãèªèº«ã®å種ã¡ã¿ãã¼ã¿(MetaData)ãåå¾ãããã¨ãåºæ¥ã¾ãã
èªåã§AMIãã«ã¹ã¿ãã¤ãºããéãã¤ã³ã¹ã¿ã³ã¹ã®èµ·åæã«å²ãæ¯ããã(確å®ãã)ãã¼ã¿(ä¾ãã°ãIPã¢ãã¬ã¹ã¨ãã¤ã³ã¹ã¿ã³ã¹IDã¨ãã)ã«ã¤ãã¦ã¯ãäºåã«æ±ãã決ãããã¨ã¯é£ãããã¨æãã¾ãã
ä¾ãã°ãã¤ã³ã¹ã¿ã³ã¹IDããµã¼ãèªèº«ãå¤å¥ã§ãããã¨ã§ããµã¼ãèµ·åã®ã¿ã¤ãã³ã°ãããµã¼ã稼åä¸ã«ãAmazon EBSããªã¥ã¼ã ã(èªåã§)èªåèªèº«ã«å²ãå½ã¦ããããçãã§ããããã¾ãã
ã¾ããä½è«ã§ãããAmazon EC2ã§ã¯ãã¦ã¼ã¶ãã¤ã³ã¹ã¿ã³ã¹ã®èµ·åæã«ä»»æã®ãã¼ã¿(UserData)ãã¤ã³ã¹ã¿ã³ã¹ã«æ¸¡ããã¨ãã§ãããã®ãã¼ã¿ãã¤ã³ã¹ã¿ã³ã¹ã®ä¸ã§æ±ããã¨ãå¯è½ã§ãã
ãã®å ´åãã以ä¸ã§ç´¹ä»ããããæ¹ã§ãã¡ã¿ãã¼ã¿ã ãã§ã¯ãªããã¦ã¼ã¶ãã¼ã¿ãåæ§ã«åå¾ãããã¨ãå¯è½ã§ãã(詳ããå©ç¨æ¹æ³ã«ã¤ãã¦ã¯å¥é)
ã¡ã¿ãã¼ã¿(ã¦ã¼ã¶ãã¼ã¿)ã®åå¾
ãã¼ã¿ã®åå¾ã¯ããµã¼ãå
é¨ããWebçµç±(HTTP)ã§åå¾ãã¾ããããã¯Amazon EC2ãç¬èªã§æã¤RESTã®APIã§ããµã¼ããã"169.254.169.254"ã¸HTTPã®GETã¡ã½ããã§ã¢ã¯ã»ã¹ãããã¨ã§åå¾ã§ãã¾ãã
Amazon EC2ã®ä»®æ³ãµã¼ãã®ã³ãã³ãã©ã¤ã³ããã以ä¸ã®è¦é ã§åå¾ãã¦ã¿ã¦ãã ããã
# curl http://169.254.169.254/latest/
dynamic
meta-data
user-data
ãã®ä¸ã§ã"meta-deta"ãã¡ã¿ãã¼ã¿ã"user-data"ãã¦ã¼ã¶ãã¼ã¿ã¨ãªãã¾ãã
# curl http://169.254.169.254/latest/user-data/
ã§ãã¦ã¼ã¶ãã¤ã³ã¹ã¿ã³ã¹ã®èµ·åæã«å®ç¾©ãã(渡ãã)ãã¼ã¿ãåå¾ã§ãã¾ãã
# curl http://169.254.169.254/latest/meta-data/ ami-id ami-launch-index ami-manifest-path ancestor-ami-ids block-device-mapping/ hostname instance-action instance-id instance-type kernel-id local-hostname local-ipv4 placement/ public-hostname public-ipv4 public-keys/ ramdisk-id reservation-id
ã§ã¯ãæ¬é¡ã®ã¡ã¿ãã¼ã¿ã®æ¹ãç´¹ä»ã
åå¾ã§ãããã©ã¡ã¼ã¿ã¯ä¸è¨ã®éããããããããã¾ãã
以ä¸ã®è¦é ã§ãç¶ãã¦ãã©ã¡ã¼ã¿åãã¤ãã¦ãããã¨ã§ãä½ãããã®å¤ãåå¾ã§ãããã¨ã«ãªãã¾ããããã¤ãåå¾ã§ããå¤ãç´¹ä»ãã¾ãã
(ä¸é¨ãpublic-keysãªã©ã¯ãæå®æ¹æ³ãå°ãéãããã以ä¸ãåç
§ãã¦ä¸ããã)
# curl http://169.254.169.254/latest/meta-data/ami-id
ami-810657c4
AMIã®IDã
# curl http://169.254.169.254/latest/meta-data/instance-id i-02688446
ã¤ã³ã¹ã¿ã³ã¹ã®IDã
# curl http://169.254.169.254/latest/meta-data/instance-type
m1.small
ãµã¼ãã®ã¤ã³ã¹ã¿ã³ã¹ã¿ã¤ãã
# curl http://169.254.169.254/latest/meta-data/local-hostname ip-10-162-154-117.us-west-1.compute.internal
ãµã¼ãã®ãã¹ãå(hostbame)ã
# curl http://169.254.169.254/latest/meta-data/local-ipv4
10.162.154.117
ãµã¼ãã®ãã©ã¤ãã¼ãIPã¢ãã¬ã¹ã
# curl http://169.254.169.254/latest/meta-data/placement/availability-zone
us-west-1a
ãµã¼ãã®èµ·åãã¦ããã¾ã¼ã³å(Availability Zone)ã
# curl http://169.254.169.254/latest/meta-data/public-hostname ec2-204-236-190-25.us-west-1.compute.amazonaws.com
ãµã¼ãã®ãããªãã¯DNSãã¼ã ã
# curl http://169.254.169.254/latest/meta-data/public-ipv4
204.236.190.25
ãµã¼ãã®ãããªãã¯IPã¢ãã¬ã¹ã
# curl http://169.254.169.254/latest/meta-data/security-groups
default
ãµã¼ãã®æå±ãã¦ããã»ãã¥ãªãã£ã°ã«ã¼ãã
# curl http://169.254.169.254/latest/meta-data/block-device-mapping/ ami ephemeral0 root swap # curl http://169.254.169.254/latest/meta-data/block-device-mapping/ami sda1 # curl http://169.254.169.254/latest/meta-data/block-device-mapping/root /dev/sda1 # curl http://169.254.169.254/latest/meta-data/block-device-mapping/ephemeral0 sda2 # curl http://169.254.169.254/latest/meta-data/block-device-mapping/swap sda3
ãµã¼ãã«æ¥ç¶ããã¦ãããã£ã¹ã¯ããã¤ã¹ã
# curl http://169.254.169.254/latest/meta-data/public-keys/ 0=test_key # curl http://169.254.169.254/latest/meta-data/public-keys/0/ openssh-key # curl http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key ssh-rsa AAAAB3NzaC1yc2EAAAAD.....(çç¥)..... test_key
KeyPairsã§æå®ããããµã¼ãã«æ¥ç¶ããéã®å
¬ééµã
"0=test_key"ãªã©ã¯ã"0"ãæå®ãåå¾ãããã©ã¡ã¼ã¿ãä¸è¨ã®ããã«ãããã¦(/0/openssh-key)æå®ãã¾ãã
ã¾ã¨ã
ã¯ã©ã¦ãAMAZON EC2/S3ã®ãã¹ã¦ (ITpro BOOKs)
- ä½è : 並河ç¥è²´,å®éè¼é,ITpro/æ¥çµSYSTEMS
- åºç社/ã¡ã¼ã«ã¼: æ¥çµBP社
- çºå£²æ¥: 2009/11/05
- ã¡ãã£ã¢: åè¡æ¬
- è³¼å ¥: 4人 ã¯ãªãã¯: 372å
- ãã®ååãå«ãããã° (18件) ãè¦ã