공식 AWS Command Line Interface (aws)를 사용하는 클라우드 인프라 관리자를 위한 핵심 명령어 퀵 레퍼런스.
설치 및 기본 구성
# macOS (Homebrew) 설치
brew install awscli
# 자격 증명 및 기본 리전 초기화
aws configure
# 이름이 지정된 프로필(Named Profile) 구성
aws configure --profile staging
aws configure --profile production
자격 증명과 설정은 ~/.aws/credentials 및 ~/.aws/config 파일에 저장됩니다.
Amazon S3 (객체 스토리지)
# 버킷 목록 또는 버킷 내용 조회
aws s3 ls
aws s3 ls s3://my-bucket-name/prefix/
# 로컬 파일을 S3로 복사 업로드
aws s3 cp document.pdf s3://my-bucket-name/docs/
# 로컬 디렉터리와 S3 버킷 동기화 (제외 옵션 포함)
aws s3 sync ./build s3://my-bucket-name/web --delete --exclude "*.tmp"
# 디렉터리 또는 프리픽스를 재귀적으로 삭제
aws s3 rm s3://my-bucket-name/temporary-files --recursive
Amazon EC2 (가상 서버)
# 실행 중인 인스턴스 정보 조회 및 테이블 출력
aws ec2 describe-instances \
--filters "Name=instance-state-name,Values=running" \
--query "Reservations[*].Instances[*].[InstanceId,PublicIpAddress,Tags[?Key=='Name'].Value|[0]]" \
--output table
# 인스턴스 시작 및 중지
aws ec2 start-instances --instance-ids i-0123456789abcdef0
aws ec2 stop-instances --instance-ids i-0123456789abcdef0
# 인스턴스 종료 및 영구 삭제
aws ec2 terminate-instances --instance-ids i-0123456789abcdef0
Amazon ECS (컨테이너 오케스트레이션)
# 클러스터 목록 조회
aws ecs list-clusters
# 신규 클러스터 생성
aws ecs create-cluster --cluster-name production-cluster
# 클러스터 내 실행 중인 태스크 목록 조회
aws ecs list-tasks --cluster production-cluster
AWS Elastic Beanstalk CLI (eb)
# Elastic Beanstalk 애플리케이션 초기화
eb init
# 환경 생성 및 애플리케이션 배포
eb create production-env
eb deploy
# 브라우저에서 실행 중인 앱 열기
eb open
# 실시간 애플리케이션 로그 확인
eb logs
유용한 공통 플래그 및 쿼리
--profile <name>: 특정 IAM 프로필 환경에서 명령 실행.--region <region>: 기본 설정된 AWS 리전 임시 재정의.--output [json|text|table]: CLI 출력 형식 지정 (json, text, table).--query '<JMESPath>': JMESPath 표현식을 사용하여 정형 데이터 필터링 및 추출.