Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CustomResource: The serviceTimeout prop does not work with token #33513

Closed
1 task
samson-keung opened this issue Feb 20, 2025 · 2 comments · Fixed by #33541
Closed
1 task

CustomResource: The serviceTimeout prop does not work with token #33513

samson-keung opened this issue Feb 20, 2025 · 2 comments · Fixed by #33541
Labels
@aws-cdk/core Related to core CDK functionality bug This issue is a bug. p2

Comments

@samson-keung
Copy link
Contributor

Describe the bug

The CustomResource construct takes a serviceTimeout prop. The construct has some validation logic for the value if it isn't a token:

if (props.serviceTimeout !== undefined && !Token.isUnresolved(props.serviceTimeout)

But I was not able to pass a token for serviceTimeout. I have the following unit test:

test('set serviceTimeout', () => {
    // GIVEN
    const stack = new Stack();
    const durToken = new CfnParameter(stack, 'MyParameter', {
      type: 'Number',
      default: 60,
    });

    // WHEN
    new CustomResource(stack, 'MyCustomResource', {
      serviceToken: 'MyServiceToken',
      serviceTimeout: durToken as any,
    });
  });

It fails with following error:

props.serviceTimeout?.toSeconds is not a function
TypeError: props.serviceTimeout?.toSeconds is not a function

I also tried the following test:

test('set serviceTimeout', () => {
    // GIVEN
    const stack = new Stack();
    const durToken = new CfnParameter(stack, 'MyParameter', {
      type: 'Number',
      default: 60,
    });

    // WHEN
    new CustomResource(stack, 'MyCustomResource', {
      serviceToken: 'MyServiceToken',
      serviceTimeout: Duration.seconds(durToken.valueAsNumber),
    });
  });

It fails with following error:

Error: serviceTimeout must either be between 1 and 3600 seconds, got -1.8881545897087526e+289

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

It should take a token as the value.

Current Behavior

Using token would cause error. See above.

Reproduction Steps

See above

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.179.0

Framework Version

No response

Node.js Version

20

OS

Mac

Language

TypeScript

Language Version

No response

Other information

No response

@samson-keung samson-keung added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 20, 2025
@github-actions github-actions bot added the @aws-cdk/custom-resources Related to AWS CDK Custom Resources label Feb 20, 2025
@samson-keung samson-keung added p2 @aws-cdk/core Related to core CDK functionality and removed needs-triage This issue or PR still needs to be triaged. @aws-cdk/custom-resources Related to AWS CDK Custom Resources labels Feb 20, 2025
@mergify mergify bot closed this as completed in #33541 Feb 22, 2025
@mergify mergify bot closed this as completed in bc91c70 Feb 22, 2025
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

1 similar comment
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/core Related to core CDK functionality bug This issue is a bug. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant