It's possible to use
EventBridge event
"CloudFormation Resource Status Change" to execute code when the
CloudFormation stack itself is created.
This can be done describing the EventBridge event rule for a Lambda function that match the emitted event:
StackEvent:
Type: EventBridgeRule
Properties:
EventBusName: default
Pattern:
source:
- aws.cloudformation
detail-type:
- CloudFormation Stack Status Change
detail:
stack-id:
- !Ref AWS::StackId
status-details:
status:
- CREATE_COMPLETE
The event rule pattern is interpolated with
AWS::StackId pseudo parameter reference.
So far the only status change that is reported is
CREATE_COMPLETE.
Here a GitHub gist with a CloudFormation (SAM) example template:
https://gist.github.com/daaru00/d5443e5de9b25fd7ee637e6d6a22d137