Skip to content

nathanagez/serverless-integration-testing-with-step-functions

Repository files navigation

serverless-integration-testing-with-step-functions

Inspired from Bite-Sized Serverless courses and serverless-integration-testing-with-step-functions .

This sample repository integrates serverless-integration-testing-with-step-functions with CDK Pipelines, in TypeScript.

All credits go to @donkersgood for his work on bitesizedserverless.com.

Getting started

Setup

The following tools need to be installed on your system prior to installing the CDK:

Bootstrapping

Deploying AWS CDK apps into an AWS environment (a combination of an AWS account and region) may require that you provision resources the AWS CDK needs to perform the deployment. These resources include an Amazon S3 bucket for storing files and IAM roles that grant permissions needed to perform deployments. The process of provisioning these initial resources is called bootstrapping.

$ cdk bootstrap aws://<ACCOUNT-NUMBER-1/REGION-1

GitHub token

By default, the pipeline authenticates to GitHub using a personal access token stored in Secrets Manager under the name github-token.

Read more about CodePipeline sources here.

Deploy

$ cdk deploy

Temporary stage

If you need to test a feature before making a PR you can deploy your own stack by creating a stage inside bin/curation-tool-cdk.

This saves you the trouble of triggering CodePipelines.

⚠️ Don't push your temporary stage on the repository.

new PipelineStage(app, 'your-local-stage', {
    env: {
        account: process.env.CDK_DEFAULT_ACCOUNT,
        region: process.env.CDK_DEFAULT_REGION
    }
})

Synthesize an AWS CloudFormation template for the app, as follows.

$ cdk synth

Deploy your temporary stage CloudFormation template, as follows.

$ cdk deploy -a cdk.out/assembly-your-local-stage

Once done, don't forget delete the stack.

Useful commands

  • npm run build compile typescript to js
  • npm run watch watch for changes and compile
  • npm run test perform the jest unit tests
  • cdk deploy deploy this stack to your default AWS account/region
  • cdk diff compare deployed stack with current state
  • cdk synth emits the synthesized CloudFormation template

About

Serverless Integration Testing with step functions using CDK Pipelines

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published