DataEngineer 03 - AWS 기초

Amazon Cloud

Service 개요

Compute

  • EC2
    • Service > Compute > EC2
    • 가상 클라우드 서버
  • Lambda : Serverless

Storage

  • S3 : 데이터 저장

Database

  • RDS : MySQL, Postgre 등
  • DynamoDB : NoSQL
  • Amazon RedShift

Networking & Content Delivery

  • API Gateway : 우리의 API를 만들 예정

Management & Governance

  • CloudWatch : 다양한 로그를 통해 에러 해결, 퍼포먼스 모니터링 등에 사용

Analytics

  • Athena : Presto 기반의 서비스로 우리가 사용할 예정
  • Kinesis : 데이터를 프로세싱
  • Data Pipeline
  • AWS Glue

Security, Identity, & Compliance

  • IAM
    • User, Permission 관리 서비스
    • 웹에 접속하지 않고 로컬에서 Console과 통신

IAM

Identity and Access Management

Image
User, Group, Role 등 관리

Add User

Image

  • User name
  • Access type
    • Programmatic access [✔] → CLI 사용을 위해 선택
      Enables an access key ID and secret access key for the AWS API, CLI, SDK, and other development tools.
    • AWS Management Console access
      Enables a password that allows users to sign-in to the AWS Management Console.

Set permissions

Image Image

  • Add user to group : User를 그룹으로 관리 가능. 지금은 그룹없이 진행
  • Copy permissions from existing user : 기존 유저의 권한 설정을 복사해서 권한 부여 eg. full permissions
  • Attach existing policies directly : 부여할 권한 선택
    • AdministratorAcess [✔] : 전체 권한을 갖도록 설정

Add tags (Optional)

Image

  • 지금은 패스

User review

Image Image

Success
You successfully created the users shown below. You can view and download user security credentials. You can also email users instructions for signing in to the AWS Management Console. This is the last time these credentials will be available to download. However, you can create new credentials at any time. Users with AWS Management Console access can sign-in at: https://950825810068.signin.aws.amazon.com/console

AWS Command Line Interface (CLI)

AWS CLI 설치

Image
Amazon CLI Install

CHECK
AWS CLI는 두 가지 버전으로 제공됩니다.

  • 버전 1.x – 일반적으로 사용 가능한 AWS CLI 버전이며 프로덕션 환경에서 사용하기에 더 적합합니다.
  • 버전 2.x – 테스트 및 평가용으로 사용되는 AWS CLI의 미리 보기 버전입니다. 이 버전에는 스크립트가 예상대로 계속 작동하도록 스크립트를 변경해야 할 수 있는 “주요” 변경 사항이 포함되어 있습니다. 버전 2의 새로운 기능 및 주요 변경 사항 목록은 호환성에 영향을 미치는 변경 – AWS CLI 버전 1에서 버전 2로 마이그레이션 단원을 참조하십시오.

⇒ 강의에 나온대로 버전 1로 진행

사전 준비

  • Python 2.7, Python 3.4 또는 이후 버전 필수 (이전 버전의 파인썬 지원 중단 2020.01.10)
    $ python --version
    Python 3.7.4
    
  • pip3 설치 확인 : Python 3.7 설치 시 자동 설치된다고 함
    $ pip3 --version
    pip 19.0.3 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
    
  • 번들 설치 관리자는 공백을 포함하는 경로에 설치하는 것을 미지원 → 공백이 없도록 경로 정리할 것!

설치하기

  • 번들 설치 관리자를 사용 / pip를 사용 설치 방법 중 선택

PIP로 설치

REF pip를 사용하여 macOS에 AWS CLI 버전 1 설치

$ pip3 install awscli --upgrade --user

PIP 설치 오류

