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
37 changes: 37 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,40 @@ describe('AwsCompileFunctions #2', () => {
});
});
});

describe('function config', () => {
it('should not create a new version object if only function-wide configuration changed', () => {
return fixtures.setup('function').then(({ servicePath, updateConfig }) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we upgrade this to async/await syntax?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was really hoping to do that! Yay!

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