diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index 9ee7f8d..0000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,15 +0,0 @@ -env: - browser: true - es2021: true -extends: - - standard -parser: '@typescript-eslint/parser' -parserOptions: - ecmaVersion: latest -plugins: - - '@typescript-eslint' -rules: { - 'no-new': off, - 'no-undef': off, - 'no-useless-escape': off -} diff --git a/.github/workflows/pipeline.yaml b/.github/workflows/pipeline.yaml index b833006..c85dc14 100644 --- a/.github/workflows/pipeline.yaml +++ b/.github/workflows/pipeline.yaml @@ -15,7 +15,7 @@ jobs: Build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Warming run: make warming - name: Build @@ -24,7 +24,7 @@ jobs: Linting: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Warming run: make warming - name: Linting @@ -33,7 +33,7 @@ jobs: Security: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Warming run: make warming # Build AWS CDK output @@ -55,7 +55,7 @@ jobs: UnitTest: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Warming run: make warming - name: Unit tests diff --git a/README.md b/README.md index 3df62c7..21d18a9 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ AWS CodePipeline is a continuous integration and continuous delivery (CI/CD) ser * CloudFormation stacks -CloudFormation is AWS' service for provisioning infrastructure as code (IaC) through the use of YAML or JSON templates. It uses stacks to logically group various AWS services into a collection, which can be managed as a single unit. These stacks can create things like a AWS CodeCommit repository and a AWS CodePipeline CI/CD pipeline. +CloudFormation is an AWS service for provisioning infrastructure as code (IaC) through the use of YAML or JSON templates. It uses stacks to logically group various AWS services into a collection, which can be managed as a single unit. These stacks can create things like a AWS CodeCommit repository and a AWS CodePipeline CI/CD pipeline. ## Architecture ![pipepline](./docs/aws-codepipeline-cicd.png) @@ -35,11 +35,11 @@ In the Dev stage there are 3 steps `Linting`, `Security` and `Unit Tests`. These ## Prerequsites & Limitations This project use AWS CDK v2 based on typescript. The developer laptop/computer should have following software. -* [AWS CDK v2](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) v2.41.0 +* [AWS CDK v2](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) v2.61.0 * [cfn_nag](https://github.com/stelligent/cfn_nag) v0.8.10 * [git-remote-codecommit](https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-git-remote-codecommit.html) v1.16 -* [node](https://nodejs.org/en/download/) v16 -* [typescript](https://www.typescriptlang.org/) v4.7.3 +* [node](https://nodejs.org/en/download/) v19 +* [typescript](https://www.typescriptlang.org/) v4.9.4 Limitation @@ -52,11 +52,10 @@ This project is based on [AWS CDK v2](https://docs.aws.amazon.com/cdk/api/v2/doc If you are using MacOS, you can install the prerequisites by running the following command in your preferred terminal or also on Linux using [homebrew for Linux](https://docs.brew.sh/Homebrew-on-Linux): ```bash -brew install node@16 -echo 'export PATH="/usr/local/opt/node@16/bin:$PATH"' >> ~/.bash_profile +brew install node brew install git-remote-codecommit brew install ruby brew-gem -gem install cfn-nag +brew-gem install cfn-nag ``` #### AWS Cloud9 @@ -118,7 +117,7 @@ npm run cdk bootstrap "aws://${ACCOUNT_NUMBER}/${AWS_REGION}" After successful bootstrap, you should see the following output: ```bash ⏳ Bootstrapping environment aws://{account#}/eu-west-1... - ✅ Environment aws://{account#}/eu-west-1 bootstrapped + ✅ Environment aws://{account#}/eu-west-1 bootstrapped. ``` For more details refer CDK Bootstraping section in [AWS CDK](https://docs.aws.amazon.com/cdk/v2/guide/bootstrapping.html). diff --git a/package.json b/package.json index 4534761..5422fc0 100644 --- a/package.json +++ b/package.json @@ -12,27 +12,43 @@ "eslint": "eslint . --ext .ts --max-warnings 0" }, "devDependencies": { - "@types/jest": "^29.0.1", - "@types/node": "18.7.16", - "@typescript-eslint/eslint-plugin": "^5.22.0", - "@typescript-eslint/parser": "^5.22.0", - "aws-cdk": "2.41.0", - "eslint": "^8.14.0", - "eslint-config-standard": "^17.0.0", - "eslint-plugin-import": "^2.26.0", - "eslint-plugin-n": "^15.2.0", - "eslint-plugin-promise": "^6.0.0", + "@types/jest": "^29.2.5", + "@types/node": "^18.11.18", + "@typescript-eslint/eslint-plugin": "^5.48.1", + "@typescript-eslint/parser": "^5.48.1", + "aws-cdk": "^2.61.1", + "eslint": "^8.32.0", + "eslint-config-standard-with-typescript": "^27.0.1", + "eslint-plugin-import": "^2.27.4", + "eslint-plugin-n": "^15.6.1", + "eslint-plugin-promise": "^6.1.1", "generate-license-file": "^2.0.0", - "jest": "^26.4.2", - "jest-junit": "^14.0.0", - "ts-jest": "^26.2.0", - "ts-node": "^10.8.1", - "typescript": "^4.7.3" + "jest": "^29.3.1", + "jest-junit": "^15.0.0", + "ts-jest": "^29.0.3", + "ts-node": "^10.9.1", + "typescript": "^4.9.4" }, "dependencies": { - "aws-cdk-lib": "2.41.0", + "aws-cdk-lib": "^2.61.1", "constructs": "^10.0.0", - "source-map-support": "^0.5.16" + "source-map-support": "^0.5.21" + }, + "eslintConfig": { + "env": { + "browser": true, + "es2021": true + }, + "extends": "standard-with-typescript", + "overrides": [], + "parserOptions": { + "ecmaVersion": "latest", + "project": "tsconfig.json" + }, + "rules": { + "no-new": "off", + "no-undef": "off" + } }, "jest": { "collectCoverage": true, diff --git a/test/main-stack.test.ts b/test/main-stack.test.ts index b1b5be5..7205a52 100644 --- a/test/main-stack.test.ts +++ b/test/main-stack.test.ts @@ -2,22 +2,16 @@ import * as cdk from 'aws-cdk-lib' import { Template } from 'aws-cdk-lib/assertions' import { MainStack } from '../lib/main-stack' +const app = new cdk.App() +const stack = new MainStack(app, 'Dev-MainStack') +const template = Template.fromStack(stack) + test('Event Bus has been created', () => { - const app = new cdk.App() - // WHEN - const stack = new MainStack(app, 'Dev-MainStack') - // THEN - const template = Template.fromStack(stack) // Assessment template.hasResource('AWS::Events::EventBus', '') }) test('MainStack has output', () => { - const app = new cdk.App() - // WHEN - const stack = new MainStack(app, 'Dev-MainStack') - // THEN - const template = Template.fromStack(stack) // Assessment template.hasOutput('EventBusName', '') }) diff --git a/test/pipeline-stack.test.ts b/test/pipeline-stack.test.ts index 10f6248..6f479c8 100644 --- a/test/pipeline-stack.test.ts +++ b/test/pipeline-stack.test.ts @@ -2,14 +2,24 @@ import * as cdk from 'aws-cdk-lib' import { Template } from 'aws-cdk-lib/assertions' import { CodePipelineStack } from '../lib/pipeline-stack' -test('Pipeline has been created', () => { - const app = new cdk.App() - // WHEN - const stack = new CodePipelineStack(app, 'CodePipeline') - // THEN - const template = Template.fromStack(stack) +const app = new cdk.App() +const stack = new CodePipelineStack(app, 'CodePipeline') +const template = Template.fromStack(stack) + +// Execute tests for CodePipeline template +test('Pipeline restarts on update', () => { // Assessment template.hasResourceProperties('AWS::CodePipeline::Pipeline', { RestartExecutionOnUpdate: true }) }) + +test('There are 8 CodeBuild objects in use', () => { + // Assessment + template.resourceCountIs('AWS::CodeBuild::Project', 8) +}) + +test('CodePipeline has repository name in output', () => { + // Assessment + template.hasOutput('RepositoryName', '') +})