diff --git a/lib/plugins/aws/package/compile/functions/index.js b/lib/plugins/aws/package/compile/functions/index.js index fd007a279de..57bdec54204 100644 --- a/lib/plugins/aws/package/compile/functions/index.js +++ b/lib/plugins/aws/package/compile/functions/index.js @@ -395,7 +395,13 @@ class AwsCompileFunctions { }); }).then(() => { // Include function configuration in version id hash (without the Code part) - const properties = _.omit(_.get(functionResource, 'Properties', {}), 'Code'); + const properties = _.omit( + _.get(functionResource, 'Properties', {}), + 'Code', + // Properties applied to function globally (not specific to version or alias) + 'ReservedConcurrentExecutions', + 'Tags' + ); _.forOwn(properties, value => { if (_.isObject(value)) { versionHash.write(JSON.stringify(value)); diff --git a/lib/plugins/aws/package/compile/functions/index.test.js b/lib/plugins/aws/package/compile/functions/index.test.js index e831f0600ac..91e26f1c82e 100644 --- a/lib/plugins/aws/package/compile/functions/index.test.js +++ b/lib/plugins/aws/package/compile/functions/index.test.js @@ -10,6 +10,7 @@ const AwsProvider = require('../../../provider/awsProvider'); const AwsCompileFunctions = require('./index'); const Serverless = require('../../../../../Serverless'); const runServerless = require('../../../../../../test/utils/run-serverless'); +const fixtures = require('../../../../../../test/fixtures'); const { getTmpDirPath, createTmpFile } = require('../../../../../../test/utils/fs'); @@ -2650,4 +2651,38 @@ describe('AwsCompileFunctions #2', () => { }); }); }); + + describe('function config', () => { + it('should not create a new version object if only function-wide configuration changed', async () => { + const { servicePath, updateConfig } = await fixtures.setup('function'); + + const { cfTemplate: originalTemplate } = await runServerless({ + cwd: servicePath, + cliArgs: ['package'], + }); + const originalVersionArn = originalTemplate.Outputs.FooLambdaFunctionQualifiedArn.Value.Ref; + + await updateConfig({ + functions: { + foo: { + tags: { + foo: 'bar', + }, + reservedConcurrency: 1, + }, + }, + }); + const { cfTemplate: updatedTemplate } = await runServerless({ + cwd: servicePath, + cliArgs: ['package'], + }); + const updatedVersionArn = updatedTemplate.Outputs.FooLambdaFunctionQualifiedArn.Value.Ref; + + expect( + updatedTemplate.Resources.FooLambdaFunction.Properties.ReservedConcurrentExecutions + ).to.equal(1); + + expect(originalVersionArn).to.equal(updatedVersionArn); + }); + }); });