-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from wri/feat/TM-1273-deployment
[TM-1273] AWS Deployment
- Loading branch information
Showing
30 changed files
with
5,148 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
dist | ||
tmp | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Api Gateway Deploy | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
env: | ||
description: 'Deployment target environment' | ||
type: choice | ||
required: true | ||
options: | ||
- dev | ||
- test | ||
- staging | ||
- prod | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
env: | ||
NODE_ENV: production | ||
AWS_REGION: eu-west-1 | ||
AWS_ROLE_TO_ASSUME: arn:aws:iam::603634817705:role/terramatch-microservices-github-actions | ||
AWS_ROLE_SESSION_NAME: terramatch-microservices-cicd-api-gateway | ||
PHP_PROXY_TARGET: ${{ vars.PHP_PROXY_TARGET }} | ||
|
||
jobs: | ||
main: | ||
runs-on: ubuntu-latest | ||
environment: ${{ inputs.env }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/[email protected] | ||
with: | ||
role-to-assume: ${{ env.AWS_ROLE_TO_ASSUME }} | ||
role-session-name: ${{ env.AWS_ROLE_SESSION_NAME }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
|
||
- name: CDK Deploy | ||
id: cdk-deploy | ||
run: | | ||
cd apps/api-gateway | ||
NODE_ENV=development npm i | ||
TM_ENV=${{ inputs.env }} npx --yes cdk deploy --require-approval never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: User Service Deploy | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
env: | ||
description: 'Deployment target environment' | ||
type: choice | ||
required: true | ||
options: | ||
- dev | ||
- test | ||
- staging | ||
- prod | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
env: | ||
AWS_REGION: eu-west-1 | ||
AWS_ROLE_TO_ASSUME: arn:aws:iam::603634817705:role/terramatch-microservices-github-actions | ||
AWS_ROLE_SESSION_NAME: terramatch-microservices-cicd-user-service | ||
ECR_REPOSITORY: terramatch-microservices/user-service-${{ inputs.env }} | ||
ECR_REGISTRY: 603634817705.dkr.ecr.eu-west-1.amazonaws.com | ||
IMAGE_TAG: ${{ github.sha }} | ||
|
||
jobs: | ||
main: | ||
runs-on: ubuntu-latest | ||
environment: ${{ inputs.env }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/[email protected] | ||
with: | ||
role-to-assume: ${{ env.AWS_ROLE_TO_ASSUME }} | ||
role-session-name: ${{ env.AWS_ROLE_SESSION_NAME }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
|
||
- name: Login to AWS | ||
id: AWS | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Build, tag, and push images to Amazon ECR | ||
id: build-images | ||
run: | | ||
echo "${{ vars.ENV }}" > .env | ||
echo "DB_PASSWORD=\"${{ secrets.DB_PASSWORD }}\"" >> .env | ||
: # Don't build the base image with NODE_ENV because it'll limit the packages that are installed | ||
docker build -t terramatch-microservices-base:nx-base . | ||
USER_SERVICE_IMAGE=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
docker build --build-arg NODE_ENV=production --build-arg BUILD_FLAG=--prod -f apps/user-service/Dockerfile -t $USER_SERVICE_IMAGE . | ||
docker push $USER_SERVICE_IMAGE | ||
echo "image=$USER_SERVICE_IMAGE" | ||
- name: Launch new task definition | ||
id: launch | ||
run: | | ||
cd apps/user-service/stack | ||
npm i | ||
IMAGE_TAG=$IMAGE_TAG TM_ENV=${{ inputs.env }} npx --yes cdk deploy --require-approval never | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
apps/*/stack |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM node:lts-alpine3.19 as builder | ||
ARG NODE_ENV | ||
ARG BUILD_FLAG | ||
|
||
WORKDIR /app/builder | ||
COPY . . | ||
RUN npm i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{ | ||
"vpc-provider:account=603634817705:filter.vpc-id=vpc-0beac5973796d96b1:region=eu-west-1:returnAsymmetricSubnets=true": { | ||
"vpcId": "vpc-0beac5973796d96b1", | ||
"vpcCidrBlock": "10.0.0.0/16", | ||
"ownerAccountId": "603634817705", | ||
"availabilityZones": [], | ||
"subnetGroups": [ | ||
{ | ||
"name": "Private", | ||
"type": "Private", | ||
"subnets": [ | ||
{ | ||
"subnetId": "subnet-065992a829eb772a3", | ||
"cidr": "10.0.128.0/20", | ||
"availabilityZone": "eu-west-1a", | ||
"routeTableId": "rtb-07f85b7827c451bc9" | ||
}, | ||
{ | ||
"subnetId": "subnet-0f48d0681051fa49a", | ||
"cidr": "10.0.144.0/20", | ||
"availabilityZone": "eu-west-1b", | ||
"routeTableId": "rtb-06afefb0f592f11d6" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "Public", | ||
"type": "Public", | ||
"subnets": [ | ||
{ | ||
"subnetId": "subnet-0a099d863485e6c39", | ||
"cidr": "10.0.0.0/20", | ||
"availabilityZone": "eu-west-1a", | ||
"routeTableId": "rtb-001c321e760157b3b" | ||
}, | ||
{ | ||
"subnetId": "subnet-0a91312f58b03ad3f", | ||
"cidr": "10.0.16.0/20", | ||
"availabilityZone": "eu-west-1b", | ||
"routeTableId": "rtb-001c321e760157b3b" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"load-balancer:account=603634817705:loadBalancerTags.0.key=service:loadBalancerTags.0.value=user-service-test:loadBalancerType=application:region=eu-west-1": { | ||
"loadBalancerArn": "arn:aws:elasticloadbalancing:eu-west-1:603634817705:loadbalancer/app/user-service-test/e1ee1ce635080238", | ||
"loadBalancerCanonicalHostedZoneId": "Z32O12XQLNTSW2", | ||
"loadBalancerDnsName": "internal-user-service-test-1863479300.eu-west-1.elb.amazonaws.com", | ||
"vpcId": "vpc-0beac5973796d96b1", | ||
"securityGroupIds": [ | ||
"sg-06a4b12aa14e529be" | ||
], | ||
"ipAddressType": "ipv4" | ||
}, | ||
"security-group:account=603634817705:region=eu-west-1:securityGroupId=sg-06a4b12aa14e529be": { | ||
"securityGroupId": "sg-06a4b12aa14e529be", | ||
"allowAllOutbound": false | ||
}, | ||
"security-group:account=603634817705:region=eu-west-1:securityGroupName=default:vpcId=vpc-0beac5973796d96b1": { | ||
"securityGroupId": "sg-0fcff87239114297b", | ||
"allowAllOutbound": false | ||
}, | ||
"load-balancer-listener:account=603634817705:loadBalancerTags.0.key=service:loadBalancerTags.0.value=user-service-test:loadBalancerType=application:region=eu-west-1": { | ||
"listenerArn": "arn:aws:elasticloadbalancing:eu-west-1:603634817705:listener/app/user-service-test/e1ee1ce635080238/069ab4638dd50686", | ||
"listenerPort": 80, | ||
"securityGroupIds": [ | ||
"sg-06a4b12aa14e529be" | ||
] | ||
} | ||
} |
Oops, something went wrong.