Skip to content

script to automatically create vars.json to run sam local invoke

License

Notifications You must be signed in to change notification settings

valeriosalvucci/samvars

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

samvars: SAM vars.json Generator

Overview

This script, in python or bash, generates vars.json, a file used when testing locally your lambda function running:

sam local invoke MyLambdaFunction --env-vars vars.json

vars.json contains the environment variables used by Lambda functions. The structure is as follows:

{
  "LambdaFunctionName1": {
    "VariableName1": "VariableValue1",
    "VariableName2": "VariableValue2",
    ...
  },
  "LambdaFunctionName2": {
    "VariableName1": "VariableValue1",
    "VariableName2": "VariableValue2",
    ...
  },
  ...
}

Installation

Clone the repository to your local machine:

git clone https://github.com/valeriosalvucci/samvars.git

Ensure that

  1. Your AWS CLI is configured with the necessary credentials
  2. The cloludformation is deployed. samvars gets the parameter value from the deployed cloudformation.

How to use

Python version

Requirements

  • Python 3.x
  • AWS CLI configured with the necessary credentials
  • boto3, toml

Install the required dependencies:

pip install -r requirements.txt
sam-app$ python samvars.py [ --stack-name YourCloudFormationStackName ]

Bash version

Run the script by executing the following command:

sam-app$ sh samvars.sh [ --stack-name YourCloudFormationStackName ]

If the --stack-name parameter is omitted, the script will attempt to read the CloudFormation stack name from samconfig.toml. If samconfig.toml file is not present or does not contain the necessary information, the script will prompt you to enter the CloudFormation stack name manually.

About

script to automatically create vars.json to run sam local invoke

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published