AWS EC2 Instance Metadata

  • κ°œλ°œμžλ“€μ—κ²Œ 아직 잘 μ•Œλ €μ§€μ§€λŠ” μ•Šμ•˜μ§€λ§Œ, 맀우 κ°•λ ₯ν•˜λ©° 쒋은 κΈ°λŠ₯이닀.
  • 이 κΈ°λŠ₯은 EC2 μΈμŠ€ν„΄μŠ€κ°€ 슀슀둜 ν•™μŠ΅ν•˜λ„λ‘ ν•΄μ„œ κ·Έ λͺ©μ μœΌλ‘œ IAM 역할이 ν•„μš”ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.
  • URL 은 http://169.254.169.254/latest/meta-data 이닀.
    • ν•΄λ‹Ή μ•„μ΄ν”ΌλŠ” AWS의 λ‚΄λΆ€ IP둜 λ‚΄μ»΄ν“¨ν„°μ—μ„œλŠ” μ ‘μ†μ΄μ•ˆλ˜κ³ , EC2 μΈμŠ€ν„΄μŠ€μ—μ„œλ§Œ μ‹€ν–‰λ©λ‹ˆλ‹€.
  • λ©”νƒ€λ°μ΄ν„°λ‘œλΆ€ν„° IAM Role 을 κ²€μƒ‰ν• μˆ˜λŠ” μžˆμ§€λ§Œ, IAM policy λŠ” 검색할 수 μ—†λ‹€.
  • Metadata = EC2 μΈμŠ€ν„΄μŠ€μ— κ΄€ν•œ 정보
  • Userdata = EC2 μΈμŠ€ν„΄μŠ€κ°€ μ‹œμž‘ν• λ•Œμ˜ launch script 이닀.
[ec2-user@ip-192.xxx.xxx.xxx]$ curl http://169.254.169.254
# 1.0
# 2007-01-19
# 2007-03-01
# ...
# 2018-03-28
# latest
[ec2-user@ip-192.xxx.xxx.xxx]$ curl http://169.254.169.254/latest/
# dynamic
# meta-data
# user-data
[ec2-user@ip-192.xxx.xxx.xxx]$ curl http://169.254.169.254/latest/meta-data/
# ami-id
# ami-launch-index
# ami-manifest-path
# hostname
# iam/
# instance-id
# ...
# security-groups
# services
[ec2-user@ip-192.xxx.xxx.xxx]$ curl http://169.254.169.254/latest/meta-data/instance-id
# i-05adcce6993809eda
[ec2-user@ip-192.xxx.xxx.xxx]$ curl http://169.254.169.254/latest/meta-data/local-ipv4
# 172.31.3.136

μœ„μ˜ μ½”λ“œμ—μ„œ λ³Ό 수 μžˆλ“―μ΄, EC2 μΈμŠ€ν„΄μŠ€ 내에 직접 μ ‘μ†ν•΄μ„œ http://169.254.169.254/latest/meta-data 둜 curl μš”μ²­μ„ 보내면 ν•΄λ‹Ή EC2 μΈμŠ€ν„΄μŠ€μ˜ λ‹€μ–‘ν•œ 섀정듀을 κ°€μ Έμ˜¬ 수 있고, 이것을 기반으둜 λ§Žμ€ 것듀을 μžλ™ν™” ν•  수 있게 λœλ‹€.

λŒ“κΈ€λ‚¨κΈ°κΈ°