Serverless-application-model: Provisioned Concurrency without DeploymentPreference causes failure on second deployment

Created on 5 Dec 2019  路  5Comments  路  Source: aws/serverless-application-model

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:

  1. Deploy a lambda with appropriate ProvisionedConcurrencyConfig property, but without a DeploymentPreference property. This deploys succesfully and works as expected.
  2. Make any change to the lambda (e.g. just add a '!' to the hello world message)
  3. Build and deploy again.

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.

Most helpful comment

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.

All 5 comments

@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:

  1. you deploy your lambda function without any version/alias enabled, and also no ProvisionedConcurrencyConfig and DeploymentPreference.
  2. in your SAM template introduce "AutoPublishAlias: live", and deploy this SAM
  3. introduce ProvisionedConcurrencyConfig together with "DeploymentPreference: Type: AllAtOnce", the ProvisionedConcurrencyConfig is not deployed successfully.

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-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')

Can you update your sam-cli to the latest version?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

polovi picture polovi  路  3Comments

kwcrook picture kwcrook  路  3Comments

MaxVynohradov picture MaxVynohradov  路  3Comments

restfulhead picture restfulhead  路  4Comments

patrickli picture patrickli  路  4Comments