sam-cdk
v1.0.1
Published
Extract environment variables from Lambda functions for use with SAM CLI.
Downloads
6
Readme
SAM CDK
Extract environment variables from Lambda functions for use with SAM CLI.
Usage
sam-cdk
wraps sam
CLI. All sam
CLI options can be passed to sam-cdk
. The only difference is that sam-cdk
needs a stack name to lookup Lambda function environments.
sam-cdk COMMAND --stack STACK_NAME --template TEMPLATE [...SAM_CLI_OPTIONS]
sam-cdk environment
The sam-cdk environment
command creates a file that can be used as env-vars
option to the SAM CLI. The command looks for all the Lambda functions in the given template. The environment variables of those Lambda functions are loaded from the stack with the given stack name and stored in the given output file.
sam-cdk environment --stack STACK_NAME --template ./cdk.out/stack.template.json --output ./environment.json
sam --template ./cdk.out/stack.template.json --env-vars ./environment.json
sam-cdk local start-api
The sam-cdk local start-api
command invokes the corresponding SAM CLI sam local start-api
command and automatically includes the env-vars
as described above.
sam-cdk local start-api --stack STACK_NAME --template ./cdk.out/stack.template.json [...SAM_CLI_OPTIONS]
sam-cdk local start-lambda
The sam-cdk local start-lambda
command invokes the corresponding SAM CLI sam local start-lambda
command and automatically includes the env-vars
as described above.
sam-cdk local start-lambda --stack STACK_NAME --template ./cdk.out/stack.template.json [...SAM_CLI_OPTIONS]
sam-cdk invoke
The sam-cdk invoke
command invokes the corresponding SAM CLI sam local invoke
command and automatically includes the env-vars
as described above.
sam-cdk local invoke FunctionName --stack STACK_NAME --template ./cdk.out/stack.template.json [...SAM_CLI_OPTIONS]
Permissions
sam-cdk
is using AWS SDK to lookup Lambda function environments. Make sure you are using an IAM role or user that can describe CloudFormation stack resources and get Lambda function configuration.
Notes
CDK
This tool works great with CDK.
Your CDK stack has to be deployed before using this tool.
Make sure to synthesize your CDK application using the --no-staging
option. CDK then adds metadata aws:asset:path
pointing to your local code for every Lambda function in the synthesized template.
cdk synth --quiet --no-staging
Environment Changes
Author
Gillis Van Ginderachter
License
GNU General Public License v3.0