-
Notifications
You must be signed in to change notification settings - Fork 1
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 #32 from moduslabs/feature-cloudformation
FET-769 - Create a CDK project to deploy the webapp at AWS
- Loading branch information
Showing
16 changed files
with
11,706 additions
and
1 deletion.
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,55 @@ | ||
name: Deployment master | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
||
env: | ||
NAMESPACE: stage | ||
QUALIFIER: stage | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [16.x] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@master | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
|
||
- name: Install dependencies to deploy project | ||
run: npm install | ||
|
||
- name: Build project | ||
run: npm run build | ||
|
||
- name: Install dependencies for cdk | ||
run: npm install | ||
working-directory: deploy | ||
|
||
- name: Synth template | ||
run: npm run cdk synth | ||
working-directory: deploy | ||
|
||
- name: Bootstrap stack | ||
run: npm run cdk bootstrap -- --toolkit-stack-name CDKToolKitStage --qualifier ${{ env.QUALIFIER }} | ||
working-directory: deploy | ||
|
||
- name: Deploy stack | ||
run: npm run cdk deploy -- --require-approval never | ||
working-directory: deploy |
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,55 @@ | ||
name: On Release published | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
env: | ||
NAMESPACE: production | ||
QUALIFIER: production | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [16.x] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@master | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
|
||
- name: Install dependencies to deploy project | ||
run: npm install | ||
|
||
- name: Build project | ||
run: npm run build | ||
|
||
- name: Install dependencies for cdk | ||
run: npm install | ||
working-directory: deploy | ||
|
||
- name: Synth template | ||
run: npm run cdk synth | ||
working-directory: deploy | ||
|
||
- name: Bootstrap stack | ||
run: npm run cdk bootstrap -- --toolkit-stack-name CDKToolKitProduction --qualifier ${{ env.QUALIFIER }} | ||
working-directory: deploy | ||
|
||
- name: Deploy stack | ||
run: npm run cdk deploy -- --require-approval never | ||
working-directory: deploy |
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 @@ | ||
!jest.config.js | ||
*.d.ts | ||
node_modules | ||
|
||
# CDK asset staging directory | ||
.cdk.staging | ||
cdk.out |
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,6 @@ | ||
*.ts | ||
!*.d.ts | ||
|
||
# CDK asset staging directory | ||
.cdk.staging | ||
cdk.out |
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,27 @@ | ||
import "source-map-support/register"; | ||
import * as cdk from "aws-cdk-lib"; | ||
import { Stack, StackProps } from "aws-cdk-lib"; | ||
import { Construct } from "constructs"; | ||
import { capitalize, getNamespace } from "./utils"; | ||
import { getHTTPSCertificate } from "./resources/certificate-dns"; | ||
import { getHostedZone, getHostedZoneRecords } from "./resources/route-53"; | ||
import { getWebappResources } from "./resources/cloud-front-distribution"; | ||
|
||
export class CdkIshiharaAppStack extends Stack { | ||
constructor(scope: Construct, id: string, props?: StackProps) { | ||
super(scope, id, props); | ||
|
||
const hostedZone = getHostedZone(this); | ||
const certificate = getHTTPSCertificate(this, hostedZone); | ||
const { cloudFrontDistribution } = getWebappResources(this, certificate); | ||
getHostedZoneRecords(this, hostedZone, cloudFrontDistribution); | ||
} | ||
} | ||
|
||
const app = new cdk.App(); | ||
|
||
new CdkIshiharaAppStack(app, `CdkIshiharaAppStack${capitalize(getNamespace())}`, { | ||
synthesizer: new cdk.DefaultStackSynthesizer({ | ||
qualifier: process.env.QUALIFIER || 'local', | ||
}), | ||
}); |
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,33 @@ | ||
{ | ||
"app": "npm run ts-node -- --prefer-ts-exts ./cdk-ishihara-app-stack.ts", | ||
"watch": { | ||
"include": [ | ||
"**" | ||
], | ||
"exclude": [ | ||
"README.md", | ||
"cdk*.json", | ||
"**/*.d.ts", | ||
"**/*.js", | ||
"tsconfig.json", | ||
"package*.json", | ||
"yarn.lock", | ||
"node_modules", | ||
"test" | ||
] | ||
}, | ||
"context": { | ||
"@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true, | ||
"@aws-cdk/core:stackRelativeExports": true, | ||
"@aws-cdk/aws-rds:lowercaseDbIdentifier": true, | ||
"@aws-cdk/aws-lambda:recognizeVersionProps": true, | ||
"@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true, | ||
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true, | ||
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true, | ||
"@aws-cdk/aws-iam:minimizePolicies": true, | ||
"@aws-cdk/core:target-partitions": [ | ||
"aws", | ||
"aws-cn" | ||
] | ||
} | ||
} |
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,6 @@ | ||
{ | ||
"cdk": { | ||
"zoneName": "ishihara-app.com", | ||
"hostedZoneId": "Z054722611ERV11JTXKBK" | ||
} | ||
} |
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,8 @@ | ||
module.exports = { | ||
testEnvironment: 'node', | ||
roots: ['<rootDir>/test'], | ||
testMatch: ['**/*.test.ts'], | ||
transform: { | ||
'^.+\\.tsx?$': 'ts-jest' | ||
} | ||
}; |
Oops, something went wrong.