반응형
◇ 공부 기록용으로 작성하였으니 틀린점, 피드백 주시면 감사하겠습니다 ◇
AWS의 메타데이터(Metadata)와 유저 데이터(User Data)는 EC2 인스턴스에 주로 사용된다.
User Data (유저 데이터)
유저 데이터는 인스턴스를 처음 부팅할 때 실행할 스크립트 형식의 데이터를 뜻한다.
처음에만 실행된다.
특히 EC2에 소프트웨어 설치해야할 때 사용한다.
- AWS Console, AWS CLI, API를 통해 설정할 수 있다
- Shell Script 또는 Cloud init 형식으로 작성
- 스크립트 형식으로 16KB로 제약
User data 예시
#!/bin/bash
# 유저 데이터 스크립트 예시
# Apache 웹 서버 설치 및 시작
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httpd
# 인덱스 페이지 작성
echo "Hello, World from $(hostname -f)" > /var/www/html/index.html
Metadata (메타데이터)
Metadata는 실행 중인 EC2 인스턴스에 대한 정보를 제공하는 데이터이다.
신기하게도 metadata는 인스턴스 내부에서 HTTP 요청을 통해 알 수 있다.
접근 방법: 인스턴스 내부에서 HTTP를 통해 http://169.254.169.254/latest/meta-data/에 요청하여 접근한다.
curl http://169.254.169.254/latest/meta-data/
Metadata에 포함된 내용
- Instance ID: The unique ID of the instance.
- AMI ID: The ID of the Amazon Machine Image (AMI) from which the instance was created.
- Host Name: The internal and external host names of the instance.
- Instance Type: The type of the instance (e.g., t2.micro).
- Security Groups: The security groups applied to the instance.
- IAM Role: Information about the IAM role assigned to the instance.
- Network Interfaces: Information related to the instance's network interfaces (e.g., MAC address, IP address).
Metadata 예시
참고자료: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
Instance metadata and user data - Amazon Elastic Compute Cloud
Although you can only access instance metadata and user data from within the instance itself, the data is not protected by authentication or cryptographic methods. Anyone who has direct access to the instance, and potentially any software running on the in
docs.aws.amazon.com
반응형