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

9 changes: 8 additions & 1 deletion lib/plugins/aws/package/compile/functions/index.js
Expand Up @@ -494,7 +494,14 @@ 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)
// https://github.com/serverless/serverless/issues/7822
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can remove the link to github issue.

If needed, it's easy to map given code lines to source PR and issue, by GitHub blame feature

'ReservedConcurrentExecutions',
'Tags'
);
_.forOwn(properties, value => {
if (_.isObject(value)) {
versionHash.write(JSON.stringify(value));
Expand Down
32 changes: 32 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 @@ -2915,4 +2916,35 @@ describe('AwsCompileFunctions #2', () => {
});
});
});

describe('function config', () => {
it.only('should not create a new version object if only function-wide configuration changed', () => {
return fixtures.setup('function').then(({ servicePath, updateConfig }) =>
runServerless({
cwd: servicePath,
cliArgs: ['package'],
}).then(({ cfTemplate: originalTemplate }) => {
const originalVersionArn = originalTemplate.Outputs.FooLambdaFunctionQualifiedArn.Value.Ref
return updateConfig({
functions: {
foo: {
tags: {
foo: 'bar'
},
reservedConcurrency: 1
}
},
}).then(() =>
runServerless({
cwd: servicePath,
cliArgs: ['package'],
}).then(({ cfTemplate: updatedTemplate }) => {
expect(updatedTemplate.Resources.FooLambdaFunction.Properties.ReservedConcurrentExecutions).to.equal(1);
const updatedVersionArn = updatedTemplate.Outputs.FooLambdaFunctionQualifiedArn.Value.Ref
expect(originalVersionArn).to.equal(updatedVersionArn);
})
);
}));
});
});
});