Aws-cdk: CfnQueue visibilityTimeout cannot be set

Created on 22 Oct 2019  路  4Comments  路  Source: aws/aws-cdk


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

@aws-cdaws-sqs bug docgenerated

All 4 comments

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.

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

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

Closing this issue but feel free to reopen.

Was this page helpful?
0 / 5 - 0 ratings