-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(COND-1): Integrate the Amazon CDK to deploy the app and set up t…
…he CI/CD pipeline in the development environment
- Loading branch information
Showing
40 changed files
with
4,232 additions
and
10 deletions.
There are no files selected for viewing
File renamed without changes.
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,26 @@ | ||
name: Deploy to Develop | ||
|
||
on: | ||
workflow_run: | ||
workflows: ['Continuous Integration'] # Triggers after the specified workflow completes | ||
types: | ||
- completed | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy to Develop | ||
environment: | ||
name: develop | ||
runs-on: ubuntu-latest | ||
if: | | ||
github.event.workflow_run.conclusion == 'success' && | ||
contains(github.event.workflow_run.head_branch, 'develop') | ||
steps: | ||
- name: Trigger AWS CodePipeline | ||
run: | ||
aws codepipeline start-pipeline-execution --name ${{ | ||
vars.CODE_BUILD_PIPELINE }} --region ${{ vars.AWS_REGION }} | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
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
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,75 @@ | ||
{ | ||
"extends": [ | ||
"eslint:recommended", | ||
"eslint-config-airbnb-base", | ||
"airbnb-typescript", | ||
"plugin:@typescript-eslint/recommended", | ||
"prettier" | ||
], | ||
"env": { | ||
"es2021": true, | ||
"node": true | ||
}, | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["@typescript-eslint", "prettier"], | ||
"rules": { | ||
"@typescript-eslint/no-unused-vars": "error", | ||
"import/prefer-default-export": "off", | ||
"no-tabs": ["off"], | ||
"max-len": ["off"], | ||
"no-await-in-loop": "off", | ||
"react/jsx-filename-extension": "off", | ||
"class-methods-use-this": "off", | ||
"no-new": "off", | ||
"no-param-reassign": "off", | ||
"@typescript-eslint/quotes": [ | ||
"error", | ||
"single", | ||
{ | ||
"avoidEscape": true | ||
} | ||
], | ||
"@typescript-eslint/comma-dangle": ["error", "never"], | ||
"@typescript-eslint/no-namespace": "off", | ||
"@typescript-eslint/no-non-null-assertion": "off", | ||
"@typescript-eslint/no-use-before-define": "off", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/lines-between-class-members": [ | ||
"error", | ||
"always", | ||
{ | ||
"exceptAfterSingleLine": true | ||
} | ||
], | ||
"prettier/prettier": [ | ||
"error", | ||
{ | ||
"tabWidth": 2 | ||
} | ||
] | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": ["*.spec.{js,ts}"], | ||
"env": { | ||
"mocha": true, | ||
"node": true | ||
}, | ||
"rules": { | ||
"no-unused-expressions": "off", | ||
"@typescript-eslint/no-unused-expressions": "off", | ||
"@typescript-eslint/no-throw-literal": "off" | ||
} | ||
} | ||
], | ||
"parserOptions": { | ||
"project": "./tsconfig.json" | ||
}, | ||
"ignorePatterns": [ | ||
"dist", | ||
"node_modules", | ||
".eslintrc.js", | ||
"jest.config.js", | ||
"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 @@ | ||
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,22 @@ | ||
{ | ||
"printWidth": 85, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"semi": true, | ||
"singleQuote": true, | ||
"quoteProps": "as-needed", | ||
"jsxSingleQuote": false, | ||
"trailingComma": "none", | ||
"bracketSpacing": true, | ||
"jsxBracketSameLine": false, | ||
"arrowParens": "always", | ||
"proseWrap": "always", | ||
"plugins": [ | ||
"prettier-plugin-packagejson", | ||
"@trivago/prettier-plugin-sort-imports" | ||
], | ||
"importOrder": ["^dotenv/config$", "<THIRD_PARTY_MODULES>", "^[./]"], | ||
"importOrderSeparation": true, | ||
"importOrderSortSpecifiers": true, | ||
"importOrderCaseInsensitive": false | ||
} |
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,2 @@ | ||
qa: | ||
yarn prettify && yarn lint:fix |
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,3 @@ | ||
{ | ||
"app": "ts-node main.ts" | ||
} |
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,16 @@ | ||
{ | ||
"nodeEnv": "NODE_ENV", | ||
"aws": { | ||
"region": "AWS_REGION", | ||
"accountId": "AWS_ACCOUNT_ID", | ||
"arn": { | ||
"role": { | ||
"lambda": "AWS_ROLE_LAMBDA_ARN" | ||
} | ||
} | ||
}, | ||
"github": { | ||
"repository": "GITHUB_REPOSITORY", | ||
"owner": "GITHUB_OWNER" | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"aws": { | ||
"region": "us-east-1" | ||
}, | ||
"github": { | ||
"repository": "realworld-nodejs-example-app", | ||
"owner": "kenyipp" | ||
} | ||
} |
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,3 @@ | ||
{ | ||
"nodeEnv": "develop" | ||
} |
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,3 @@ | ||
{ | ||
"nodeEnv": "prod" | ||
} |
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 @@ | ||
import { ResourcePrefix } from './constants'; | ||
|
||
export const Lambdas = { | ||
UserServerFunction: `${ResourcePrefix}-user-server-lambda`, | ||
AppServerFunction: `${ResourcePrefix}-app-server-lambda`, | ||
ArticleServerFunction: `${ResourcePrefix}-article-server-lambda`, | ||
TestingCron: `${ResourcePrefix}-testing-cron-lambda` | ||
}; |
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 @@ | ||
import { config } from '../utils'; | ||
|
||
export const Secrets = { | ||
GithubToken: 'conduit/github-token', | ||
DatabaseConfig: `conduit/${config.nodeEnv}/database`, | ||
JwtSecret: `conduit/${config.nodeEnv}/jwt-token`, | ||
DomainCert: `conduit/${config.nodeEnv}/acm-certificate` | ||
}; |
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 @@ | ||
import { ResourcePrefix } from './constants'; | ||
|
||
export const Stacks = { | ||
ApiGateway: `${ResourcePrefix}-api-gateway-stack`, | ||
Lambda: `${ResourcePrefix}-lambda-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,6 @@ | ||
import { config } from '../utils'; | ||
|
||
const app = 'conduit-api'; | ||
const { accountId } = config.aws; | ||
|
||
export const ResourcePrefix = `${app}-${config.nodeEnv}-${accountId}`; |
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 @@ | ||
export * from './constants'; | ||
export * from './Lambdas'; | ||
export * from './Stacks'; | ||
export * from './Secrets'; |
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,57 @@ | ||
import 'dotenv/config'; | ||
|
||
import { CdkGraph, FilterPreset } from '@aws/pdk/cdk-graph'; | ||
import { | ||
CdkGraphDiagramPlugin, | ||
DiagramFormat | ||
} from '@aws/pdk/cdk-graph-plugin-diagram'; | ||
import { App, Environment } from 'aws-cdk-lib'; | ||
|
||
import { Stacks } from './constants'; | ||
import { ApiGatewayStack, LambdaStack } from './stacks'; | ||
import { config } from './utils'; | ||
|
||
// eslint-disable-next-line no-void, func-names | ||
void (async function () { | ||
const app = new App(); | ||
|
||
const env: Environment = { | ||
region: config.aws.region, | ||
account: config.aws.accountId | ||
}; | ||
|
||
const lambdaStack = new LambdaStack(app, Stacks.Lambda, { | ||
env, | ||
roleArn: config.aws.arn.role.lambda | ||
}); | ||
|
||
new ApiGatewayStack(app, Stacks.ApiGateway, { | ||
env, | ||
userFunctionArn: lambdaStack.userServerFunction.functionArn, | ||
appFunctionArn: lambdaStack.appServerFunction.functionArn, | ||
articleServerFunctionArn: lambdaStack.articleServerFunction.functionArn | ||
}); | ||
|
||
// Generate a diagram for the whole architecture | ||
const group = new CdkGraph(app, { | ||
plugins: [ | ||
new CdkGraphDiagramPlugin({ | ||
diagrams: [ | ||
{ | ||
name: 'conduit-api-stack-diagram', | ||
title: 'Conduit Api Stack Diagram', | ||
format: DiagramFormat.PNG, | ||
theme: 'light', | ||
filterPlan: { | ||
preset: FilterPreset.COMPACT | ||
} | ||
} | ||
] | ||
}) | ||
] | ||
}); | ||
|
||
app.synth(); | ||
|
||
await group.report(); | ||
})(); |
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,43 @@ | ||
{ | ||
"name": "@conduit/lamba-infra", | ||
"version": "1.0.0", | ||
"description": "", | ||
"license": "ISC", | ||
"author": "ken.yip", | ||
"main": "main.ts", | ||
"scripts": { | ||
"cdk:list": "cdk list", | ||
"check-types": "tsc --skipLibCheck --noEmit", | ||
"deploy": "cdk deploy --require-approval never", | ||
"lint": "eslint .", | ||
"lint:fix": "eslint . --fix", | ||
"prettify": "prettier --write .", | ||
"synth": "cdk synth" | ||
}, | ||
"dependencies": { | ||
"@aws/pdk": "^0.25.0", | ||
"aws-cdk": "2.161.1", | ||
"aws-cdk-lib": "2.161.1", | ||
"config": "^3.3.12", | ||
"constructs": "^10.4.1", | ||
"dotenv": "^16.4.5" | ||
}, | ||
"devDependencies": { | ||
"@trivago/prettier-plugin-sort-imports": "^4.3.0", | ||
"@types/config": "^3.3.5", | ||
"@types/node": "^22.7.5", | ||
"@typescript-eslint/eslint-plugin": "^5.30.7", | ||
"@typescript-eslint/parser": "^5.30.7", | ||
"eslint": "^8.19.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-airbnb-typescript": "^17.0.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-jest": "^26.5.3", | ||
"eslint-plugin-prettier": "^5.2.1", | ||
"prettier": "^3.3.3", | ||
"prettier-plugin-packagejson": "^2.5.3", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.6.3" | ||
} | ||
} |
Oops, something went wrong.