Skip to content

Commit

Permalink
fix(AWS Lambda): Fix event config setup for provisioned lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Dec 15, 2021
1 parent 7de020b commit 3b4e453
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/plugins/aws/package/compile/functions.js
Expand Up @@ -638,6 +638,7 @@ class AwsCompileFunctions {
DestinationConfig: destinationConfig,
Qualifier: functionObject.targetAlias ? functionObject.targetAlias.name : '$LATEST',
},
DependsOn: _.get(functionObject.targetAlias, 'logicalId'),
};

if (maximumEventAge) {
Expand Down
10 changes: 10 additions & 0 deletions test/unit/lib/plugins/aws/package/compile/functions.test.js
Expand Up @@ -1921,6 +1921,11 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => {
handler: 'target.handler',
layers: [{ Ref: 'ExternalLambdaLayer' }],
},
fnProvisioned: {
handler: 'trigger.handler',
maximumRetryAttempts: 0,
provisionedConcurrency: 1,
},
},
resources: {
Resources: {
Expand Down Expand Up @@ -2231,12 +2236,17 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => {
it('should support `functions[].maximumRetryAttempts`', () => {
const maximumRetryAttempts =
serviceConfig.functions.fnMaximumRetryAttempts.maximumRetryAttempts;

expect(maximumRetryAttempts).to.be.a('number');

expect(
cfResources[naming.getLambdaEventConfigLogicalId('fnMaximumRetryAttempts')].Properties
.MaximumRetryAttempts
).to.equal(maximumRetryAttempts);

expect(cfResources[naming.getLambdaEventConfigLogicalId('fnProvisioned')].DependsOn).to.equal(
naming.getLambdaProvisionedConcurrencyAliasLogicalId('fnProvisioned')
);
});

it('should support `functions[].fileSystemConfig` (with vpc configured on function)', () => {
Expand Down

0 comments on commit 3b4e453

Please sign in to comment.