diff --git a/.gitignore b/.gitignore index 9747da3..58723c3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ *.d.ts node_modules package-lock.json -.env +*.env backup.env .ipynb_checkpoints SimpleServer.ipynb diff --git a/api/deploy.sh b/api/deploy.sh new file mode 100644 index 0000000..cc4bc5e --- /dev/null +++ b/api/deploy.sh @@ -0,0 +1,5 @@ +sam package --s3-bucket scratch-cheetsheet-deployment --debug +sam deploy --stack-name sam-app \ + --parameter-overrides LayerArn=$LAMBDA_LAYER \ + --s3-prefix deploy --s3-bucket scratch-cheetsheet-deployment --debug \ + --region $AWS_DEFAULT_REGION --capabilities CAPABILITY_IAM diff --git a/api/template.yaml b/api/template.yaml index b37b274..94b58b8 100644 --- a/api/template.yaml +++ b/api/template.yaml @@ -40,30 +40,31 @@ Resources: Handler: app.main Layers: - !Sub '${LayerArn}' + Role: arn:aws:iam::056825751459:role/service-role/scratch-cheet-sheet-lambda-role Events: #/sheet - Get_sheet: + GetSheet: Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api Properties: Path: /sheet Method: get - Post_sheet/{sheetName}: + PostSheet: Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api Properties: Path: /sheet Method: post #/sheet/{sheetName} - Get_sheet/{sheetName}: + GetSheetSheetName: Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api Properties: Path: /sheet/{sheetName} Method: get - Delete_sheet/{sheetName}: + DeleteSheetSheetName: Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api Properties: Path: /sheet/{sheetName} Method: delete - Put_sheet/{sheetName}: + PutSheetSheetName: Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api Properties: Path: /sheet/{sheetName} diff --git a/docker-compose.deploy.code.yml b/docker-compose.deploy.code.yml new file mode 100644 index 0000000..32899fb --- /dev/null +++ b/docker-compose.deploy.code.yml @@ -0,0 +1,43 @@ +# ------------------------------------------------------------------------------ +# CODE DOCKER COMPOSE +# +# This Docker Compose is meant to deploy frontend code and backend code +# to a remote environment. +# +# What this deploys: +# - Angular code to an S3 bucket +# - Lambda Function that connects to an API Gateway +# +# Prerequisites: +# - Cognito Userpool +# - API Gateway +# - S3 Bucket for UI hosting +# - S3 Bucket for App Data Storage +# +# ------------------------------------------------------------------------------ +version: '3.7' +services: + # -------------------------------------------------------------------------- + # FRONTEND WRITTEN IN ANGULAR + # -------------------------------------------------------------------------- + serverless-angular-client-ui: + build: ./client-ui + container_name: serverless-angular-client-ui + volumes: + - ./client-ui:/usr/src/app + - /usr/src/app/node_modules + command: sh deploy.sh + # -------------------------------------------------------------------------- + # BACKEND WRITTEN IN AWS SAM LOCAL + # -------------------------------------------------------------------------- + serverless-lambda-api: + build: ./api + container_name: serverless-lambda-api + volumes: + - ./api:/app + environment: + - AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION + - AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY + - LAMBDA_LAYER:$LAMBDA_LAYER + # command: bash deploy.sh diff --git a/docker-compose.deploy.infrastructure.yml b/docker-compose.deploy.infrastructure.yml new file mode 100644 index 0000000..0dd0a52 --- /dev/null +++ b/docker-compose.deploy.infrastructure.yml @@ -0,0 +1,21 @@ +# ------------------------------------------------------------------------------ +# INFRASTRUCTURE DOCKER COMPOSE +# +# This Docker Compose is meant provision the necessary AWS resources +# for a user. This includes VPC's, Subnets, Roles and Policies. +# +# What this sets up: +# - Cognito Userpool +# - API Gateway +# - S3 Bucket for UI hosting +# - S3 Bucket for App Data Storage +# - S3 Bucket for Code Deployment Artifacts +# +# Prerequisites: +# - AWS VPC +# - Route53 Domains +# - Cloud Front CDN +# +# Note: If you don't have a Cloud Admin who can set this up for you +# it is recommended to use docker-compose.network.yml +# ------------------------------------------------------------------------------ diff --git a/docker-compose.deploy.network.yml b/docker-compose.deploy.network.yml new file mode 100644 index 0000000..a61437d --- /dev/null +++ b/docker-compose.deploy.network.yml @@ -0,0 +1,6 @@ +# ------------------------------------------------------------------------------ +# NETWORK DOCKER COMPOSE +# +# This Docker Compose is meant to setup the necessary network infrastructure +# for the app. This includes VPC's, Subnets, Roles and Policies. +# ------------------------------------------------------------------------------ diff --git a/docker-compose.yml b/docker-compose.yml index 40f31e5..70ab5ac 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,9 @@ +# ------------------------------------------------------------------------------ +# LOCAL DOCKER COMPOSE +# +# This Docker Compose is meant to run the App locally on ones machine. +# Its use case is for development. +# ------------------------------------------------------------------------------ version: '3.7' services: # --------------------------------------------------------------------------