Create status-badges and commit-id badges according to CodeBuild/CodePipeline states.
The badges are uploaded to S3 bucket, and then you can link to those badges (SVG files) in your README.md
- You have at least one CodeBuild project and/or at least one CodePipeline.
- You're going to launch this app in the same region your CodeBuild projects and CodePipelines are
- Yup, that's it, no installation no nothing
Not using any of the regions above? Go ahead and deploy with a template
Download the cloudformation template from here and upload it manually to a specific region.
Expand/Collapse
- NodeJS 10.x - AWS Lambda supports this version of NodeJS
- AWS SDK for JavaScript - Upload status badges to S3 bucket, and get commit-id from pipeline
- yarn - package manager (instead of npm)
- TypeScript 3.7 - targeting ES5
- ESLint - Linting TypeScript (src) and JavaScript (dist) files
- Webpack v3.3 - Packing and minifying code -
yarn build
- serverless-framework - Deploying to AWS -
yarn deploy:vault-dev
- Jest - for testing -
yarn test
- aws-vault - securing AWS credentials
- Download and install the LTS version of NodeJS
- Download and install git
- Clone this repo with git
(home) $: git clone https://github.com/unfor19/aws-build-badges.git (home) $: cd ./aws-build-badges (aws-build-badges) $:
- Download and install yarn
- Install serverless-framework globally
(aws-build-badges) $: yarn global add serverless
- Install application dependencies
(aws-build-badges) $: yarn installDeps
- Create a bucket for serverless deployments, and name it:
myapp-badges-deployment-STAGE
, where myapp is your app's name- For example:
myapp-badges-deployment-prod
- For example:
- (Optional) Download and install aws-vault
Copy env
file to .env
and modify the relevant variables.
These variables are releavnt only if you intend to run tests or aws-vault.
BUCKET_BADGES=myapp-bucket-for-testing # jest
IMAGEPATH=true # for tests
VAULT_PROFILE_TESTING=myapp-dev # aws-vault
VAULT_PROFILE_DEV=myapp-dev # aws-vault
VAULT_PROFILE_STAGING=myapp-staging # aws-vault
VAULT_PROFILE_PROD=myapp-prod # aws-vault
Copy serverless.vars.yml
to .serverless.vars.yml
and modify the relevant variables.
Find and replace "myapp" with your application's name. And of course, do whatever changes you need, so it fits your infrastructure.
The scripts reside in the package.json
file, under the scripts
section.
All the scripts must run while the present working directory is the project's folder, aws-build-badges
yarn test:vault - Run jest using aws-vault profile
yarn test:aws - Run jest using AWS credentials and profiles
yarn build:dev - Run webpack for each service, mode=development
yarn build:prod - Run webpack for each service, mode=production
yarn deploy:vault-STAGE - Deploy to AWS using aws-vault profile
yarn deploy:aws-STAGE - Deploy to AWS using AWS credentials and profiles
yarn destroy:vault-STAGE - Destroy stack using aws-vault profile
yarn destroy:aws-STAGE - Destroy stack using AWS credentials and profiles
(aws-build-badges) $: yarn deploy:vault-prod
yarn run v1.19.1
$ yarn build:prod && export $(cat .env) && aws-vault exec ${VAULT_PROFILE_PROD} -- sls deploy --verbose --stage=prod
$ bash build_services_prod
...
Serverless: Removing old service artifacts from S3...
Serverless: Run the "serverless" command to setup monitoring, troubleshooting and testing.
Done in 193.59s.
- Issue: Fails with:
Invalid bucket name
.- Solution: Set the
BUCKET_BADGES
variable in.env
- Solution: Set the
- Issue: Failed to get credentials for jest
- Solution: Set the
VAULT_PROFILE_TESTING
variable in.env
- Solution: Set the
- Issue: (node:#####) DeprecationWarning: Tapable.plugin is deprecated. Use new API on
.hooks
instead- Solution: You can ignore this warning - details
OS | Bash | serverless-framework | yarn | AWS SDK | aws-vault |
---|---|---|---|---|---|
Ubuntu 19.10 | 5.0.3 | 1.56.1 | 1.19.1 | 2.580.0 | 4.7.1 |
Windows 10 | TBD | TBD | TBD | TBD | TBD |
MacOS | TBD | TBD | TBD | TBD | TBD |