Operational Excellence and Automation

A CloudFormation stack must manage an external service configuration that has no native CloudFormation resource type. Its API operations must run during stack creation, update, and deletion, rather than during template synthesis. Which implementation is most appropriate?

Show the answer

Correct answerD. Use a Lambda-backed CloudFormation custom resource.

AWhy not this: CDK aspects run during synthesis and do not receive CloudFormation create, update, or delete requests.

BWhy not this: Synthesis-time calls run while generating the template, not in response to CloudFormation stack lifecycle requests.

CWhy not this: A post-creation script does not integrate the configuration's update and deletion operations with the stack lifecycle.

DWhy this is right: A custom resource provider handles create, update, and delete requests from CloudFormation and can invoke external APIs.

A Lambda-backed custom resource receives CloudFormation create, update, and delete requests, allowing external API operations to follow the stack lifecycle. Calling the API during CDK synthesis runs too early and does not connect those operations to stack lifecycle events.