Skip to content

How to set Termination Protection for an EC2 Instance? #21779

Answered by khushail
mikelhamer asked this question in Q&A
Discussion options

You must be logged in to vote

Adding more reference to @PatMyron answer, the property is -

disableApiTermination

Type: boolean | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) (optional)

If you set this parameter to true , you can't terminate the instance using the Amazon EC2 console, CLI, or API;

otherwise, you can. To change this attribute after launch, use [ModifyInstanceAttribute](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ModifyInstanceAttribute.html) . Alternatively, if you set InstanceInitiatedShutdownBehavior to terminate , you can terminate the instance by running the shutdown command from the instance.

Default: false

like this -

    const instance = 

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by khushail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants