A REST echo server used for the Nordic Developer Academy developed using AWS CDK in TypeScript.
Install the dependencies:
npm ci
Configure the metrics for Azure Monitor logs ingestion (used for usage metrics tracking):
aws ssm put-parameter --name /${STACK_NAME:-rest-echo}/metrics/endpoint --type String --value "<endpoint>"
aws ssm put-parameter --name /${STACK_NAME:-rest-echo}/metrics/dcrId --type String --value "<dcrId>"
aws ssm put-parameter --name /${STACK_NAME:-rest-echo}/metrics/streamName --type String --value "<streamName>"
aws ssm put-parameter --name /${STACK_NAME:-rest-echo}/metrics/secret --type SecureString --value "<secret>"
npx cdk bootstrap # if this is the first time you use CDK in this account
npx cdk deploy
Once the API is deployed, you can interact with it as documented here.
Both non-secure HTTP and secure HTTPs are supported.
Create a GitHub environment production
.
Store the role used for continuous deployment as a secret:
CD_ROLE_ARN=`aws cloudformation describe-stacks --stack-name ${STACK_NAME:-rest-echo} | jq -r '.Stacks[0].Outputs[] | select(.OutputKey == "cdRoleArn") | .OutputValue'`
gh secret set AWS_ROLE --env production --body "${CD_ROLE_ARN}"
Store the stack name and the region as a variable:
gh variable set STACK_NAME --env production --body "${STACK_NAME:-rest-echo}"
gh variable set AWS_REGION --env production --body "${AWS_REGION}"
Optionally, if you are using a custom domain name, store the domain name and the AWS certificate ID:
gh variable set DOMAIN_NAMES --env production --body "rest.nordicsemi.academy,echo.thingy.rocks"
gh variable set CERTIFICATE_ID --env production --body "ff6dc724-ac8d-4328-8f86-628126771d67"
We use bifravst/ci to set up resources and permissions for continuous integration.