Skip to content

Commit

Permalink
Merge pull request #560 from canopas/remove-api-gateway-from-deployment
Browse files Browse the repository at this point in the history
Remove api gateway from aws lambda
  • Loading branch information
cp-sumi-k authored Feb 19, 2024
2 parents 66a5276 + fce99d8 commit 11d4783
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 81 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/deploy-frontend-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ jobs:
sed -i "s|CLOUDFRONT_URL_VALUE|${{ secrets.CLOUDFRONT_URL_VALUE_DEV }}|g" config.js
sh ./../deploy/generate-sitemap.sh https://dev-stack.canopas.com https://dev-stack-api.canopas.com
yarn install --frozen-lockfile && yarn build
aws s3 rm s3://canopas-website-ssr-dev --recursive
cd .output/server && zip canopas_website_SSR_dev_${{ github.sha }}-${{ github.run_attempt }}.zip -r . && aws s3 cp canopas_website_SSR_dev_${{ github.sha }}-${{ github.run_attempt }}.zip s3://canopas-lambda-handlers && cd ../..
aws s3 sync --cache-control 'max-age=604800' --exclude *.html ./.output/public s3://canopas-website-ssr-dev
aws s3 sync ./.output/public s3://canopas-website-ssr-dev
aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_DEV }} --paths "/sitemap.xml"
- name: Deploy cloudformation stack
id: canopas-website-dev-lambda-stack-frontend
Expand All @@ -52,5 +52,4 @@ jobs:
no-fail-on-empty-changeset: "1"
parameter-overrides: >-
EnvName=dev,
ZipFileName=canopas_website_SSR_dev_${{ github.sha }}-${{ github.run_attempt }}.zip,
CloudfrontURL=${{ secrets.CLOUDFRONT_URL_VALUE_DEV }}
ZipFileName=canopas_website_SSR_dev_${{ github.sha }}-${{ github.run_attempt }}.zip
5 changes: 2 additions & 3 deletions .github/workflows/deploy-frontend-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ jobs:
mv config.prod.js config.js
sh ./../deploy/generate-sitemap.sh https://canopas.com https://prod-stack-api.canopas.com
yarn install --frozen-lockfile && yarn build
aws s3 rm s3://canopas-website-ssr-prod --recursive
cd .output/server && zip canopas_website_SSR_prod_${{ github.sha }}-${{ github.run_attempt }}.zip -r . && aws s3 cp canopas_website_SSR_prod_${{ github.sha }}-${{ github.run_attempt }}.zip s3://canopas-lambda-handlers && cd ../..
aws s3 sync --cache-control 'max-age=604800' --exclude *.html ./.output/public s3://canopas-website-ssr-prod
aws s3 sync ./.output/public s3://canopas-website-ssr-prod
aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_PROD }} --paths "/sitemap.xml"
- name: Deploy cloudformation stack
id: canopas-website-prod-lambda-stack-frontend
Expand All @@ -53,5 +53,4 @@ jobs:
no-fail-on-empty-changeset: "1"
parameter-overrides: >-
EnvName=prod,
ZipFileName=canopas_website_SSR_prod_${{ github.sha }}-${{ github.run_attempt }}.zip,
CloudfrontURL=${{ secrets.CLOUDFRONT_URL_VALUE_PROD }}
ZipFileName=canopas_website_SSR_prod_${{ github.sha }}-${{ github.run_attempt }}.zip
79 changes: 4 additions & 75 deletions infrastructure/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,75 +17,10 @@ Parameters:
ZipFileName:
Type: String
Description: Name of the zip file.
CloudfrontURL:
Type: String
Description: Cloudfront URL.

Resources:
HttpApi:
Type: AWS::Serverless::HttpApi
Properties:
StageName: $default
Description:
Fn::Sub: Canopas Website SSR Frontend API ${EnvName}
DefinitionBody:
openapi: "3.0.1"
info:
title:
Fn::Sub: canopas-website-ssr-frontend-${EnvName}
version: "1.0"
paths:
/favicon.ico:
x-amazon-apigateway-any-method:
responses:
default:
description: "Default response for ANY /favicon.ico"
x-amazon-apigateway-integration:
payloadFormatVersion: "1.0"
type: "http_proxy"
httpMethod: "ANY"
uri:
Fn::Sub: "${CloudfrontURL}favicon.ico"
connectionType: "INTERNET"
/sitemap.xml:
x-amazon-apigateway-any-method:
responses:
default:
description: "Default response for ANY /sitemap.xml"
x-amazon-apigateway-integration:
payloadFormatVersion: "1.0"
type: "http_proxy"
httpMethod: "ANY"
uri:
Fn::Sub: "${CloudfrontURL}sitemap.xml"
connectionType: "INTERNET"
/robots.txt:
x-amazon-apigateway-any-method:
responses:
default:
description: "Default response for ANY /robots.txt"
x-amazon-apigateway-integration:
payloadFormatVersion: "1.0"
type: "http_proxy"
httpMethod: "ANY"
uri:
Fn::Sub: "${CloudfrontURL}robots.txt"
connectionType: "INTERNET"
/apple-touch-icon.png:
x-amazon-apigateway-any-method:
responses:
default:
description: "Default response for ANY /apple-touch-icon.png"
x-amazon-apigateway-integration:
payloadFormatVersion: "1.0"
type: "http_proxy"
httpMethod: "ANY"
uri:
Fn::Sub: "${CloudfrontURL}apple-touch-icon.png"
connectionType: "INTERNET"
x-amazon-apigateway-importexport-version: "1.0"

HttpApiFunction:
Resources:
SSRFunction:
Type: AWS::Serverless::Function
Properties:
PackageType: Zip
Expand All @@ -101,11 +36,5 @@ Resources:
Fn::Sub: canopas-website-ssr-frontend-${EnvName}
Description:
Fn::Sub: Canopas Website SSR Frontend Lambda ${EnvName}
Events:
ProxyResource:
Type: HttpApi
Properties:
ApiId:
Ref: HttpApi
Path: $default
Method: any
FunctionUrlConfig:
AuthType: NONE
1 change: 1 addition & 0 deletions nuxt-frontend/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default Object.freeze({
blog: "https://blog.canopas.com",
linkedin: "https://www.linkedin.com/company/canopasinc",
youtube: "https://www.youtube.com/channel/UC77VyeTVJ45HiUS_o2GNcBA/videos",
github: "https://github.com/canopas",
},

// SEO and meta data
Expand Down
1 change: 1 addition & 0 deletions nuxt-frontend/config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default Object.freeze({
blog: "https://blog.canopas.com",
linkedin: "https://www.linkedin.com/company/canopasinc",
youtube: "https://www.youtube.com/channel/UC77VyeTVJ45HiUS_o2GNcBA/videos",
github: "https://github.com/canopas",
},

// SEO and meta data
Expand Down

0 comments on commit 11d4783

Please sign in to comment.