Skip to content

Commit d599900

Browse files
authored
feat(custom-resource): add serviceTimeout property for custom resources (#30911)
### Issue # (if applicable) Closes #30517. ### Reason for this change L2 construct does not support setting `serviceTimeout`. Enabling customizable timeouts is useful when using custom resources, as the current default timeout is set to 3600 seconds. Ref: [AWS CloudFormation accelerates dev-test cycle with adjustable timeouts for custom resources](https://aws.amazon.com/about-aws/whats-new/2024/06/aws-cloudformation-dev-test-cycle-timeouts-custom-resources/) ### Description of changes Add `serviceTimeout` property for `CustomResource` and `AwsCustomResource`. ### Description of how you validated changes Add unit tests and integ tests. Additionally, I confirmed that ServiceTimeout is set by checking the CloudWatch Logs of the Lambda function that generates custom resources. <img width="1036" alt="スクリーンショット 2024-07-21 2 09 15" src="https://github.com/user-attachments/assets/b99bc10b-52e6-4cdc-ba63-b4f379077bfc"> ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent a10c369 commit d599900

29 files changed

+1957
-9
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-cloudformation/test/integ.core-custom-resources-service-timeout.js.snapshot/asset.58b00a04670a58e0a99d0ca363cd2c6449822eb21c94bc5d3ca25a4816b69098/__entrypoint__.js

+155
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cloudformation/test/integ.core-custom-resources-service-timeout.js.snapshot/asset.58b00a04670a58e0a99d0ca363cd2c6449822eb21c94bc5d3ca25a4816b69098/index.js

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cloudformation/test/integ.core-custom-resources-service-timeout.js.snapshot/cdk.out

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cloudformation/test/integ.core-custom-resources-service-timeout.js.snapshot/custom-resource-test-service-timeout.assets.json

+32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{
2+
"Resources": {
3+
"CustomReflectCustomResourceProviderRoleB4B29AEC": {
4+
"Type": "AWS::IAM::Role",
5+
"Properties": {
6+
"AssumeRolePolicyDocument": {
7+
"Version": "2012-10-17",
8+
"Statement": [
9+
{
10+
"Action": "sts:AssumeRole",
11+
"Effect": "Allow",
12+
"Principal": {
13+
"Service": "lambda.amazonaws.com"
14+
}
15+
}
16+
]
17+
},
18+
"ManagedPolicyArns": [
19+
{
20+
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
21+
}
22+
]
23+
}
24+
},
25+
"CustomReflectCustomResourceProviderHandler2E189D0B": {
26+
"Type": "AWS::Lambda::Function",
27+
"Properties": {
28+
"Code": {
29+
"S3Bucket": {
30+
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
31+
},
32+
"S3Key": "58b00a04670a58e0a99d0ca363cd2c6449822eb21c94bc5d3ca25a4816b69098.zip"
33+
},
34+
"Timeout": 900,
35+
"MemorySize": 128,
36+
"Handler": "__entrypoint__.handler",
37+
"Role": {
38+
"Fn::GetAtt": [
39+
"CustomReflectCustomResourceProviderRoleB4B29AEC",
40+
"Arn"
41+
]
42+
},
43+
"Runtime": "nodejs18.x",
44+
"Description": "veni vidi vici"
45+
},
46+
"DependsOn": [
47+
"CustomReflectCustomResourceProviderRoleB4B29AEC"
48+
]
49+
},
50+
"MyResource": {
51+
"Type": "Custom::Reflect",
52+
"Properties": {
53+
"ServiceToken": {
54+
"Fn::GetAtt": [
55+
"CustomReflectCustomResourceProviderHandler2E189D0B",
56+
"Arn"
57+
]
58+
},
59+
"ServiceTimeout": "60"
60+
},
61+
"UpdateReplacePolicy": "Delete",
62+
"DeletionPolicy": "Delete"
63+
}
64+
},
65+
"Parameters": {
66+
"BootstrapVersion": {
67+
"Type": "AWS::SSM::Parameter::Value<String>",
68+
"Default": "/cdk-bootstrap/hnb659fds/version",
69+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
70+
}
71+
},
72+
"Rules": {
73+
"CheckBootstrapVersion": {
74+
"Assertions": [
75+
{
76+
"Assert": {
77+
"Fn::Not": [
78+
{
79+
"Fn::Contains": [
80+
[
81+
"1",
82+
"2",
83+
"3",
84+
"4",
85+
"5"
86+
],
87+
{
88+
"Ref": "BootstrapVersion"
89+
}
90+
]
91+
}
92+
]
93+
},
94+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
95+
}
96+
]
97+
}
98+
}
99+
}

packages/@aws-cdk-testing/framework-integ/test/aws-cloudformation/test/integ.core-custom-resources-service-timeout.js.snapshot/customresourcetestservicetimeoutintegtestDefaultTestDeployAssert8F844874.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cloudformation/test/integ.core-custom-resources-service-timeout.js.snapshot/customresourcetestservicetimeoutintegtestDefaultTestDeployAssert8F844874.template.json

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cloudformation/test/integ.core-custom-resources-service-timeout.js.snapshot/integ.json

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)