-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
@aws-cdk/aws-lambda-event-sourcesbugThis issue is a bug.This issue is a bug.closing-soonThis issue will automatically close in 4 days unless further comments are made.This issue will automatically close in 4 days unless further comments are made.
Description
Without the dependsOn being generated in the CFT the EventSource can be generated with an empty OnFailure destination.
Reproduction Steps
import cdk = require('@aws-cdk/core');
import dynamodb = require('@aws-cdk/aws-dynamodb');
import eventSource = require('@aws-cdk/aws-lambda-event-sources');
import lambda = require('@aws-cdk/aws-lambda');
import sqs = require('@aws-cdk/aws-sqs');
import {Construct} from "@aws-cdk/core";
export class CdkTestStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const table = new dynamodb.Table(this, 'table', {
partitionKey: {
name: 'pk',
type: dynamodb.AttributeType.STRING
},
stream: dynamodb.StreamViewType.NEW_IMAGE
});
const testlambda = new lambda.Function(this, 'TestFunction', {
code: lambda.Code.fromInline('handler = () => console.log("handled");'),
runtime: lambda.Runtime.NODEJS_12_X,
handler: 'index.handler',
description: 'Example function',
});
const sqsQueue = new sqs.Queue(this, 'sqsDLQ', {
});
testlambda.addEventSource(
new eventSource.DynamoEventSource(table, {
startingPosition: lambda.StartingPosition.TRIM_HORIZON,
batchSize: 1,
retryAttempts: 0,
onFailure: new eventSource.SqsDlq(sqsQueue)
})
);
}
}
Error Log
Environment
- **CLI Version : >1.29.0 **
- Framework Version:
- OS :
- Language :
Other
Register dependency on the DLQ with the EventSource when it is created.
Hack work around (added to stack):
let dynamoDBEventSource = {} as Construct;
for (let i = 0; i < testlambda.node.children.length; i++) {
if (testlambda.node.children[i].node.uniqueId.includes('DynamoDBEventSource')) {
dynamoDBEventSource = testlambda.node.children[i] as Construct;
}
}
dynamoDBEventSource.node.addDependency(sqsQueue);
This is 🐛 Bug Report
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-lambda-event-sourcesbugThis issue is a bug.This issue is a bug.closing-soonThis issue will automatically close in 4 days unless further comments are made.This issue will automatically close in 4 days unless further comments are made.