3. Deployment
We use the AWS CDK for deployment. With the help of the CDK, we can programmatically create an AWS CloudFormation template. Using this template, AWS CloudFormation automatically creates all the necessary resources and automatically uploads the source code.
The AWS CDK can be used with different programming languages. As our source code is written in Go, we also use Go for the CDK.
Necessary tools
- A fully set-up development environment
- AWS CDK (Automatically pre-installed in the development environment)
The CDK source code is located in the folder (deployment)[../deployment].
The stages and the corresponding domains to be deployed to are defined in file (stage.go)[../deployment/stage/stage.go]. If you want to deploy to an additional stage, you only need to insert the additional stage at this point.
GitHub Deployment
We recommend deployment via the GitHub pipeline, as all the necessary secrets are stored here. You can find the GitHub pipeline here.
Manual Deployment
For the deployment from the local PC, you must set the environment variables KATAPP_TOKEN_SECRET, KATAPP_DOMAIN_CERT and KATAPP_API_GATEWAY_CERT.
The following commands can be used for the initial deployment or the update of a deployment.
Before deployment, make sure that the necessary endpoints and swagger documentation have been created by the automatic code generation. You can find information on this here.
# move to the deployment folder
cd deployment/
# deploy or update specific stage
cdk deploy <StageName>
# or deploy or update all stages
cdk deploy --all
Manual Removal
If the deployment should be removed from AWS, the following commands can be used.
!!! Please note that all data will be deleted !!!
# move to the deployment folder
cd deployment/
# remove specific stage
cdk destroy <StageName>
# or remove all stages
cdk destroy --all
Automatic Deployment and Removal using VsCode Tasks
For easier handling, the VsCode task “CDK: Deploy” and “CDK: Destroy” is available for deployment and the removal of a stage. You can select the task under “Terminal” -> “Run Task”.
After selecting Deploy or Destroy, the stage is automatically queried.