AMI는 EC2 인스턴스의 템플릿(이미지)입니다. OS, 루트 디스크 스냅샷, 블록 디바이스 맵핑, 권한 등의 런치에 필요한 모든 메타데이터를 담고 있음
x86_64 / arm64 (예: Graviton=arm64)AMI ID는 리전 종속. 다른 리전에서 쓰려면 Copy AMI가 필요
EBS-backed (대부분)
Instance Store-backed (레거시/특수)
pending → available → (optional) deprecated → deregistered실행 중 인스턴스 → 이미지: 패치/설정 끝낸 인스턴스에서 스냅샷 만들어 골든 AMI 생성
aws ec2 create-image \
--instance-id i-0123456789abcdef0 \
--name "golden-al2023-2025-10-07" \
--description "Hardened AL2023 base" \
--no-reboot
스냅샷 → AMI 등록: register-image로 직접 등록도 가능
aws ec2 copy-image \
--source-region ap-northeast-2 \
--source-image-id ami-0abc... \
--name "golden-al2023-copy-to-us-east-1" \
--region us-east-1
암호화된 AMI는 대상 리전 KMS 키로 재암호화됨
aws ec2 modify-image-attribute \
--image-id ami-0abc... \
--launch-permission "Add=[{UserId=123456789012}]"
최신 아마존 리눅스/윈도우 AMI는 SSM Parameter Store에서 안전하게 참조
aws ssm get-parameters \
--names /aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64 \
--query 'Parameters[0].Value' --output text
런치 템플릿/IaC에서 하드코딩된 AMI ID 대신 SSM 참조를 권장
EC2 Image Builder 또는 HashiCorp Packer로
장점: 일관성, 컴플라이언스, 취약점 패치 자동화
패치 주기: 월간/주간 등 조직 정책에 맞춰 deprecate → 교체 롤아웃
# CloudFormation: LaunchTemplate에서 AMI 참조(SSM)
Parameters:
LatestAL2023Ami:
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
Default: /aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64
Resources:
LT:
Type: AWS::EC2::LaunchTemplate
Properties:
LaunchTemplateData:
ImageId: !Ref LatestAL2023Ami
InstanceType: t3.medium
BlockDeviceMappings:
- DeviceName: /dev/xvda
Ebs: { VolumeSize: 30, VolumeType: gp3 }
# AMI 조회 (내 소유)
aws ec2 describe-images --owners self --query 'Images[*].{ID:ImageId,Name:Name}'
# AMI 공유 추가/제거
aws ec2 modify-image-attribute --image-id ami-0abc... \
--launch-permission "Add=[{UserId=123456789012}]"
aws ec2 modify-image-attribute --image-id ami-0abc... \
--launch-permission "Remove=[{UserId=123456789012}]"
# AMI 비활성화(Deprecation 설정)
aws ec2 enable-image-deprecation \
--image-id ami-0abc... \
--deprecate-at 2026-01-31T00:00:00Z
# AMI 등록 해제 & 스냅샷 정리
aws ec2 deregister-image --image-id ami-0abc...
aws ec2 delete-snapshot --snapshot-id snap-0123abcd...