2023년 3월 31일 금요일

[2023-03-31] aws cli 업데이트가 필요 합니다.

[2023-03-31] aws cli 업데이트가 필요 합니다.


안녕하세요. 클스 입니다.


aws cli를 v1 설치하고 v2로 업데이트를 하였습니다. 한 1년전인 것 같습니다. python 3.9.11 을 설치하고 

v2를 설치했었습니다.  당연히 python 을 업데이트 하면 자동으로 aws cli 가 최신 파이썬을 물고 동작할 줄 알았는데 그렇지가 않네요


pyenv와 virtual env로 py3.11.2 를 만들고

$ aws --version 을 해보시면 python 3.9.11 에서 돌고 있다. 이렇게 표시됩니다.

그래서 다시 설치했더니 python 3.11.2 로 변경됐습니다. 아래는 최신 aws cli 설치 방법 입니다.

https://docs.aws.amazon.com/ko_kr/cli/latest/userguide/getting-started-install.html

참고하셔서 본인 환경에 맞게 설치하시면 됩니다,

(py3.11.2) [~/data/s3]$ aws --version

aws-cli/2.11.7 Python/3.11.2 Darwin/22.4.0 exe/x86_64 prompt/off

이제 최신 버전으로 표시되네요~


이상 클스 였습니다.



라벨: , , ,

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

라벨: , , , , ,