-
Notifications
You must be signed in to change notification settings - Fork 9
Advanced usage
Ben Kehoe edited this page Feb 8, 2018
·
1 revision
Classes may implement validate() and/or populate(). validate should return
True if self.resource_properties is valid. populate can transfer the contents of
self.resource_properties into object fields, if this is not done by validate.
Some hooks are provided to override behavior. The first four are instance fields, since they may be set to functions that rely on instance fields. The last is a class field, since it is called by a class method.
-
finish_function, normally set toCloudFormationCustomResource.cfn_response, takes as input the custom resource object and deals with sending the response and cleaning up. -
send_function, used withinCloudFormationCustomResource.cfn_response, takes as input the custom resource object, a url, and the response_content dictionary. Normally this is set toCloudFormationCustomResource.send_response, which uses requests to send the content to its destination, using the vendored version in botocore. -
generate_unique_id_prefix_functioncan be set to put a prefix on the id returned bygenerate_unique_id, for example if the physical resource id needs to be an ARN. -
generate_physical_resource_id_functionis used to get a physical resource id on a create call unlessDISABLE_PHYSICAL_RESOURCE_ID_GENERATIONis True. It takes the custom resource object as input.This is normally set toCloudFormationCustomResource.generate_unique_id, which generates a physical resource id like CloudFormation:{stack_id}-{logical resource id}-{random string}It also provides two keyword arguments:- prefix: if for example the physical resource id must be an arn
- separator: defaulting to '-'.
-
BOTO3_SESSION_FACTORYtakes no input and returns an object that acts like a boto3 session. If this class field is notNone, it is used byget_boto3_sessioninstead of creating a regular boto3 session. This could be made to use placebo for testing
-
DELETE_LOGS_ON_STACK_DELETION: A boolean which, when True, will cause a successful stack deletion to trigger the deletion of the CloudWatch log group on stack deletion. If there is a problem during stack deletion, the logs are left in place. NOTE: this is not intended for use when the Lambda function is used by multiple stacks.