Description:
Using new Provisioned Concurrency capabilities without a DeploymentPreference Property causes a failed update (and consequent failed update rollback) on the second deployment.
I don't think it's an issue with SAM persay - just that it needs to be checked for, and the documentation needs to be updated, i.e. the Release note for v1.18.0 will cause a failed update (and failed rollback) on second deployment. Potentially also add a comment on this table in the bottom 2 rows: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#properties ?
Steps to reproduce the issue:
ProvisionedConcurrencyConfig property, but without a DeploymentPreference property. This deploys succesfully and works as expected. I reproduced this using this hello world project: https://github.com/jcts3/sam-pc-experiment/blob/master/template.yaml
Observed result:
Function Alias fails to update.
Alias with weights can not be used with Provisioned Concurrency (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: 15023437-6d75-40d3-ae4c-313691fcf174)
Invalid function version 1. Function version 1 is already included in routing configuration. (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: 92ee7215-037c-417f-8874-0f024bc8022f)
I think what's happening is the alias is trying to shift from version 1to version 2 of the function, but the provisioned concurrency isn't allowing it to do this by itself (i.e. without CodeDeploy managing the change).
Expected result:
Update to not fail. Alias to switch between versions.
OR
First deployment to not succeed due to it missing a required property
Proposed Fix
Update docs to reflect requirement of DeploymentPreference property when using ProvisionedConcurrencyConfig property.
Update pre-deployment checks to prevent deployment without DeploymentPreference when using ProvisionedConcurrencyConfig property.
@jcts3 thanks for reporting this issue! This is such a helpful issue description. I could reproduce it on my end. I am reaching out to the right people, meanwhile, I agree with you on updating the docs. I don't think we should add a pre-deployment check yet, but let me investigate further and get back to you.
I was having this same problem and here is a workaround that worked for me until this is fixed:
AutoPublishAlias: live
ProvisionedConcurrencyConfig:
ProvisionedConcurrentExecutions: 1
DeploymentPreference:
Type: AllAtOnce
Should have the same behavior as if the DeploymentPreference wasn't there.
I noticed another issue: ProvisionedConcurrency will not be deployed successfully in below steps:
But if you add AutoPublishAlias, ProvisionedConcurrencyConfig, and DeploymentPreference at the same time, it works.
Unable to run SAM (v 0.34.0) locally using sam local start-api --port 3030 --skip-pull-image when including the below in template file. Works in production and not locally.
AutoPublishAlias: live
ProvisionedConcurrencyConfig:
ProvisionedConcurrentExecutions: 5
DeploymentPreference:
Type: AllAtOnce
Error: [InvalidResourceException('Index', 'property ProvisionedConcurrencyConfig not defined for resource of type AWS::Serverless::Function')] ('Index', 'property ProvisionedConcurrencyConfig not defined for resource of type AWS::Serverless::Function')
Unable to run SAM (v 0.34.0) locally using
sam local start-api --port 3030 --skip-pull-imagewhen including the below in template file. Works in production and not locally.AutoPublishAlias: live ProvisionedConcurrencyConfig: ProvisionedConcurrentExecutions: 5 DeploymentPreference: Type: AllAtOnceError: [InvalidResourceException('Index', 'property ProvisionedConcurrencyConfig not defined for resource of type AWS::Serverless::Function')] ('Index', 'property ProvisionedConcurrencyConfig not defined for resource of type AWS::Serverless::Function')
Can you update your sam-cli to the latest version?
Most helpful comment
I was having this same problem and here is a workaround that worked for me until this is fixed:
Should have the same behavior as if the DeploymentPreference wasn't there.