2023년 2월 7일 화요일

맥북에 AWS 개발 환경 설정하기

 

1. 개요

2. 설치하기

  1. VPN에 상관없이 인터넷 연결만 되면 가능함
  2. Run iTerm on Mac
  3. mkdir ~/aws
  4. cd aws
  5. Install awscli : $ pip install awscli
  6. $ aws configure -> 자격 증명 넣어라고 나옴 (발급 권한 필요)

AWS Access Key ID [None]: AK당신이 AIM에서 발급 받은 키ROZ7A
AWS Secret Access Key [None]: KEY [ 잘 생각 해보세요 ]
Default region name [None]: ap-northeast-2
Default output format [None]: json

Aws cli와 anaconda 충돌 해결
  • 문제
Traceback (most recent call last):
  File "/Users/mksong.cncity/opt/anaconda3/bin/aws", line 19, in <module>
    import awscli.clidriver
  File "/Users/mksong.cncity/opt/anaconda3/lib/python3.7/site-packages/awscli/clidriver.py", line 24, in <module>
    from botocore.history import get_global_history_recorder
ModuleNotFoundError: No module named 'botocore.history'

  • 해결법
$ pip uninstall awscli
$ pip install awscli --force-reinstall --upgrade --user
$ aws configure

  • Test : $ aws s3 ls
  • Key 생성은 루트 관리자가 생성해줘야 함. 다운은 AWS Console > 내계정 > 내 보안 자격 증명에서 받을 수 있음
  • 절대로 노출하면 안됨

3. AWS SDK 로 프로그램 개발

3.1 AWS SDK 설치

3.1 AWS SDK Sample for python

import boto3

# Create an S3 client
s3 = boto3.client('s3')

# Call S3 to list current buckets
response = s3.list_buckets()

# Get a list of all bucket names from the response
buckets = [bucket['Name'] for bucket in response['Buckets']]

# Print out the bucket list
print("Bucket List: %s" % buckets)

4. AWS EC2에 접속하기

4.1 with SSH on Mac

ssh youraccount@IPaddr

라벨: , , , , ,