When creating a CfnQueue and specifying the visibilityTimeout, an error occurs that the toSeconds function is note a function.
const internalDeadLetterQueue = new sqs.Queue(this, `InternalDeadLetterQueue`);
const internalQueueName = `InternalQueue`;
const internalQueue = new sqs.Queue(this, internalQueueName, {
visibilityTimeout: 60,
deadLetterQueue: {
queue: internalDeadLetterQueue,
maxReceiveCount: 25,
}
});
$ cdk synth
/Users/repo/api/node_modules/@aws-cdk/aws-sqs/lib/validate-props.js:8
validateRange('visibility timeout', props.visibilityTimeout && props.visibilityTimeout.toSeconds(), 0, 43200, 'seconds');
TypeError: props.visibilityTimeout.toSeconds is not a function
at Object.validateProps (/Users/repo/api/node_modules/@aws-cdk/aws-sqs/lib/validate-props.js:8:92)
at new Queue (/Users/repo/api/node_modules/@aws-cdk/aws-sqs/lib/queue.js:37:26)
at new ApiStack (/Users/repos-api/stack.js:21:27)
at new App (/Users/repos/api/cloudformation.js:31:5)
at Object.<anonymous> (/Users/repo/api/cloudformation.js:35:1)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
Subprocess exited with error 1
The documentation for this still says to use a number, not a duration.
https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-sqs.CfnQueue.html
I updated my code to:
const internalDeadLetterQueue = new sqs.Queue(this, `InternalDeadLetterQueue`);
const internalQueueName = `InternalQueue`;
const internalQueue = new sqs.Queue(this, internalQueueName, {
visibilityTimeout: cdk.Duration.seconds(60),
deadLetterQueue: {
queue: internalDeadLetterQueue,
maxReceiveCount: 25,
}
});
and it worked
This is :bug: Bug Report
I have found my solution. But the documentation still needs to be updated before I would consider this resolved.
Hi @sentient-kshaffer, I'm glad you were able to find a solution! Someone will update this once there's movement on updating the documentation.
Thanks for catching that @jogold! Here's the main doc on it.
Closing this issue but feel free to reopen.