Description
In my AWS::Serverless::Function Environment section, I have the Parameter referenced.
When the parameter value changes and I run sam deploy, a new Lambda version is not created.
Steps to reproduce
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
TestParameter:
Type: String
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello_world/
Handler: app.lambda_handler
Environment:
Variables:
TEST_PARAMETER: !Ref TestParameter
AutoPublishAlias: live
AutoPublishAliasAllProperties: true
Runtime: python3.12
Architectures:
- x86_64
sam build --template-file template.yaml --parameter-overrides TestParameter='3'
sam deploy --config-file samconfig.toml --template-file template.yaml --debug --parameter-overrides TestParameter='3'
Observed result
No new Lambda version is created
2025-09-30 19:30:57,747 | Config file location: .../LambdaVersions/samconfig.toml
2025-09-30 19:30:57,748 | Loading configuration values from [default.['deploy'].parameters] (env.command_name.section) in config file at '.../LambdaVersions/samconfig.toml'...
2025-09-30 19:30:57,748 | Configuration values successfully loaded.
2025-09-30 19:30:57,749 | Configuration values are: {'stack_name': 'LambdaVersions', 'template': 'template.yaml', 'capabilities':
'CAPABILITY_IAM', 'confirm_changeset': True, 'no_resolve_s3': True, 's3_bucket': '...', 's3-prefix': '...'}
2025-09-30 19:30:57,763 | Using config file: samconfig.toml, config environment: default
2025-09-30 19:30:57,764 | Expand command line arguments to:
2025-09-30 19:30:57,764 | --template_file=.../LambdaVersions/template.yaml
--parameter_overrides={'TestParameter': '3'} --fail_on_empty_changeset --confirm_changeset --on_failure=ROLLBACK --max_wait_duration=60
--stack_name=LambdaVersions --s3_bucket=... --capabilities=['CAPABILITY_IAM']
2025-09-30 19:30:57,858 | Collected default values for parameters: {}
2025-09-30 19:30:57,866 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource
logical id as the resource id
2025-09-30 19:30:57,866 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource
logical id as the resource id
2025-09-30 19:30:57,866 | 0 stacks found in the template
2025-09-30 19:30:57,867 | Collected default values for parameters: {}
2025-09-30 19:30:57,872 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource
logical id as the resource id
2025-09-30 19:30:57,873 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource
logical id as the resource id
2025-09-30 19:30:57,947 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource
logical id as the resource id
2025-09-30 19:30:57,947 | Sam customer defined id is more priority than other IDs. Customer defined id for resource HelloWorldFunction is
HelloWorldFunction
2025-09-30 19:30:58,439 |
File with same data already exists at ..., skipping upload
Deploying with following values
===============================
Stack name : LambdaVersions
Region :...
Confirm changeset : True
Disable rollback : False
Deployment s3 bucket :...
Capabilities : ["CAPABILITY_IAM"]
Parameter overrides : {"TestParameter": "3"}
Signing Profiles : {}
Initiating deployment
=====================
2025-09-30 19:30:58,466 | Collected default values for parameters: {}
2025-09-30 19:30:58,476 | Sam customer defined id is more priority than other IDs. Customer defined id for resource HelloWorldFunction is
HelloWorldFunction
2025-09-30 19:30:58,477 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource
logical id as the resource id
2025-09-30 19:30:58,477 | 0 stacks found in the template
2025-09-30 19:30:58,477 | Collected default values for parameters: {}
2025-09-30 19:30:58,486 | Sam customer defined id is more priority than other IDs. Customer defined id for resource HelloWorldFunction is
HelloWorldFunction
2025-09-30 19:30:58,486 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource
logical id as the resource id
2025-09-30 19:30:58,487 | 2 resources found in the stack
2025-09-30 19:30:59,741 |
File with same data already exists at ....template, skipping upload
Waiting for changeset to be created..
CloudFormation stack changeset
-------------------------------------------------------------------------------------------------------------------------------------
Operation LogicalResourceId ResourceType Replacement
-------------------------------------------------------------------------------------------------------------------------------------
* Modify HelloWorldFunction AWS::Lambda::Function False
-------------------------------------------------------------------------------------------------------------------------------------
Changeset created successfully. arn:aws:cloudformation:...:...:changeSet/samcli-deploy.../...
Previewing CloudFormation changeset before deployment
======================================================
Expected result
According to AutoPublishAliasAllProperties documentation, the new Lambda version should be created ("When true, a new Lambda version is created when any property in the Lambda function is modified").
Compare to changing the Lambda environment variable value in the template directly:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
TestParameter:
Type: String
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello_world/
Handler: app.lambda_handler
Environment:
Variables:
TEST_PARAMETER: 3
AutoPublishAlias: live
AutoPublishAliasAllProperties: true
Runtime: python3.12
Architectures:
- x86_64
sam build --template-file template.yaml
sam deploy --config-file samconfig.toml --template-file template.yaml --debug
2025-09-30 19:45:50,908 | Config file location: .../LambdaVersions/samconfig.toml
2025-09-30 19:45:50,910 | Loading configuration values from [default.['deploy'].parameters] (env.command_name.section) in config file at '.../LambdaVersions/samconfig.toml'...
2025-09-30 19:45:50,910 | Configuration values successfully loaded.
2025-09-30 19:45:50,910 | Configuration values are: {'stack_name': 'LambdaVersions', 'template': 'template.yaml', 'capabilities':
'CAPABILITY_IAM', 'confirm_changeset': True, 'no_resolve_s3': True, 's3_bucket': '...', 's3-prefix': '.../'}
2025-09-30 19:45:50,924 | Using config file: samconfig.toml, config environment: default
2025-09-30 19:45:50,924 | Expand command line arguments to:
2025-09-30 19:45:50,925 | --template_file=.../LambdaVersions/template.yaml
--fail_on_empty_changeset --confirm_changeset --on_failure=ROLLBACK --max_wait_duration=60 --stack_name=LambdaVersions
--s3_bucket=... --capabilities=['CAPABILITY_IAM']
2025-09-30 19:45:51,016 | Collected default values for parameters: {}
2025-09-30 19:45:51,024 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource
logical id as the resource id
2025-09-30 19:45:51,025 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource
logical id as the resource id
2025-09-30 19:45:51,025 | 0 stacks found in the template
2025-09-30 19:45:51,026 | Collected default values for parameters: {}
2025-09-30 19:45:51,031 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource
logical id as the resource id
2025-09-30 19:45:51,031 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource
logical id as the resource id
2025-09-30 19:45:51,104 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource
logical id as the resource id
2025-09-30 19:45:51,104 | Sam customer defined id is more priority than other IDs. Customer defined id for resource HelloWorldFunction is
HelloWorldFunction
2025-09-30 19:45:51,669 |
File with same data already exists at ..., skipping upload
Deploying with following values
===============================
Stack name : LambdaVersions
Region : ...
Confirm changeset : True
Disable rollback : False
Deployment s3 bucket :...
Capabilities : ["CAPABILITY_IAM"]
Parameter overrides : {}
Signing Profiles : {}
Initiating deployment
=====================
2025-09-30 19:45:51,694 | Collected default values for parameters: {}
2025-09-30 19:45:51,703 | Sam customer defined id is more priority than other IDs. Customer defined id for resource HelloWorldFunction is
HelloWorldFunction
2025-09-30 19:45:51,704 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource
logical id as the resource id
2025-09-30 19:45:51,704 | 0 stacks found in the template
2025-09-30 19:45:51,705 | Collected default values for parameters: {}
2025-09-30 19:45:51,713 | Sam customer defined id is more priority than other IDs. Customer defined id for resource HelloWorldFunction is
HelloWorldFunction
2025-09-30 19:45:51,713 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource
logical id as the resource id
2025-09-30 19:45:51,714 | 2 resources found in the stack
Uploading to ...template 1349 / 1349 (100.00%)
Waiting for changeset to be created..
CloudFormation stack changeset
-------------------------------------------------------------------------------------------------------------------------------------
Operation LogicalResourceId ResourceType Replacement
-------------------------------------------------------------------------------------------------------------------------------------
+ Add HelloWorldFunctionVersionfd... AWS::Lambda::Version N/A
* Modify HelloWorldFunctionAliaslive AWS::Lambda::Alias False
* Modify HelloWorldFunction AWS::Lambda::Function False
- Delete HelloWorldFunctionVersion... AWS::Lambda::Version N/A
-------------------------------------------------------------------------------------------------------------------------------------
Changeset created successfully. arn:aws:cloudformation...:...:changeSet/samcli-deploy.../...
Previewing CloudFormation changeset before deployment
======================================================
Additional environment details
- OS: macOS 15.6.1
- If using the SAM CLI,
sam --version: SAM CLI, version 1.144.0
- AWS region: eu-central-1
Description
In my AWS::Serverless::Function Environment section, I have the Parameter referenced.
When the parameter value changes and I run sam deploy, a new Lambda version is not created.
Steps to reproduce
Observed result
No new Lambda version is created
Expected result
According to AutoPublishAliasAllProperties documentation, the new Lambda version should be created ("When true, a new Lambda version is created when any property in the Lambda function is modified").
Compare to changing the Lambda environment variable value in the template directly:
sam build --template-file template.yamlAdditional environment details
sam --version: SAM CLI, version 1.144.0