AWS › IaC (CloudFormation)
How can custom resources in CloudFormation extend its capabilities to manage resources or perform actions that are not natively supported by AWS resource types?
AdvancedAnswer
A custom resource lets you invoke your own Lambda function as part of a CloudFormation stack's create, update, or delete lifecycle, enabling you to perform virtually any custom action, such as calling a third party API to provision a resource outside of AWS, generating a randomly unique value, or performing a complex validation step, all fully integrated into CloudFormation's normal stack lifecycle and rollback behavior as if it were a native, built in resource type.
Resources:
MyCustomResource:
Type: Custom::MyResource
Properties:
ServiceToken: arn:aws:lambda:us-east-1:123456789012:function:CustomResourceHandlerReal-world example A company needing to provision a resource in a third party SaaS platform as part of their infrastructure deployment writes a custom resource backed by a Lambda function, fully integrating that external provisioning step into the same CloudFormation stack lifecycle as their native AWS resources.