| No. | Category | Service | Descriptions | Library | Position |
|---|---|---|---|---|---|
| 001. | EDA, AI | 없음 | AWS 서비스가 사용되지는 않았지만 Jupyter notebook과 colab을 사용하여 개발하였다. | NumPy, Pandas, SciPy, Matplotlib, Seaborn, Keras, TensorFlow, Prophet ... | Data Analysis, Machine Learning, Deep Learning |
| 002. | Database | Database AWS RDS Storage 자체 Storage |
관계형 데이터베이스 서비스 Relational Database Service |
MySQL, mysql-connector-python, psycopg2-binary ... | Database Management |
| 003. | Client | Cloud Computing AWS EC2 Storage AWS EBS |
AWS EC2 생성 시 AWS EBS 스토리지 용량 설정 | Streamlit, pillow ... | Front-end |
| 004. | Server / API | Security, Identity, & Compliance AWS IAM Cloud Computing AWS Lambda Storage AWS S3 |
AWS IAM 사용자 생성 후 serverless로 AWS Lambda에 배포하면 AWS S3에 버킷이 자동으로 생성된다. | Flask, Flask-JWT-Extended, Flask-Restful, Passlib, Email-validator ... | Back-end |
- vscode
- jutyper notebook
- colab
- mysql workbench
- postman
- github desktop
- putty
- numpy
- scipy
- pandas
- matplotlib
- seaborn
- sklearn
- keras
- tensorflow
- prophet
- streamlit
- pillow
- mysql-connector-python
- flask
- flask_jwt_extended
- flask_restfull
- psycopg2-binary
- passlib
- email-validator
- RDS
- EC2
- IAM
- Lambda
- S3
▶ 참고자료
https://rudtjr0906.tistory.com/category/AWS
▶ 먼저 홈페이지에서 NodeJS 설치하기
https://nodejs.org/en
▶ IAM 서비스에서 사용자 생성을 해야한다.
- Amazon API Gateway
- Amazon RDS Data
- CloudFront
- IAM (Identity and Access Management)
- CloudWatch
- Amazon S3 (Simple Storage Service)
- AWS CloudFormation
- AWS Lambda
▶ 사용자 생성을 완료했다면 api_dev_accessKeys.csv파일을 다운로드 받는다.
▶ Windows CMD를 켜고 serverless를 설치한 후 설정해준다.
cd C:\Users\406\Documents\GitHub
npm install -g serverless
serverless
serverless config credentials --provider aws --key AKIA6GBMCQLLOXBH474Y --secret 9Ge17YfsBServerless ϟ Framework
√ Select A Template: · AWS / Python / Flask API
√ Name Your Service: · aws-flask-server
√ Create Or Select An Existing App: · Create A New App
√ Name Your New App: · flask-app
√ AWS Credentials Set-Up Method: · Save AWS Credentials in a Local Profile
√ Enter AWS Access Key ID: · AKIA6GBMCQLLOXBH474Y
√ Enter AWS Secret Access Key: · 9Ge17YfsBEZDXrDM9GnPXiEIyzt3uuaQr5VYxrMa▶ 이후 웹 브라우저에서 대시보드가 열린다.
▶ 구글로 로그인
https://app.serverless.com/popcorn0508/apps
▶ 그리고 C:\Users\406\Documents\GitHub에 프로젝트가 생성된다.
▶ 이후 생성된 프로젝트를 vscode에서 open folder한 후에 cmd에서 serverless deploy 또는 sls deploy 명령어를 입력해준다.
▶ 참고로 여기에서 sls는 serverless의 약자이다.
▶ serverless-wsgi 플러그인이 설치되지 않았다는 에러가 발생했을 경우
npm install serverless-wsgi▶ 이후에 serverless.yml 파일에서 이렇게 되어있으면 설치가 잘 된것이다.
plugins:
- serverless-wsgi▶ 만약 EMFILE: too many open files 에러가 발생했을 경우에는 serverless.yml 파일에서 아래의 코드를 맨 밑에 추가해주면 된다.
package:
individually: true
exclude:
- node_modules/** # node_modules 폴더와 그 하위 모든 파일 및 디렉토리 제외
- .git/** # .git 폴더와 그 하위 모든 파일 및 디렉토리 제외
- tests/** # tests 폴더와 그 하위 모든 파일 및 디렉토리 제외
include:
- src/** # src 폴더와 그 하위 모든 파일 및 디렉토리 포함
- handler.py # 루트 디렉토리의 handler.py 파일 포함
- config/** # config 폴더와 그 하위 모든 파일 및 디렉토리 포함▶ 이제 기존에 개발했던 로컬 API 프로젝트 파일들을 serverless프로젝트로 옮겨주고
▶ AWS lambda 서비스 환경에 맞게 환경설정을 해주어야 한다.
▶ serverless.yml에서 provider: 부분 수정
( 참고로 AWS 런타임 환경을 python3.10버전으로, 리전은 아시아 태평양(서울)인 ap-northeast-2로 설정한다는 뜻이다. )
provider:
name: aws
runtime: python3.10
region: ap-northeast-2▶ requirements.txt에서 아래의 코드를 맨 밑에 추가
( 참고로 배포 시 사용할 라이브러리를 설치한다는 뜻이다. )
flask-restful
mysql-connector-python
psycopg-binary
passlib
flask-jwt-extended
email-validator▶ 그리고 serverless deploy명령어로 배포를 하면 잘 된다.
serverless deploy( 참고로 serverless remove명령어는 배포된 프로젝트를 제거하는 명령어이다. )
serverless remove▶ 배포가 완료되었다는 로그
✔ Service deployed to stack aws-flask-server-dev (105s)▶ 마지막으로 endpoints의 url로 API를 사용하면 된다.
endpoints:
ANY - https://bycew609a0.execute-api.us-east-1.amazonaws.com/dev/
ANY - https://bycew609a0.execute-api.us-east-1.amazonaws.com/dev/{proxy+}
functions:
api: aws-flask-server-dev-api (1.5 MB)▶ 배포된 프로젝트는 AWS Lambda 서비스에서 확인할 수 있다.
▶ 마찬가지로 AWS S3 서비스에 버킷이 자동으로 생성된다.
▶ 참고자료
https://rudtjr0906.tistory.com/50
▶ 참고자료
https://sohyun-lee.tistory.com/entry/%E3%85%8F?category=1063559