Skip to content
New issue

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

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

Already on GitHub? # to your account

custom-resource: Support of ServiceTimeout from Cloudformation #30517

Open
2 tasks
btd opened this issue Jun 11, 2024 · 9 comments · May be fixed by #30911
Open
2 tasks

custom-resource: Support of ServiceTimeout from Cloudformation #30517

btd opened this issue Jun 11, 2024 · 9 comments · May be fixed by #30911
Labels
@aws-cdk/custom-resources Related to AWS CDK Custom Resources effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1

Comments

@btd
Copy link

btd commented Jun 11, 2024

Describe the feature

Hi, everyone.

Cloudformation just release ServiceTimeout attribute support in Custom Resources, so now we do not need to wait 1h to notice faulty deployment.

Announcement: https://aws.amazon.com/about-aws/whats-new/2024/06/aws-cloudformation-dev-test-cycle-timeouts-custom-resources/

Docs: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html#response-timeout

Use Case

Mostly development cycle should be improved when you actively develop custom resources. I will be able to set timeout to 5 min max and see it fail faster.

Proposed Solution

New optional property added to custom resource construct (not sure to which part, most likely it is framework)

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

all

Environment details (OS name and version, etc.)

AL2

@btd btd added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jun 11, 2024
@github-actions github-actions bot added the @aws-cdk/custom-resources Related to AWS CDK Custom Resources label Jun 11, 2024
@pahud pahud added p1 and removed needs-triage This issue or PR still needs to be triaged. labels Jun 11, 2024
@pahud
Copy link
Contributor

pahud commented Jun 11, 2024

Definitely, this is a highly anticipated feature that many users have been waiting for.

@pahud pahud added the effort/medium Medium work item – several days of effort label Jun 11, 2024
@pahud pahud changed the title customresource: Support of ServiceTimeout from Cloudformation custom-resource: Support of ServiceTimeout from Cloudformation Jun 11, 2024
@prazian
Copy link

prazian commented Jun 15, 2024

I just created this PR. I would appreciate to receive your thoughts and feedback:
#30557

I still need to work on adding integration tests (probably a maintainer needs to create the snapshots) + also I don't know where in docs this can be added, but meanwhile would be great if someone looks at the approach and give feedback.

Currently, we have the timeout field for the lambda function that creates the resource (here is the cfn docs), but this new field sets timeout on a higher level (stack, instead of the lambda fn that creates the resource).

@mrlikl
Copy link
Contributor

mrlikl commented Jun 18, 2024

@pahud, what do you think about the idea of having a feature flag to control the default timeout for all the custom resources in a stack ?

Also, I do want to suggest having a different default timeout for CDK of 15mins rather than setting to 1hour (excluding edge cases like EKS cluster provider).

Main reason being for cases like lambda's failing to signal back due to network issues, users need not wait 1+1 hour (update as well as rollback) to have an updatable stack.

@pahud
Copy link
Contributor

pahud commented Jul 8, 2024

It's a good question on how to customize the default timeout for custom resource and we've seen similar issue like this for all custom resource providers that does not have LoggingConfig specified and should have a custom retention period.

I am not sure if feature flag is a good solution as most of our feature flags are boolean typed that toggle some features on or off. I guess what users need is a global config like this that applies to existing resources if relevant config is undefined.

defaultCustomResourceTimeout=10min
defaultLambdaLogRetentionPeriod=7days

But users would still need further customization like:

  1. What should I do if I need to raise the ServiceTimeout up to 1 hour for everything behind the eks.Cluster?
  2. What should I do if I need to raise the log retention period to 10 years for all log groups created behind current stack?

Maybe something like the Tags class that comes with an Aspect iterating the construct tree would be a nice solution?

WDYT?

Just added a feat request #30800

@kriehzoo
Copy link

kriehzoo commented Nov 22, 2024

So, neither CfnCustomConstruct.Builder, nor CustomConstruct.Builder have support for ServiceTime which was added this year?

Wasting a lot of time waiting for stack deployment and rollback / cleanup to time out.
Could you pls reconsider adding this?

I assumed that CDK is somehow generated from CloudFormation and would at least contain everything as level-1 constructs?

I am using CDK v2 and Java.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-customresource.html#aws-resource-cloudformation-customresource-properties
https://aws.amazon.com/about-aws/whats-new/2024/06/aws-cloudformation-dev-test-cycle-timeouts-custom-resources/

@pahud
Copy link
Contributor

pahud commented Nov 22, 2024

We have a PR in progress now
#30911

@kriehzoo
Copy link

nice! will it be available then also for cdk for java?

@kriehzoo
Copy link

a workaround I found useful was to run cdk synth, then add the service timeout in cloud formation template and use Aws cli for cloud formation to deploy the template.

@Dreamescaper
Copy link

Currently it is possible simply to add "ServiceTimeout" to Properties:

        new CustomResource(parentConstruct, "id", new CustomResourceProps
        {
            ServiceToken = lambda.FunctionArn,
            Properties = new Dictionary<string, object>
            {
                ["ServiceTimeout"] = "900",
            },
            //...
        });

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
@aws-cdk/custom-resources Related to AWS CDK Custom Resources effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1
Projects
None yet
6 participants