aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

CfnQueue visibilityTimeout cannot be set

Open sentient-kshaffer opened this issue 7 years ago • 4 comments

When creating a CfnQueue and specifying the visibilityTimeout, an error occurs that the toSeconds function is note a function.

Reproduction Steps

const internalDeadLetterQueue = new sqs.Queue(this, `InternalDeadLetterQueue`);
    const internalQueueName = `InternalQueue`;
    const internalQueue = new sqs.Queue(this, internalQueueName, {
        visibilityTimeout: 60,
        deadLetterQueue: {
            queue: internalDeadLetterQueue,
            maxReceiveCount: 25,
        }
    });

Error Log

$ 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

Environment

  • CLI Version :1.13.1
  • Framework Version: 1.13.1
  • OS : MacOS 10.14
  • **Language : Javascript **

Other

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

sentient-kshaffer avatar Oct 22 '19 17:10 sentient-kshaffer

I have found my solution. But the documentation still needs to be updated before I would consider this resolved.

sentient-kshaffer avatar Oct 22 '19 17:10 sentient-kshaffer

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.

SomayaB avatar Oct 22 '19 18:10 SomayaB

Your are looking at the documentation for CfnQueue (L1 construct) but using Queue (L2 construct) where it is correctly documented.

jogold avatar Oct 22 '19 19:10 jogold

Thanks for catching that @jogold! Here's the main doc on it.

Closing this issue but feel free to reopen.

SomayaB avatar Oct 22 '19 21:10 SomayaB