Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cloudformation deploy fails if new parameters are not overridden even if they have default value #2599

Closed
kskory opened this issue May 12, 2017 · 22 comments · Fixed by #2659
Closed
Labels
bug This issue is a bug. cloudformation package-deploy customization Issues related to CLI customizations (located in /awscli/customizations)

Comments

@kskory
Copy link

kskory commented May 12, 2017

After adding new parameters to the template, it has to be deployed with --parameters-override for all the new parameters even if they have default value, otherwise deploy fails with:

An error occurred (ValidationError) when calling the CreateChangeSet operation: Invalid input for parameter key Param2. Cannot specify usePreviousValue as true for a parameter key not in the previous template

To reproduce, deploy simple template:

AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: A hello world application.
Parameters:
  Param1:
    Default: 123
    Type: String
Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs4.3
      CodeUri: ./hello.zip

add some parameter to it:

...
Parameters:
  Param1:
    Default: 123
    Type: String
  Param2:
    Default: 123
    Type: String
...

Try to deploy again, it fails with aforementioned error.

@JordonPhillips
Copy link
Member

Thanks for the report, this seems to be related to a previous bugfix: #2573

@prokilogrammer
Copy link

Its not a regression to previous bugfix, but a new corner case that the code doesn't handle well.

Unfortunately, this is a tough one because I need to pull down the latest template from stack, parse parameters, diff with the new template and merge current-template, new-template and overrides to come up with list of accurate UsePreviousValues. For the majority use-case, this extra call is unnecessary.

Potential fix would be to use get-template-summary call instead of describe-stacks to check presence of stack AND fetch parameter information.

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

@ffxsam
Copy link

ffxsam commented Sep 5, 2017

This is still an issue as of awscli version 1.11.146.

@billnbell
Copy link

Just say you are adding ServiceCount, do it this way:

aws cloudformation deploy --template-file ./build/cfn-package.yml --stack-name dev-v2 --region us-west-2 --capabilities CAPABILITY_NAMED_IAM CAPABILITY_IAM --parameter-overrides ServiceCount=1

@btisdall
Copy link

In the modern world of infrastructure creates/updates happening via CI or some other automation one-time hacks to put the new parameter there really don't cut it.

@mga226
Copy link

mga226 commented Oct 17, 2017

Just adding another voice here.

This isn't a "corner case." The way this currently works doesn't play nice with CI at all, and it's something I have to hack around with manual workarounds on a regular basis. Using the default if no previous value exists should be the expected behavior.

@btisdall
Copy link

btisdall commented Nov 8, 2017

Shameless plug for #2943 which provides a alternate mode of operation (never re-use stack params because that's a deployment anti-pattern IMO) and thereby avoids this problem. I realise this won't be satisfactory for everyone but I thought I'd mention it.

@billnbell
Copy link

btisdall: this is not the same thing. I agree that we should not re-use stack params, but the default should work, and we should not have to override them.

@ffxsam
Copy link

ffxsam commented Nov 8, 2017

I actually disagree. I think reusing params is extremely handy. No way would I want to have to specify every single parameter every time I wanted to re-deploy. Sure, in a CI/CD environment that would probably make sense. But often times I'm running build & deploy from the command line.

@dgcgh
Copy link

dgcgh commented Nov 8, 2017

In particular when doing stack updates, where you might not be aware of all the parameters that were set at creation time. We currently have scripts for updates which pull all of the original parameters from the stack and then override the ones we're changing to prevent things like regression to defaults, but it would be nice to not have to do that.

Also because of the behavior cited here adding a parameter to a stack means breaking any code/procedure/deployment that does not know about the new parameter. That would make sense if the parameter did not have a default, but that's what defaults are supposed to do: make a selection when none is provided by the user.

@btisdall
Copy link

btisdall commented Nov 8, 2017

@billnbell and others: I'm fully aware it's not the same thing, I thought my comment made this clear. I absolutely agree that new template params with a default should just work with the command as it is. And I don't deny parameter re-use is handy, I just happen to think it's a bad choice for some situations because you're effectively pushing your infrastructure configuration out of code into a remote system.

@larryboymi
Copy link

👍 Any news on this?

@ldm314
Copy link

ldm314 commented Jan 9, 2018

Ran into this same issue today.

@libert-xyz
Copy link

same issue here, any updates?

@foxx
Copy link

foxx commented Jan 20, 2018

Same problem here :/

stealthycoin added a commit that referenced this issue Jan 23, 2018
…ters

don't set UsePreviousValue if parameters doesn't exist (fixes #2599)
awstools added a commit that referenced this issue Jan 25, 2018
* release-1.14.31:
  Bumping version to 1.14.31
  Update changelog based on model updates
  Fixing broken test caused by a merge of PR #2659
  Removing stray print statement
  CloudFormation deploy tags should be in key=value format
  Fix tests
  fix error where tags are not being passed to create_change_set
  updated tests to handle new parameter
  Updated example command to include new tag argument
  Added Cfn stack tag support to the deploy command
  don't set UsePreviousValue if parameters doesn't exist (fixes #2599)
@ericzbeard
Copy link

This is still an issue with Cloud9 Lambda functions. It's not possible to add a parameter to the SAM template file. And the click-to-deploy functionality does not offer a way to fix it via the command line.

bbuechler added a commit to asfadmin/thin-egress-app that referenced this issue May 21, 2019
aws/aws-cli#2599

we can remove these lines later.
@aws-adjustmentbureau
Copy link

bug has still not been fixed on aws cli

@oxsannikova
Copy link

Have same issue with aws cli and Lambda.

@smyja
Copy link

smyja commented Apr 13, 2020

same issues

@kdaily kdaily added the customization Issues related to CLI customizations (located in /awscli/customizations) label Nov 12, 2020
@mynamerahulkumar
Copy link

An error occurred (ValidationError) when calling the CreateStack operation: Parameters: [PrivateSubnet1CIDR, PublicSubnet2CIDR, PrivateSubnet2CIDR, PublicSubnet1CIDR] do not exist in the template
My solution-I have not proper indentation after proper indentation it works

@jackos
Copy link

jackos commented Feb 17, 2022

5 years later and same issue

@p10tyr
Copy link

p10tyr commented Oct 31, 2024

Just saying. Still a problem and really annoying me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. cloudformation package-deploy customization Issues related to CLI customizations (located in /awscli/customizations)
Projects
None yet
Development

Successfully merging a pull request may close this issue.