aws-vault 설정

김신영·2023년 5월 22일
0

AWS Discovery Book

목록 보기
10/10
post-thumbnail

1. AWS Vault 설치

brew install --cask aws-vault

# 기존에 awsudo를 사용한 경우, 기존 설정과 인증서 삭제
rm ~/.aws/config ~/.aws/credentials

2. IAM → Access Key 생성

  • Acesss Key
  • Secret Key

3. AWS Vault에 Crendential 등록

$ aws-vault add ${AWS_PROFILE}
Enter Access Key Id: ...
Enter Secret Key: ...

4. KeyChain 파일 세션 유효시간 변경

  1. Finder 열기
  2. Shift + Cmd + G (Go to Folder 창 띄우기)
  3. /Users/유저이름/Library/Keychains 입력 후 Enter
  4. aws-vault.keychain-db 키체인 파일 더블 클릭
  5. 좌측에 aws-vault 메뉴 우클릭
  6. Change Settings for Keychain “aws-vault”… 클릭

  1. 600 입력하고 저장 (600분 = 10시간)

5. Config 파일 설정

cat <<EOF >> ~/.aws/config
[default]
region=ap-northeast-2
output=table

[profile rolroralra]
region=ap-northeast-2
output=table
mfa_serial=arn:aws:iam::xxxxxxxxxxxx:mfa/rolroralra
credential_process = aws-vault exec --json --prompt=osascript rolroralra
source_profile = rolroralra
EOF

6. 환경 변수 설정 (.bashrc, .bash_profile, .zshrc)

cat <<EOF >> ~/.zshrc
# AWS
export AWS_PROFILE=rolroralra
export AWS_SESSION_TOKEN_TTL=10h

eval "$(aws-vault --completion-script-zsh)"
EOF

7. 확인

$ aws-vault exec rolroralra -- aws s3 ls

$ aws s3 ls
profile
Hello velog!

0개의 댓글