Skip to content

Commit

Permalink
Merge pull request #155 from aws-samples/feature/module_update
Browse files Browse the repository at this point in the history
Feature/module update
  • Loading branch information
kzarms committed Feb 27, 2023
2 parents c7dc7aa + 0e59cfa commit 343fae0
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 60 deletions.
15 changes: 0 additions & 15 deletions .eslintrc.yml

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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).
Expand Down
50 changes: 33 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 4 additions & 10 deletions test/main-stack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', '')
})
22 changes: 16 additions & 6 deletions test/pipeline-stack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', '')
})

0 comments on commit 343fae0

Please sign in to comment.