Repository navigation
Closed
Description
When adding the reservedConcurrency property to the serverless.yml file for an existing function (previously deployed using the same serverless configuration, minus the property), you receive an error similar to "A version for this Lambda function exists ( 4 ). Modify the function to create a new version."
serverless.yml
Initial deployment (works fine):
service: func
plugins:
- serverless-plugin-typescript
provider:
name: aws
runtime: nodejs12.x
region: ${opt:region,'us-east-2'}
functions:
func:
handler: handler.handler
environment:
SOME_VALUE: ${ssm:some-parameter-name~true}
events:
- sns: ${env:SNS_TOPIC_ARN}
memorySize: 128Second deployment (fails):
service: func
plugins:
- serverless-plugin-typescript
provider:
name: aws
runtime: nodejs12.x
region: ${opt:region,'us-east-2'}
functions:
func:
handler: handler.handler
environment:
SOME_VALUE: ${ssm:some-parameter-name~true}
events:
- sns: ${env:SNS_TOPIC_ARN}
memorySize: 128
reservedConcurrency: 1sls deploy output
Serverless: Load command interactiveCli
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command config:tabcompletion
Serverless: Load command config:tabcompletion:install
Serverless: Load command config:tabcompletion:uninstall
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command upgrade
Serverless: Load command uninstall
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: Load command output
Serverless: Load command output:get
Serverless: Load command output:list
Serverless: Load command param
Serverless: Load command param:get
Serverless: Load command param:list
Serverless: Load command studio
Serverless: Load command dev
Serverless: [AWS ssm 200 0.142s 0 retries] getParameter({ Name: 'some-parameter-name', WithDecryption: true })
Serverless: Invoke deploy
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: Compiling with Typescript...
handler.ts (4,54): Cannot find module 'aws-lambda' or its corresponding type declarations.
handler.ts (10,41): Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
Type 'undefined' is not assignable to type 'string'.
Serverless: Typescript compiled.
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Invoke aws:package:finalize
Serverless: Invoke aws:common:moveArtifactsToPackage
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:deploy:deploy
Serverless: [AWS cloudformation 200 0.14s 0 retries] describeStacks({ StackName: 'func' })
Serverless: [AWS cloudformation 200 0.123s 0 retries] describeStackResource({
StackName: 'func',
LogicalResourceId: 'ServerlessDeploymentBucket'
})
Serverless: [AWS s3 200 0.131s 0 retries] listObjectsV2({
Bucket: 'func-serverlessdeploymentbucket-1rj34cb43sqtk',
Prefix: 'serverless/func/dev'
})
Serverless: [AWS s3 200 0.114s 0 retries] headObject({
Bucket: 'func-serverlessdeploymentbucket-1rj34cb43sqtk',
Key: 'serverless/func/dev/1591470816226-2020-06-06T19:13:36.226Z/compiled-cloudformation-template.json'
})
Serverless: [AWS s3 200 0.124s 0 retries] headObject({
Bucket: 'func-serverlessdeploymentbucket-1rj34cb43sqtk',
Key: 'serverless/func/dev/1591470816226-2020-06-06T19:13:36.226Z/func.zip'
})
Serverless: [AWS lambda 200 0.119s 0 retries] getFunction({ FunctionName: 'func-func' })
Serverless: [AWS sts 200 0.086s 0 retries] getCallerIdentity({})
Serverless: Uploading CloudFormation file to S3...
Serverless: [AWS s3 200 0.152s 0 retries] putObject({
Body: <Buffer 7b 22 41 57 53 54 65 6d 70 6c 61 74 65 46 6f 72 6d 61 74 56 65 72 73 69 6f 6e 22 3a 22 32 30 31 30 2d 30 39 2d 30 39 22 2c 22 44 65 73 63 72 69 70 74 ... 3337 more bytes>,
Bucket: 'func-serverlessdeploymentbucket-1rj34cb43sqtk',
Key: 'serverless/func/dev/1591470850104-2020-06-06T19:14:10.104Z/compiled-cloudformation-template.json',
ContentType: 'application/json',
Metadata: { filesha256: '6tlzxGOj7dmJdH2M0jLzEGD3umhDsWY3bpP5AibM0q4=' }
})
Serverless: Uploading artifacts...
Serverless: Uploading service func.zip file to S3 (14.1 MB)...
Serverless: [AWS s3 200 0.157s 0 retries] createMultipartUpload({
Bucket: 'func-serverlessdeploymentbucket-1rj34cb43sqtk',
Key: 'serverless/func/dev/1591470850104-2020-06-06T19:14:10.104Z/func.zip',
ContentType: 'application/zip',
Metadata: { filesha256: '2y2TsrMbagLXtAYt6NcmkQG8XhQgwUzyxQlnDFi4rD4=' }
})
Serverless: [AWS s3 200 0.523s 0 retries] uploadPart({
Body: <Buffer 5b a9 91 b2 fc e9 e7 d8 b4 cf 5c 39 1c f1 e5 7d 40 c7 5f 8c f3 46 9f 75 72 e0 e0 53 d3 f6 e5 fd 26 1f 4e ff ec 62 f9 ba 57 56 94 bc 57 5a 6e 00 73 b9 ... 4294239 more bytes>,
ContentLength: 4294289,
PartNumber: 3,
Bucket: 'func-serverlessdeploymentbucket-1rj34cb43sqtk',
Key: 'serverless/func/dev/1591470850104-2020-06-06T19:14:10.104Z/func.zip',
UploadId: '8RgGsXKRMFkVVUtam9DCunBFxBo0eP4lZpAA96oT7esb1smbrSY018sFQamrBDU7FIIijeoy5kPX0WyqG14iH82NF_NAEH_yyZzoFvWduJgKfsKmYQ_wxyjRTLEoSjjTb1tZEGcU7RryRZTwsCQPwn1hoj7nfUK0wyUfvr4NQ1Y-'
})
Serverless: [AWS s3 200 0.556s 0 retries] uploadPart({
Body: <Buffer 7c f5 e7 ff 05 ae 83 fd 48 7e c3 1f cb 69 d4 82 cb e6 cf ff 2b d0 7d 4b 87 4b 37 20 b5 7f 79 05 cf e9 98 31 e6 a3 e7 d8 bb df 7c 43 57 77 c0 6a 6c 8b ... 5242830 more bytes>,
ContentLength: 5242880,
PartNumber: 2,
Bucket: 'func-serverlessdeploymentbucket-1rj34cb43sqtk',
Key: 'serverless/func/dev/1591470850104-2020-06-06T19:14:10.104Z/func.zip',
UploadId: '8RgGsXKRMFkVVUtam9DCunBFxBo0eP4lZpAA96oT7esb1smbrSY018sFQamrBDU7FIIijeoy5kPX0WyqG14iH82NF_NAEH_yyZzoFvWduJgKfsKmYQ_wxyjRTLEoSjjTb1tZEGcU7RryRZTwsCQPwn1hoj7nfUK0wyUfvr4NQ1Y-'
})
Serverless: [AWS s3 200 13s 0 retries] uploadPart({
Body: <Buffer 50 4b 03 04 14 00 08 00 08 00 00 00 21 00 00 00 00 00 00 00 00 00 00 00 00 00 0a 00 00 00 68 61 6e 64 6c 65 72 2e 6a 73 95 57 fb 6f d3 56 14 fe bd 7f ... 5242830 more bytes>,
ContentLength: 5242880,
PartNumber: 1,
Bucket: 'func-serverlessdeploymentbucket-1rj34cb43sqtk',
Key: 'serverless/func/dev/1591470850104-2020-06-06T19:14:10.104Z/func.zip',
UploadId: '8RgGsXKRMFkVVUtam9DCunBFxBo0eP4lZpAA96oT7esb1smbrSY018sFQamrBDU7FIIijeoy5kPX0WyqG14iH82NF_NAEH_yyZzoFvWduJgKfsKmYQ_wxyjRTLEoSjjTb1tZEGcU7RryRZTwsCQPwn1hoj7nfUK0wyUfvr4NQ1Y-'
})
Serverless: [AWS s3 200 0.181s 0 retries] completeMultipartUpload({
MultipartUpload: {
Parts: [
{ ETag: '"1f53ac91fe9ad11b2ed1afa276b2b27f"', PartNumber: 1 },
{ ETag: '"c5b37dd12757d3e4b56a81fb1b21425e"', PartNumber: 2 },
{ ETag: '"7d28e551250b071c6c1c1ca874537b27"', PartNumber: 3 },
[length]: 3
]
},
Bucket: 'func-serverlessdeploymentbucket-1rj34cb43sqtk',
Key: 'serverless/func/dev/1591470850104-2020-06-06T19:14:10.104Z/func.zip',
UploadId: '8RgGsXKRMFkVVUtam9DCunBFxBo0eP4lZpAA96oT7esb1smbrSY018sFQamrBDU7FIIijeoy5kPX0WyqG14iH82NF_NAEH_yyZzoFvWduJgKfsKmYQ_wxyjRTLEoSjjTb1tZEGcU7RryRZTwsCQPwn1hoj7nfUK0wyUfvr4NQ1Y-'
})
Serverless: Validating template...
Serverless: [AWS cloudformation 200 0.45s 0 retries] validateTemplate({
TemplateURL: 'https://s3.amazonaws.com/func-serverlessdeploymentbucket-1rj34cb43sqtk/serverless/func/dev/1591470850104-2020-06-06T19:14:10.104Z/compiled-cloudformation-template.json'
})
Serverless: Updating Stack...
Serverless: [AWS cloudformation 200 0.814s 0 retries] updateStack({
StackName: 'func',
Capabilities: [ 'CAPABILITY_IAM', 'CAPABILITY_NAMED_IAM', [length]: 2 ],
Parameters: [ [length]: 0 ],
TemplateURL: 'https://s3.amazonaws.com/func-serverlessdeploymentbucket-1rj34cb43sqtk/serverless/func/dev/1591470850104-2020-06-06T19:14:10.104Z/compiled-cloudformation-template.json',
Tags: [ { Key: 'STAGE', Value: 'dev' }, [length]: 1 ]
})
Serverless: Checking Stack update progress...
Serverless: [AWS cloudformation 200 0.192s 0 retries] describeStackEvents({
StackName: 'arn:aws:cloudformation:us-east-2:111111111111:stack/func/ae433620-a828-11ea-a71f-0247ef85be9c'
})
...Serverless: [AWS cloudformation 200 0.173s 0 retries] describeStackEvents({
StackName: 'arn:aws:cloudformation:us-east-2:111111111111:stack/func/ae433620-a828-11ea-a71f-0247ef85be9c'
})
...
Serverless: Operation failed!
Serverless: View the full error output: https://us-east-2.console.aws.amazon.com/cloudformation/home?region=us-east-2#/stack/detail?stackId=arn%3Aaws%3Acloudformation%3Aus-east-2%3A111111111111%3Astack%2Ffunc%2Fae433620-a828-11ea-a71f-0247ef85be9c
Serverless Error ---------------------------------------
ServerlessError: An error occurred: SnsDashtoDashslackLambdaVersionR8XJyuCWJKn103ukYgyWheWLWHxpDuhJF6xyXV7I - A version for this Lambda function exists ( 5 ). Modify the function to create a new version..
at /usr/local/lib/node_modules/serverless/lib/plugins/aws/lib/monitorStack.js:125:33
From previous event:
at AwsDeploy.monitorStack (/usr/local/lib/node_modules/serverless/lib/plugins/aws/lib/monitorStack.js:28:12)
at /usr/local/lib/node_modules/serverless/lib/plugins/aws/lib/updateStack.js:115:28
From previous event:
at AwsDeploy.update (/usr/local/lib/node_modules/serverless/lib/plugins/aws/lib/updateStack.js:115:8)
From previous event:
at AwsDeploy.<anonymous> (/usr/local/lib/node_modules/serverless/lib/plugins/aws/lib/updateStack.js:129:35)
From previous event:
at AwsDeploy.updateStack (/usr/local/lib/node_modules/serverless/lib/plugins/aws/lib/updateStack.js:125:33)
From previous event:
at AwsDeploy.<anonymous> (/usr/local/lib/node_modules/serverless/lib/plugins/aws/deploy/index.js:127:39)
From previous event:
at Object.aws:deploy:deploy:updateStack [as hook] (/usr/local/lib/node_modules/serverless/lib/plugins/aws/deploy/index.js:123:30)
at /usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:490:55
From previous event:
at PluginManager.invoke (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:490:22)
at PluginManager.spawn (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:510:17)
at AwsDeploy.<anonymous> (/usr/local/lib/node_modules/serverless/lib/plugins/aws/deploy/index.js:93:48)
From previous event:
at Object.deploy:deploy [as hook] (/usr/local/lib/node_modules/serverless/lib/plugins/aws/deploy/index.js:89:30)
at /usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:490:55
From previous event:
at PluginManager.invoke (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:490:22)
at /usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:525:24
From previous event:
at PluginManager.run (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:525:8)
at /usr/local/lib/node_modules/serverless/lib/Serverless.js:133:33
From previous event:
at Serverless.run (/usr/local/lib/node_modules/serverless/lib/Serverless.js:120:74)
at /usr/local/lib/node_modules/serverless/bin/serverless.js:80:26
at processImmediate (internal/timers.js:456:21)
at process.topLevelDomainCallback (domain.js:137:15)
From previous event:
at Object.<anonymous> (/usr/local/lib/node_modules/serverless/bin/serverless.js:80:4)
at Module._compile (internal/modules/cjs/loader.js:1151:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: darwin
Node Version: 13.7.0
Framework Version: 1.72.0
Plugin Version: 3.6.13
SDK Version: 2.3.1
Components Version: 2.30.12
Installed version
Framework Core: 1.72.0
Plugin: 3.6.13
SDK: 2.3.1
Components: 2.30.12
Reacted by Calvin Mlynarczyk
Activity
medikoo commentedon Jun 8, 2020
@yardbirdsax thanks for report. Indeed I can reproduce it. As I see bug is that for version's CodeSha256 property, we assign a hash that's resolved just against lambda code and not other configuration setting.
I think assiging there
versionDigestas resolved here:serverless/lib/plugins/aws/package/compile/functions/index.js
Line 481 in 77fbb59
may fix the issue (but it'll be good to understand first, why actually we calculate both
fileDigestandversionDigest)funkel1989 commentedon Jul 13, 2020
is there a current work around for this?
funkel1989 commentedon Jul 16, 2020
@medikoo Given this bug our team decided to remove reservedConcurrency from our serverless.yml file all together and on our next deploy i found myself still encountering the issue. Do we have any insight to a work around for this until its resolved. I'm assuming if its still because of reservedConcurrency that it is because its now trying to remove concurrency.
To add some extra details here, i've found that after i encounter this error, if i repeat the exact same deploy it will, most of the time, work correctly but not actually apply any of the changes (code or serverless).
medikoo commentedon Aug 26, 2020
We've looked into this issue here: #8066 (comment) and it appears we can't use
versionDigestforCodeSha256property, as that one has to match the SHA of a file.It seems that AWS doesn't give us a clear solution to that. We cannot tweak code hash as function code didn't change, while upgrading the version number will bring error stating that we already have function with very same hash deployed a other version.
Let me check with AWS what's they're stance on that
medikoo commentedon Aug 26, 2020
I've just realized that reserved concurrency is a function wide setting (not specific to version or alias).
Error on framework side, is that we're taking
reservedConcurrencyinto account when calculating version hash. This setting should be ignored.PR that provides that is welcome!
CalMlynarczyk commentedon Aug 27, 2020
We recently ran into a similar issue when trying to add new tags to our stack. No code changes were made in our Lambda function handlers; just the stack config change. We have
versionFunctions: truein our config because our functions for this service are all deployed to Lambda@Edge, which requires versioning.When we run
serverless deploy, we get the sameA version for this Lambda function existserror that causes the stack update to fail and roll back the tag changes.medikoo commentedon Aug 27, 2020
@CalMlynarczyk thanks for pointing. It means that tags should also be excluded from version hash calculation
funkel1989 commentedon Aug 27, 2020
I've found the work around for this being to remove the lambda all together and deploy, then re-add the lambda. This has worked for me 100% of the time so far but adds a lot of complexity when working with pipelines where i would have to push a build with the lambda removed through multiple environments and then push a second build with the lambda just to get the changes to take effect.
CalMlynarczyk commentedon Aug 27, 2020
I should note that we have other services which have
versionFunctions: falseset. We made similar updates to them where we just added new tags to the stack, and did not run into this error.Our workaround for our trouble services was similar to @funkel1989. We added some code comments to the Lambda handlers to trigger a new version update without changing functionality.
azizur commentedon Sep 27, 2020
Not sure why this issue has been marked as closed. I am still getting
A version for this Lambda function exists ( XXX ). Modify the function to create a new version..medikoo commentedon Sep 28, 2020
@azizur are you relying on latest version?
I've just re-tested and it's clearly fixed. You may confirm by deploying this simple service: https://github.com/medikoo/test-serverless/blob/issue-7822/serverless.yml and re-deploying with just
reservedConcurrencysetting added to functionmedikoo commentedon Sep 30, 2020
@crouinicrouina please open another bug report (fully respecting bug template remarks)