简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM