|
| 1 | +{ |
| 2 | + "title": "Custom resource with wait condition", |
| 3 | + "description": "Use AWS CloudFormation Wait Conditions for long-running custom resources up to 12 hours", |
| 4 | + "language": "TypeScript", |
| 5 | + "level": "200", |
| 6 | + "framework": "AWS CDK", |
| 7 | + "introBox": { |
| 8 | + "headline": "How it works", |
| 9 | + "text": [ |
| 10 | + "AWS Lambda functions have a 15-minute execution timeout, limiting CloudFormation custom resources to short-running operations. This pattern extends custom resource execution time to 12 hours using CloudFormation Wait Conditions. The architecture uses four components working together: A Custom Resource Handler Lambda receives CloudFormation lifecycle events and immediately starts a Step Function execution, then returns success to prevent timeouts. The Step Function orchestrates the long-running process with built-in retry mechanisms and error handling. When the process completes, a Completion Signal Handler Lambda sends success or failure signals to a Wait Condition Handle URL. The Wait Condition blocks CloudFormation stack completion until receiving the signal.", |
| 11 | + "This decouples custom resource lifecycle management from process execution, enabling asynchronous processing with proper CloudFormation integration. The Step Function provides visual workflow monitoring and state management while the Wait Condition ensures stack operations complete only after the long-running process finishes. The pattern deploys two Lambda functions, one Step Function, a Wait Condition Handle, and a Wait Condition.", |
| 12 | + "Use cases include database migrations, complex infrastructure provisioning, and third-party system integrations that exceed Lambda's 15-minute limit." |
| 13 | + ] |
| 14 | + }, |
| 15 | + "gitHub": { |
| 16 | + "template": { |
| 17 | + "repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/cdk-custom-resource-with-wait-condition", |
| 18 | + "templateURL": "serverless-patterns/cdk-custom-resource-with-wait-condition", |
| 19 | + "projectFolder": "cdk-custom-resource-with-wait-condition", |
| 20 | + "templateFile": "lib/demo-stack.ts" |
| 21 | + } |
| 22 | + }, |
| 23 | + "resources": { |
| 24 | + "bullets": [ |
| 25 | + { |
| 26 | + "text": "Custom resources", |
| 27 | + "link": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html" |
| 28 | + }, |
| 29 | + { |
| 30 | + "text": "Using wait conditions", |
| 31 | + "link": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-waitcondition.html" |
| 32 | + }, |
| 33 | + { |
| 34 | + "text": "Implementing long running deployments with AWS CloudFormation Custom Resources using AWS Step Functions", |
| 35 | + "link": "https://aws.amazon.com/blogs/devops/implementing-long-running-deployments-with-aws-cloudformation-custom-resources-using-aws-step-functions/" |
| 36 | + } |
| 37 | + ] |
| 38 | + }, |
| 39 | + "deploy": { |
| 40 | + "text": [ |
| 41 | + "cdk deploy --require-approval never" |
| 42 | + ] |
| 43 | + }, |
| 44 | + "testing": { |
| 45 | + "text": [ |
| 46 | + "Review Amazon CloudWatch logs for the Lambda functions and Step Function execution to confirm that the long-running process completed successfully and the wait condition was signaled." |
| 47 | + ] |
| 48 | + }, |
| 49 | + "cleanup": { |
| 50 | + "text": [ |
| 51 | + "Delete the stack: <code>cdk destroy -f</code>." |
| 52 | + ] |
| 53 | + }, |
| 54 | + "authors": [ |
| 55 | + { |
| 56 | + "name": "Dmitry Gulin", |
| 57 | + "bio": "Senior Delivery Consultant, AWS.", |
| 58 | + "linkedin": "dmitry-gulin" |
| 59 | + } |
| 60 | + ], |
| 61 | + "patternArch": { |
| 62 | + "icon1": { |
| 63 | + "x": 20, |
| 64 | + "y": 50, |
| 65 | + "service": "cloudformation", |
| 66 | + "label": "AWS CloudFormation" |
| 67 | + }, |
| 68 | + "icon2": { |
| 69 | + "x": 50, |
| 70 | + "y": 50, |
| 71 | + "service": "lambda", |
| 72 | + "label": "Custom resource" |
| 73 | + }, |
| 74 | + "icon3": { |
| 75 | + "x": 80, |
| 76 | + "y": 50, |
| 77 | + "service": "sfn", |
| 78 | + "label": "AWS Step Functions workflow" |
| 79 | + }, |
| 80 | + "line1": { |
| 81 | + "from": "icon1", |
| 82 | + "to": "icon2", |
| 83 | + "label": "" |
| 84 | + }, |
| 85 | + "line2": { |
| 86 | + "from": "icon2", |
| 87 | + "to": "icon3", |
| 88 | + "label": "" |
| 89 | + } |
| 90 | + } |
| 91 | +} |
0 commit comments