REF
pip SSL 관련 오류 해결 방법
openssl 재설치

  • 오류
    $ pip3 install awscli --upgrade --user
    ...
    Could not fetch URL https://pypi.org/simple/awscli/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/awscli/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
    Could not find a version that satisfies the requirement awscli (from versions: )
    No matching distribution found for awscli
    pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
    
  • 해결 시도

    REF SSL: CERTIFICATE_VERIFY_FAILED with Python 3.6.0

    • ssl 재설치 시도했으나 해결되지 않았다
      $ brew install openssl
      
    • 결국 이렇게 설치에 성공하는 듯 했으나 aws가 실제로 설치가 되지 않아 not found command란다
      $ pip --trusted-host pypi.org install awscli --upgrade --user
      Collecting awscli
      Downloading https://files.pythonhosted.org/packages/3f/32/2914f9bdd89429db51050760698af77021ba3bd52261fe8714de628c3691/awscli-1.18.5-py2.py3-none-any.whl (2.9MB)
       |████████████████████████████████| 2.9MB 577kB/s 
      Collecting rsa<=3.5.0,>=3.1.2 (from awscli)
      Downloading https://files.pythonhosted.org/packages/e1/ae/baedc9cb175552e95f3395c43055a6a5e125ae4d48a1d7a924baca83e92e/rsa-3.4.2-py2.py3-none-any.whl (46kB)
       |████████████████████████████████| 51kB 7.5MB/s 
      Requirement already satisfied, skipping upgrade: colorama<0.4.4,>=0.2.5; python_version != "3.4" in /opt/anaconda3/lib/python3.7/site-packages (from awscli) (0.4.1)
      Collecting botocore==1.15.5 (from awscli)
      Downloading https://files.pythonhosted.org/packages/40/2b/f290e79241a6b07ab955a65d0395128bb300711ef37589a01696de1c5b5f/botocore-1.15.5-py2.py3-none-any.whl (5.9MB)
       |████████████████████████████████| 5.9MB 384kB/s 
      Requirement already satisfied, skipping upgrade: PyYAML<5.3,>=3.10 in /opt/anaconda3/lib/python3.7/site-packages (from awscli) (5.1.2)
      Requirement already satisfied, skipping upgrade: docutils<0.16,>=0.10 in /opt/anaconda3/lib/python3.7/site-packages (from awscli) (0.15.2)
      Collecting s3transfer<0.4.0,>=0.3.0 (from awscli)
      Downloading https://files.pythonhosted.org/packages/69/79/e6afb3d8b0b4e96cefbdc690f741d7dd24547ff1f94240c997a26fa908d3/s3transfer-0.3.3-py2.py3-none-any.whl (69kB)
       |████████████████████████████████| 71kB 495kB/s 
      Collecting pyasn1>=0.1.3 (from rsa<=3.5.0,>=3.1.2->awscli)
      Downloading https://files.pythonhosted.org/packages/62/1e/a94a8d635fa3ce4cfc7f506003548d0a2447ae76fd5ca53932970fe3053f/pyasn1-0.4.8-py2.py3-none-any.whl (77kB)
       |████████████████████████████████| 81kB 290kB/s 
      Requirement already satisfied, skipping upgrade: urllib3<1.26,>=1.20; python_version != "3.4" in /opt/anaconda3/lib/python3.7/site-packages (from botocore==1.15.5->awscli) (1.24.2)
      Collecting jmespath<1.0.0,>=0.7.1 (from botocore==1.15.5->awscli)
      Downloading https://files.pythonhosted.org/packages/83/94/7179c3832a6d45b266ddb2aac329e101367fbdb11f425f13771d27f225bb/jmespath-0.9.4-py2.py3-none-any.whl
      Requirement already satisfied, skipping upgrade: python-dateutil<3.0.0,>=2.1 in /opt/anaconda3/lib/python3.7/site-packages (from botocore==1.15.5->awscli) (2.8.0)
      Requirement already satisfied, skipping upgrade: six>=1.5 in /opt/anaconda3/lib/python3.7/site-packages (from python-dateutil<3.0.0,>=2.1->botocore==1.15.5->awscli) (1.12.0)
      Installing collected packages: pyasn1, rsa, jmespath, botocore, s3transfer, awscli
      WARNING: The scripts pyrsa-decrypt, pyrsa-decrypt-bigfile, pyrsa-encrypt, pyrsa-encrypt-bigfile, pyrsa-keygen, pyrsa-priv2pub, pyrsa-sign and pyrsa-verify are installed in '/Users/minky/.local/bin' which is not on PATH.
      Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
      Successfully installed awscli-1.18.5 botocore-1.15.5 jmespath-0.9.4 pyasn1-0.4.8 rsa-3.4.2 s3transfer-0.3.3
      
  • macOS 명령줄 경로에 AWS CLI 버전 1 실행 파일 추가
$ which python
/opt/anaconda3/bin/python

$ ls -al /opt/anaconda3/bin/python
lrwxr-xr-x  1 minky  wheel  9  1 19 14:48 /opt/anaconda3/bin/python -> python3.7

homebrew로 설치 성공

AWS CLI on MacOS

brew install awscli

AWS CLI 설정

REF AWS CLI 구성 > 빠르게 AWS CLI 구성

  • Key ID, Secret access key : AWS IAM에서 생성한 유저의 정보를 입력
    • 기존 키값 분실 시 Users > 해당 유저 > Security credentials > create access key로 다시 생성 가능
  • Default region name : 데이터 센터 지역 eg. ap-northeast-2(Seoul)
  • Default output format : (Null → 그냥 엔터키 입력)
$ aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]: json

REF
패스트캠퍼스 - 데이터 엔지니어 강의 / 한승수 강사