I read issues #400 and #456 and it looks like --parameter-values or --parameter-overrides are no longer supported for sam local invoke command. The ability to pass on parameters to a SAM Template when running locally is critical to test the behavior of the lambda function when deployed remotely.
Will --parameter-values or --parameter-overrides be supported for 'sam local invoke' command in future releases?
+1 for this feature. It's really helpful in local testing.
Closing. Was released with 0.6.1
SAM CLI --parameter-overrides doesn't use the same format as AWS CLI
$ aws cloudformation deploy help
--parameter-overrides (list) A list of parameter structures that spec-
ify input parameters for your stack template. If you're updating a
stack and you don't specify a parameter, the command uses the stack's
existing value. For new stacks, you must specify parameters that don't
have a default value. Syntax: ParameterKey1=ParameterValue1 Parame-
terKey2=ParameterValue2 ...
Syntax:
"string" "string" ...
$ sam local start-api --help
--parameter-overrides Optional. A string that contains
CloudFormation parameter overrides encoded
as key=value pairs. Use the same format as
the AWS CLI, e.g. 'ParameterKey=KeyPairName,
ParameterValue=MyKey ParameterKey=InstanceTy
pe,ParameterValue=t1.micro'
Users gets the following error while using aws cloudformation deploy format:
Error: Invalid value for "--parameter-overrides": ParameterKey1=ParameterValue1 is not in valid format. It must look something like 'ParameterKey=KeyPairName,ParameterValue=MyKey ParameterKey=InstanceType,ParameterValue=t1.micro'
Using sam local start-api --parameter-overrides Environment=dev throws:
Error: Invalid value for "--parameter-overrides": Environment=dev is not in valid format. It must look something like 'ParameterKey=KeyPairName,ParameterValue=MyKey ParameterKey=InstanceType,ParameterValue=t1.micro'
@guijob The way you are specifying them are incorrect.
sam local start-api --parameter-overrides ParameterKey=Environment,ParameterValue=dev
@jfuss How override multi parameters ?
@pmayet You can override multiple parameters by using quotes.
Example:
--parameter-overrides "ParameterKey=Key1,ParameterValue=value1 ParameterKey=Key2,ParameterValue=value2"
Most helpful comment
SAM CLI --parameter-overrides doesn't use the same format as AWS CLI
$ aws cloudformation deploy help
$ sam local start-api --help
Users gets the following error while using
aws cloudformation deployformat:Error: Invalid value for "--parameter-overrides": ParameterKey1=ParameterValue1 is not in valid format. It must look something like 'ParameterKey=KeyPairName,ParameterValue=MyKey ParameterKey=InstanceType,ParameterValue=t1.micro'