The CI/CD pipeline for the AWS Greengrass The Things Stack LoRaWAN component is a TypeScript CDK application that deploys a CodePipeline pipeline.
The pipeline consists of three stages: build, deploy and test. The build stage creates a new component version, the deploy stage deploys that version to the Greengrass Edge runtime and the test stage performs system-level smoke tests to ensure that The Things Stack has started up correctly.
Source code is obtained from CodeCommit in the same region as what the pipeline is deployed. Therefore it's necessary to clone the code to a CodeCommit repository. Alternatively you can modify the pipeline to obtain the source code from a different repository.
The pipeline automatically increments the component version number by assigning the build stage CodeBuild build number as the patch revision of the major.minor.patch version. Major and minor revision updates are achieved by changing buildspec.yml.
The test stage does not modify The Things Stack databases and therefore the pipeline is generally appropriate for DEV, TEST and PROD environments. Testing is performed with the help of Robot Framework, with logs stored as build artifacts and JUnit compatible reports in CodeBuild.
The pipeline publishes success or failure notifications to an SNS topic.
Follow the Getting started with the AWS SDK guide (for Typescript) to install CDK and bootstrap your environment.
Compile TypeScript to JS.
npm run build
Uses the Jest framework.
npm run test
Synthesis and deployment of the stack requires the following context variables:
Name | Description |
---|---|
RepositoryName | The name of the CodeCommit repository containing the component's source code. |
BranchName | The name of the branch to use within the CodeCommit repository. |
GreengrassCoreName | The name of the Greengrass Core device that the component shall be deployed to. |
Example synthesis:
cdk synth -c RepositoryName=aws-greengrass-labs-component-for-the-things-stack-lorawan -c BranchName=main -c GreengrassCoreName=raspberrypi4-ggv2
Example deployment:
cdk deploy -c RepositoryName=aws-greengrass-labs-component-for-the-things-stack-lorawan -c BranchName=main -c GreengrassCoreName=raspberrypi4-ggv2