This is an example of using the AuthenticatedApi to create two example API's one authenticated and one not.
The AuthenticatedApi:
- creates an ApiGateway (v2)
- creates an authorisation lambda which authenticates tokens against persona
- creates any number of routes, each with a lambda to handle requests.
- creates any number of routes redirecting to a given url(s).
- allows authentication to be configured either on all routes or on individual routes
- triggers an alarm if the response time on any route in the api exceeds a configurable duration
- triggers an alarm if the duration of a lambda dealing with the api requests exceeds a configurable duration
To build and deploy this example:
export AWS_PREFIX=development-XX-
where XX are your initials- This is used in the name of the stack and resources created, so that they do not clash with anyone elses stack in AWS
source awsenv <profile>
to set your credentials to the shared accountnpm install
npm run build
cdk deploy
After you have finished with the example, remove your stack in AWS using:
cdk destroy
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit testscdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk synth
emits the synthesized CloudFormation template