inblog logo
|
silver
    AWS

    [AWS] CLI

    silver's avatar
    silver
    Nov 12, 2025
    [AWS] CLI
    Contents
    AWS CLI 설치 및 설정주요 AWS CLI 명령어프로필을 활용한 다중 계정 관리

    AWS CLI 설치 및 설정

    CLI 설치

    AWS CLI는 명령줄에서 AWS 서비스를 제어할 수 있는 도구
    Windows:
    msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi
    macOS:
    brew install awscli
    Linux:
    curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install

    CLI 구성

    aws configure
    입력 항목:
    • AWS Access Key ID
    • AWS Secret Access Key
    • Default region name (예: ap-northeast-2)
    • Default output format (json, yaml, text 중 선택)

    자격 증명 발급

    1. AWS 콘솔 로그인
    1. IAM 서비스 이동
    1. 사용자 → 보안 자격 증명 탭
    1. 액세스 키 만들기
    1. 키 ID와 비밀 키를 안전하게 저장
    ⚠️ 비밀 액세스 키는 생성 시 한 번만 표시되므로 꼭 저장!!

    주요 AWS CLI 명령어

    S3 관련

    # 버킷 목록 조회 aws s3 ls # 파일 업로드 aws s3 cp local-file.txt s3://my-bucket/ # 파일 다운로드 aws s3 cp s3://my-bucket/file.txt ./ # 버킷 동기화 aws s3 sync ./local-folder s3://my-bucket/

    EC2 관련

    # 인스턴스 목록 조회 aws ec2 describe-instances # 인스턴스 시작 aws ec2 start-instances --instance-ids i-1234567890abcdef0 # 인스턴스 중지 aws ec2 stop-instances --instance-ids i-1234567890abcdef0

    IAM 관련

    # 사용자 목록 조회 aws iam list-users # 정책 목록 조회 aws iam list-policies # 사용자에게 정책 연결 aws iam attach-user-policy --user-name MyUser --policy-arn arn:aws:iam::aws:policy/ReadOnlyAccess

    프로필을 활용한 다중 계정 관리

    여러 AWS 계정을 사용하면 프로필 사용하는 것이 좋다!
    # 프로필 설정 aws configure --profile company-dev aws configure --profile company-prod # 프로필 사용 aws s3 ls --profile company-dev aws ec2 describe-instances --profile company-prod
    ~/.aws/config 파일에서 프로필을 확인 가능:
    [profile company-dev] region = ap-northeast-2 output = json [profile company-prod] region = us-east-1 output = json
    Share article
    Contents
    AWS CLI 설치 및 설정주요 AWS CLI 명령어프로필을 활용한 다중 계정 관리

    silver

    RSS·Powered by Inblog