- Step One: Basic lambdas and getting them deployed
- Step Two: Adding CodePipeline to remove manual deployments
- Step Three: Tips & Tricks
infra
- Deploys lambda with CDKlambdas
- Contains Java lambda functionslayer
- Creates layer for use by the lambdas
- create project structure
- Create a simple java lambda - no input, string output
- Unit test it - find lambda
- deploy it via CDK
- call it from commandline
aws lambda invoke --function-name CoreServicesDEVStack-developmentsimplehandlerD999D-ra3ExXakKWsH --payload '' response.txt
- view
cdk.json
andpom.xml
to see how CDK finds the App to run for deployment
- Introduce
Message
request class - Unittest and deploy
- Test via commandline
aws lambda invoke --function-name CoreServicesDEVStack-developmentmessagehandler6D5F-a9zqbgSRXoiQ --cli-binary-format raw-in-base64-out --payload '{"message": "Hello"}' response.txt
- util/domain classes in layer
- Handler for API Gateway events
- Unittest
- Deploy endpoint via CDK
- Call via
curl
curl https://qaxjj2p7kc.execute-api.eu-west-1.amazonaws.com/development/mypath/myresource
- Check the CloudWatch logs
- Experiment with the event class
- Look at CORS configuration in API Gateway console
- manuallly create api key
- add it and userplan to apigw endpoint
- deploy and test via
x-api-key
header
Note: AWS CDK CLI & Docker is required on your machine to deploy the solution
First time: run cdk bootstrap --profile <your profile>
mvn clean package
- build the solutioncd infra
cdk synth --profile <your profile>
- synth the solutioncdk deploy --profile <your profile>
- deploy the solution
Resources: https://github.com/kolomied/awesome-cdk Intro: https://cdkworkshop.com/50-java/70-advanced-topics/100-pipelines/5000-test-actions.html
JavaCDK Stack example: https://github.com/xerris/poc-javacdk/blob/master/src/main/java/com/myorg/JavaCdkStack.java
JavaDocs for AWS CDK lib: https://docs.aws.amazon.com/cdk/api/v2/java/index.html?software/amazon/awscdk/services/codepipeline/actions/ManualApprovalAction.html ` AWS CDK Activate workshop: https://catalog.us-east-1.prod.workshops.aws/v2/workshops/13304db2-f715-48bf-ada0-92e5c4eea945/