콘텐츠로 이동

AWS CLI

명령어설명
aws configureAWS 자격 증명 및 리전 구성
aws configure list현재 구성 표시
aws configure set region us-west-2기본 지역 설정
aws configure set output json출력 형식 설정
aws sts get-caller-identity현재 신원 확인
aws configure list-profiles구성된 모든 프로필 나열
aws configure --profile myprofile명명된 프로필 구성하기
명령어설명
aws ec2 describe-instances모든 인스턴스 나열
aws ec2 run-instances --image-id ami-12345 --instance-type t2.micro인스턴스 시작
aws ec2 start-instances --instance-ids i-1234567890abcdef0인스턴스 시작
aws ec2 stop-instances --instance-ids i-1234567890abcdef0인스턴스 중지
aws ec2 terminate-instances --instance-ids i-1234567890abcdef0인스턴스 종료
aws ec2 reboot-instances --instance-ids i-1234567890abcdef0인스턴스 재부팅
명령어설명
aws ec2 describe-security-groups보안 그룹 나열
aws ec2 create-security-group --group-name MySecurityGroup --description "My security group"보안 그룹 생성
aws ec2 authorize-security-group-ingress --group-id sg-12345 --protocol tcp --port 80 --cidr 0.0.0.0/0인바운드 규칙 추가
aws ec2 revoke-security-group-ingress --group-id sg-12345 --protocol tcp --port 80 --cidr 0.0.0.0/0인바운드 규칙 제거
명령어설명
aws ec2 describe-key-pairs키 페어 나열하기
aws ec2 create-key-pair --key-name MyKeyPair --query 'KeyMaterial' --output text > MyKeyPair.pem키 페어 생성
aws ec2 delete-key-pair --key-name MyKeyPair키 페어 삭제
명령어설명
aws s3 ls모든 버킷 나열
aws s3 mb s3://my-bucket버킷 생성
aws s3 rb s3://my-bucket빈 버킷 제거
aws s3 rb s3://my-bucket --force버킷과 모든 내용 제거
aws s3 ls s3://my-bucket버킷의 객체 나열
aws s3 ls s3://my-bucket --recursive재귀적으로 모든 객체 나열하기
명령어설명
aws s3 cp file.txt s3://my-bucket/파일 업로드
aws s3 cp s3://my-bucket/file.txt .파일 다운로드
aws s3 sync ./local-folder s3://my-bucket/로컬 폴더를 S3에 동기화
aws s3 sync s3://my-bucket/ ./local-folderS3를 로컬 폴더와 동기화
aws s3 rm s3://my-bucket/file.txt파일 삭제
aws s3 rm s3://my-bucket/ --recursive버킷의 모든 파일 삭제
명령어설명
aws s3api get-bucket-versioning --bucket my-bucket버전 상태 확인
aws s3api put-bucket-versioning --bucket my-bucket --versioning-configuration Status=Enabled버전 관리 활성화
aws s3api get-bucket-encryption --bucket my-bucket암호화 확인
aws s3api put-bucket-encryption --bucket my-bucket --server-side-encryption-configuration file://encryption.json암호화 활성화
명령어설명
aws lambda list-functions모든 함수 나열하기
aws lambda create-function --function-name my-function --runtime python3.9 --role arn:aws:iam::123456789012:role/lambda-role --handler lambda_function.lambda_handler --zip-file fileb://function.zip함수 생성하기
aws lambda update-function-code --function-name my-function --zip-file fileb://function.zip함수 코드 업데이트
aws lambda invoke --function-name my-function output.txt함수 호출
aws lambda delete-function --function-name my-function삭제 함수
명령어설명
aws lambda get-function --function-name my-function함수 세부 정보 가져오기
aws lambda update-function-configuration --function-name my-function --timeout 30시간 초과 업데이트
aws lambda update-function-configuration --function-name my-function --memory-size 256메모리 업데이트
aws lambda put-function-event-invoke-config --function-name my-function --maximum-retry-attempts 1재시도 구성
명령어설명
aws iam list-users모든 사용자 나열
aws iam create-user --user-name myuser사용자 생성
aws iam delete-user --user-name myuser사용자 삭제
aws iam get-user --user-name myuser사용자 세부 정보 가져오기
aws iam create-access-key --user-name myuser액세스 키 생성
aws iam delete-access-key --user-name myuser --access-key-id AKIAIOSFODNN7EXAMPLE액세스 키 삭제
명령어설명
aws iam list-roles모든 역할 나열하기
aws iam create-role --role-name MyRole --assume-role-policy-document file://trust-policy.json역할 생성
aws iam attach-role-policy --role-name MyRole --policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess역할에 정책 연결
aws iam detach-role-policy --role-name MyRole --policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess역할에서 정책 분리
명령어설명
aws iam list-policies모든 정책 나열하기
aws iam create-policy --policy-name MyPolicy --policy-document file://policy.json정책 생성
aws iam delete-policy --policy-arn arn:aws:iam::123456789012:policy/MyPolicy삭제 정책
aws iam get-policy --policy-arn arn:aws:iam::123456789012:policy/MyPolicy정책 세부 정보 가져오기
명령어설명
aws cloudformation list-stacks모든 스택 나열하기
aws cloudformation create-stack --stack-name my-stack --template-body file://template.yaml스택 생성
aws cloudformation update-stack --stack-name my-stack --template-body file://template.yaml스택 업데이트
aws cloudformation delete-stack --stack-name my-stack스택 삭제
aws cloudformation describe-stacks --stack-name my-stack스택 세부 정보 가져오기
aws cloudformation describe-stack-events --stack-name my-stack스택 이벤트 가져오기
명령어설명
aws cloudformation validate-template --template-body file://template.yaml템플릿 유효성 검사
aws cloudformation estimate-template-cost --template-body file://template.yaml비용 추정
aws cloudformation get-template --stack-name my-stack스택 템플릿 가져오기
명령어설명
aws rds describe-db-instances모든 DB 인스턴스 나열
aws rds create-db-instance --db-instance-identifier mydb --db-instance-class db.t3.micro --engine mysql --master-username admin --master-user-password mypassword --allocated-storage 20DB 인스턴스 생성
aws rds start-db-instance --db-instance-identifier mydbDB 인스턴스 시작
aws rds stop-db-instance --db-instance-identifier mydbDB 인스턴스 중지
aws rds delete-db-instance --db-instance-identifier mydb --skip-final-snapshotDB 인스턴스 삭제
명령어설명
aws rds describe-db-snapshots모든 스냅샷 나열하기
aws rds create-db-snapshot --db-instance-identifier mydb --db-snapshot-identifier mydb-snapshot스냅샷 생성
aws rds restore-db-instance-from-db-snapshot --db-instance-identifier mydb-restored --db-snapshot-identifier mydb-snapshot스냅샷에서 복원
aws rds delete-db-snapshot --db-snapshot-identifier mydb-snapshot스냅샷 삭제
명령어설명
aws ec2 describe-vpcs모든 VPC 나열
aws ec2 create-vpc --cidr-block 10.0.0.0/16VPC 생성
aws ec2 delete-vpc --vpc-id vpc-12345678VPC 삭제
aws ec2 describe-subnets모든 서브넷 나열
aws ec2 create-subnet --vpc-id vpc-12345678 --cidr-block 10.0.1.0/24서브넷 생성
명령어설명
aws ec2 describe-route-tables라우트 테이블 목록
aws ec2 create-route-table --vpc-id vpc-12345678라우트 테이블 생성
aws ec2 create-route --route-table-id rtb-12345678 --destination-cidr-block 0.0.0.0/0 --gateway-id igw-12345678라우트 추가
aws ec2 associate-route-table --subnet-id subnet-12345678 --route-table-id rtb-12345678연결된 라우트 테이블
명령어설명
aws cloudwatch list-metrics모든 메트릭 나열하기
aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name CPUUtilization --dimensions Name=InstanceId,Value=i-1234567890abcdef0 --statistics Average --start-time 2023-01-01T00:00:00Z --end-time 2023-01-02T00:00:00Z --period 3600메트릭 통계 가져오기
aws cloudwatch describe-alarms모든 알람 나열하기
aws cloudwatch put-metric-alarm --alarm-name cpu-mon --alarm-description "Alarm when CPU exceeds 70%" --metric-name CPUUtilization --namespace AWS/EC2 --statistic Average --period 300 --threshold 70.0 --comparison-operator GreaterThanThreshold알람 생성

로그

명령어설명
aws logs describe-log-groups로그 그룹 나열
aws logs create-log-group --log-group-name my-log-group로그 그룹 생성
aws logs describe-log-streams --log-group-name my-log-group로그 스트림 목록
aws logs get-log-events --log-group-name my-log-group --log-stream-name my-log-stream로그 이벤트 가져오기

모범 사례

보안