Skip to content

Commit

Permalink
fix(AWS Lambda): Recognize function-wide settings for version hashing
Browse files Browse the repository at this point in the history
(PR #8212)
  • Loading branch information
thewizarodofoz committed Sep 22, 2020
1 parent 0164327 commit 1fceb89
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/plugins/aws/package/compile/functions/index.js
Expand Up @@ -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));
Expand Down
35 changes: 35 additions & 0 deletions lib/plugins/aws/package/compile/functions/index.test.js
Expand Up @@ -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');

Expand Down Expand Up @@ -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);
});
});
});

0 comments on commit 1fceb89

Please sign in to comment.