Had some trouble finding info on this, but I'm getting a validation error, when I supply a Parameter to the SAM template:
aws cloudformation deploy --template-file template.yaml --stack-name stack2 --capabilities CAPABILITY_IAM
An error occurred (ValidationError) when calling the CreateChangeSet operation: Cannot specify UsePreviousValue on Parameters when ChangeSetType is CREATE
When I comment the Parameters, it creates fine.
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
AWS SAM template with API defined for Application. Swagger yaml included for API
Parameters:
EnvParameter:
Type: String
Default: prod
Description: Enter string for environment label of this deployment stack.
*I currently have no references to the parameter in my template for testing.
That's a known bug. When you add a default value to a parameter, deploy command doesn't pass it to CloudFormation. Try adding --parameters EnvParameter=prod to the command until this bug is fixed
That works. The following yaml and CLI command worked for providing the parameters:
Parameters:
EnvParameter:
Type: String
aws cloudformation deploy --template-file template.yaml --stack-name stack2 --parameter-overrides EnvParameter=prod --capabilities CAPABILITY_IAM --profile sandbox
Is there any update on when this may be fixed?
This is already fixed. https://github.com/aws/aws-cli/pull/2360
@sanathkr Just upgraded to the most recent version, still running into this issue.
This is still an issue. Deploying a SAM template with aws cloudformation deploy throws the following exception:
An error occurred (ValidationError) when calling the CreateChangeSet operation: Cannot specify UsePreviousValue on Parameters when ChangeSetType is CREATE
The suggested fix of adding a default parameter does not work. Is there a work around?
@bgenchel, @sbrickner you are probably running into aws/aws-cli#2599 - which happens when you create stack for very first time.
Until we fix this bug, you can override the parameter explicitly when you add a new parameter with default value. Just once when you first update the stack. Afterwards, UsePreviousValue should work as expected
For me, --parameters didn't work. I used --parameter-overrides. Im fairly new to AWS, so maybe AWS updated? Since this post was from Dec 2016.
Also, I got this issue when updating a stack. I'm on aws-cli 1.15.55, which I believe is the latest version. It worked after I added a --parameter-overrides flag.
Most helpful comment
@sanathkr Just upgraded to the most recent version, still running into this issue.