Skip to content

Commit 599a1d3

Browse files
authored
feat(lambda): add support for durable functions (#36282)
### Issue # (if applicable) N/A ### Reason for this change AWS Lambda L2 support for the new durable functions feature. https://docs.aws.amazon.com/lambda/latest/dg/durable-functions.html ### Description of changes Updating the `Lambda::Function` L2 construct with the new `durableConfig` property. ### Describe any new or updated permissions being added Updating the managed policy that gets attached to lambda functions to be the new `AWSLambdaBasicDurableExecutionRolePolicy` managed policy for durable functions. In addition to the existing policies that the `AWSLambdaBasicExecutionRole` has, this new policy has permissions for `lambda:CheckpointDurableExecution` and `lambda:GetDurableExecutionState` actions. ### Description of how you validated changes Unit tests, integration tests and generated snapshot files. ### 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 c4fa99b commit 599a1d3

File tree

14 files changed

+1120
-1
lines changed

14 files changed

+1120
-1
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.durable-config.js.snapshot/aws-cdk-lambda-durable-config.assets.json

Lines changed: 20 additions & 0 deletions
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,111 @@
1+
{
2+
"Resources": {
3+
"DurableFunctionServiceRole4F9882F4": {
4+
"Type": "AWS::IAM::Role",
5+
"Properties": {
6+
"AssumeRolePolicyDocument": {
7+
"Statement": [
8+
{
9+
"Action": "sts:AssumeRole",
10+
"Effect": "Allow",
11+
"Principal": {
12+
"Service": "lambda.amazonaws.com"
13+
}
14+
}
15+
],
16+
"Version": "2012-10-17"
17+
},
18+
"ManagedPolicyArns": [
19+
{
20+
"Fn::Join": [
21+
"",
22+
[
23+
"arn:",
24+
{
25+
"Ref": "AWS::Partition"
26+
},
27+
":iam::aws:policy/service-role/AWSLambdaBasicDurableExecutionRolePolicy"
28+
]
29+
]
30+
}
31+
]
32+
}
33+
},
34+
"DurableFunction8FC9485F": {
35+
"Type": "AWS::Lambda::Function",
36+
"Properties": {
37+
"Code": {
38+
"ZipFile": "exports.handler = async () => ({ statusCode: 200, body: \"Hello World\" });"
39+
},
40+
"DurableConfig": {
41+
"ExecutionTimeout": 3600,
42+
"RetentionPeriodInDays": 30
43+
},
44+
"Handler": "index.handler",
45+
"Role": {
46+
"Fn::GetAtt": [
47+
"DurableFunctionServiceRole4F9882F4",
48+
"Arn"
49+
]
50+
},
51+
"Runtime": "nodejs22.x"
52+
},
53+
"DependsOn": [
54+
"DurableFunctionServiceRole4F9882F4"
55+
]
56+
},
57+
"DurableFunctionLogGroup96FE3B84": {
58+
"Type": "AWS::Logs::LogGroup",
59+
"Properties": {
60+
"LogGroupName": {
61+
"Fn::Join": [
62+
"",
63+
[
64+
"/aws/lambda/",
65+
{
66+
"Ref": "DurableFunction8FC9485F"
67+
}
68+
]
69+
]
70+
},
71+
"RetentionInDays": 731
72+
},
73+
"UpdateReplacePolicy": "Retain",
74+
"DeletionPolicy": "Retain"
75+
}
76+
},
77+
"Parameters": {
78+
"BootstrapVersion": {
79+
"Type": "AWS::SSM::Parameter::Value<String>",
80+
"Default": "/cdk-bootstrap/hnb659fds/version",
81+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
82+
}
83+
},
84+
"Rules": {
85+
"CheckBootstrapVersion": {
86+
"Assertions": [
87+
{
88+
"Assert": {
89+
"Fn::Not": [
90+
{
91+
"Fn::Contains": [
92+
[
93+
"1",
94+
"2",
95+
"3",
96+
"4",
97+
"5"
98+
],
99+
{
100+
"Ref": "BootstrapVersion"
101+
}
102+
]
103+
}
104+
]
105+
},
106+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
107+
}
108+
]
109+
}
110+
}
111+
}

packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.durable-config.js.snapshot/cdk.out

Lines changed: 1 addition & 0 deletions
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-lambda/test/integ.durable-config.js.snapshot/integ.json

Lines changed: 13 additions & 0 deletions
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-lambda/test/integ.durable-config.js.snapshot/lambdadurableconfigDefaultTestDeployAssert5291EFAC.assets.json

Lines changed: 20 additions & 0 deletions
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-lambda/test/integ.durable-config.js.snapshot/lambdadurableconfigDefaultTestDeployAssert5291EFAC.template.json

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)