- VPC 생성
- IGW / NAT 생성
- VPC와 IGW 연결
- 서브넷 생성
- 라우팅 테이블 생성
- 기본경로 설정 - 게이트웨이 설정
- 서브넷 연결
- 보안 그룹 생성
- 대상 그룹 생성
- 로드밸런서 생성
- 가용영역 - 퍼블릭 선택
- 시작 템플릿 생성
- 토큰 V1 및 V2 선택
- 미선택 시 인스턴스 ID 할당 불
- 오토 스케일링 생성
- 가용영역 프라이빗 선택
- 데이터베이스 생성
- 가용영역 마스터 설치할 서브넷만 선택
- DB 서브넷 그룹 생성
- 가용영역 서브넷 추가 - 공유할 서브넷 모두 선택


nslookup my-alb-1974955271.ap-northeast-2.elb.amazonaws.com
Non-authoritative answer:
Name: my-alb-1974955271.ap-northeast-2.elb.amazonaws.com
Address: 43.200.26.28
Name: my-alb-1974955271.ap-northeast-2.elb.amazonaws.com
Address: 43.200.233.196
dig +short my-alb-1974955271.ap-northeast-2.elb.amazonaws.com
43.200.233.196
해당 IP로 ping or curl 확인
로드밸런서 생성 - 가용영역 - 모두 퍼블릭으로 변경
보안그룹 - 모든 트래픽에서 - 특정 트래픽으로 변경
#!/bin/bash
# EC2 인스턴스 ID 가져오기
export INSTANCE_ID=$(curl -s <http://169.254.169.254/latest/meta-data/instance-id>)
# 루트 비밀번호 설정 (Amazon Linux 2023에서는 chpasswd 사용)
echo "root:aws1234!" | chpasswd
# SSH 설정 변경
sed -i 's/^PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
sed -i 's/^#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
sed -i 's/^#PermitRootLogin no/PermitRootLogin yes/' /etc/ssh/sshd_config
systemctl restart sshd
# Apache 설치
dnf -y install httpd
# index.html에 인스턴스 ID 출력
echo "<h1>${INSTANCE_ID} (AUTO SCALING) Welcome to AWS WEB Server</h1>" > /var/www/html/index.html
# Apache 실행 및 부팅 시 자동 실행
systemctl enable httpd
systemctl start httpd


인스턴스 ID 할당 불가 시 확인 사항
1. 시작 탬플릿 - V1,V2 토큰 선택
# 토큰 요청
token=$(curl -X PUT -H "X-aws-ec2-metadata-token-ttl-seconds: 21600" \\
<http://169.254.169.254/latest/api/token>)
# 인스턴스 ID 요청
curl -H "X-aws-ec2-metadata-token: $token" \\
<http://169.254.169.254/latest/meta-data/instance-id>
- 데이터베이스
- 마스터 2a
- 읽기 추가로 가용영역 2c 추가
'IT 엔지니어 > CLOUD' 카테고리의 다른 글
AWS - CloudFormation (0) | 2025.06.10 |
---|---|
AWS - Auto Scaling Group (1) | 2025.06.09 |
AWS - RDS (0) | 2025.06.08 |
AWS - Public INSTANCE (2) | 2025.06.07 |
AWS - IAM / S3 / VPC (3) | 2025.06.06 |