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

Bug: Change Parameter's Default value doesn't reflect #7103

Closed
siosphere opened this issue May 26, 2024 · 6 comments
Closed

Bug: Change Parameter's Default value doesn't reflect #7103

siosphere opened this issue May 26, 2024 · 6 comments
Labels
area/deploy sam deploy command type/bug

Comments

@siosphere
Copy link

Description:

I am using AWS SAM to deploy my entire stack. Everything is codified within the yaml, and I use parameters for setting values of environment variables:

Parameters:
    MyParam:
        Type: String
        Default: foobar

It is being used within the yaml like:

Globals:
  Function:
    Environment:
        Variables:
          MY_PARAM: 
            Ref: MyParam

The Default value for this used to be bar but I updated it.

My deploy command does not use parameter-overrides for dev, only for production, so the default value is what should be used.

Upon deploying however, the old value (bar) is used. Even when I create new lambdas that have never been made before, the configuration will be the old value, which does not exist at all within my codebase anymore.

If I manually adjust the configuration of that env var in the aws console, it will revert to this old value the next time I deploy.

I would expect the updated Default value to be used if I am not overriding the value, otherwise whatever value I put in there first is used forever unless I override it, and that isn't very intuitive.

Steps to reproduce:

Configure an environment variable that references a param with a default value. Change the default value and make a new lambda, and it will get the old param value.

Observed result:

MY_PARAM | bar

Expected result:

MY_PARAM | foobar

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

{
  "version": "1.115.0",
  "system": {
    "python": "3.12.3",
    "os": "macOS-14.5-arm64-arm-64bit"
  },
  "additional_dependencies": {
    "docker_engine": "20.10.13",
    "aws_cdk": "Not available",
    "terraform": "1.2.9"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}

Add --debug flag to command you are running

@siosphere siosphere added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label May 26, 2024
@jysheng123
Copy link
Contributor

jysheng123 commented May 29, 2024

Hi, thanks for bringing up the issue. For clarity's sake, are you using sam deploy to deploy your application, or is the only time you are using SAM is for creating the template? There is another repo for AWS SAM specifically, what kind of commands are you running to build/deploy?

@siosphere
Copy link
Author

I am using sam deploy to deploy the application
Technically it runs:

sam build
sam deploy --stack-name=...

@jysheng123 jysheng123 added area/deploy sam deploy command type/bug and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels May 30, 2024
@jysheng123
Copy link
Contributor

Hey thanks for the response, after investigating it seems to be a bug on our side, we currently use previous values for parameters if they are present in the existing template already, regardless if the value is actually changed or not. Will mark it as a bug so the team can work on a fix. In the meantime as a workaround, when you deploy can you run the --parameter-overrides flag? Alternatively if you don't want to pass in that flag every time, deploying the stack once without the parameter should update the next deployment to have the new parameter value in it

@siosphere
Copy link
Author

Thanks, I did write a deployment script to pass in the --parameter-overrides which has been working, but occasionally I'll add a parameter, deploy, forget to add the override, change the default, and run into this again, so the fix will be appreciated eventually!

Thank you

@mildaniel
Copy link
Contributor

We've had similar discussions in the past about this scenario. In short, this is behaviour we adopt from CloudFormation. The linked ticket has more detail. I'm going to close this issue in favour of the previous.

#4180

Copy link
Contributor

github-actions bot commented Jul 8, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/deploy sam deploy command type/bug
Projects
None yet
Development

No branches or pull requests

3 participants