'AWS CDK add CreationPolicy to EC2 Instance
Question in the title, trying to figure out how to add a CreationPolicy to an ec2 instance in the cdk so that I can then send a cfn-signal command once the script finishes, to then mark the resource as create complete.
This is what I have so far, after creating the ec2 instance in the stack:
create_policy = CfnCreationPolicy(resource_signal=CfnResourceSignal(count=1, timeout="PT10M"))
I don't see a way in the docs to add that to the ec2 resource as a property. Just wondering what I should do next.
Solution 1:[1]
Add a Creation Policy by setting a CfnInstance construct's cfn_options attribute.
If your EC2 instance is built with the L2 Instance construct, first use escape hatch syntax to reference its underlying L1 CfnInstance construct:
my_cfn_instance = my_instance.node.default_child
my_cfn_instance.cfn_options.creation_policy = create_policy
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | fedonev |
