install
brew install awscli
brew install aws-cdk
brew tap aws/tap
brew install aws-sam-cli
Using colima?
Error: Running AWS SAM projects locally requires Docker. Have you got it installed and running?
Enable AWS SAM local to run without Docker Desktop but Colima + Docker Daemon on MacOs
# aws sam requires DOCKER_HOST to be set
export DOCKER_HOST="unix://$HOME/.colima/docker.sock"
Test lambda
cdk synth --no-staging
sam local invoke helloLambdaNodeJs --no-event -t ./cdk.out/*.template.json
Start lambda
cdk synth --no-staging
sam local start-api -t ./cdk.out/*.template.json
Start api with all lambdas
cdk synth --no-staging
sam local start-api -t ./cdk.out/*.template.json
(src: Locally testing AWS CDK applications - AWS Serverless Application Model & Getting started with AWS SAM and the AWS CDK - AWS Serverless Application Model)
Fix “AuthorizationHeaderMalformed”
{
"errorType": "AuthorizationHeaderMalformed",
"errorMessage": "The authorization header is malformed; the Credential is mal-formed; expecting \"<YOUR-AKID>/YYYYMMDD/REGION/SERVICE/aws4_request\".",
"trace": [
"AuthorizationHeaderMalformed: The authorization header is malformed; the Credential is mal-formed; expecting \"<YOUR-AKID>/YYYYMMDD/REGION/SERVICE/aws4_request\".",
" at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/services/s3.js:710:35)",
" at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20)",
" at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:78:10)",
" at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:686:14)",
" at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)",
" at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)",
" at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10",
" at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)",
" at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:688:12)",
" at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:116:18)"
]
}
fixed by making sure some form of credentials are set
- aws credentials - don’t store plaintext
- or
- aws configure