Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exclude tags and reservedConcurrency from version hash #8212

8 changes: 7 additions & 1 deletion lib/plugins/aws/package/compile/functions/index.js
Expand Up @@ -494,7 +494,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 @@ -2831,4 +2832,38 @@ describe('AwsCompileFunctions #2', () => {
});
});
});

describe.only('function config', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.only I believe was committed in by accident

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);
});
});
});