Ensure that the Amazon EC2 instances provisioned outside the Auto Scaling Groups (ASGs) have Termination Protection safety feature enabled in order to protect them from being accidentally terminated.
For Amazon EC2 instances provisioned manually, once the Termination Protection feature is enabled you will not be able to terminate your EC2 instances using the AWS Management Console, the AWS API, or the AWS CLI until the Termination Protection has been disabled. However, this will not prevent your instances from getting terminated if these have set the Shutdown Behavior flag to 'Terminate' when an OS-level shutdown is performed. To make sure your EC2 instances cannot be accidentally terminated, you need to set first the instance Shutdown Behavior value to 'Stop' (which sets the InstanceInitiatedShutdownBehavior attribute value to 'stop') then enable Termination Protection safety feature (which sets the DisableApiTermination attribute value to true).
For Amazon EC2 instances provisioned automatically via AWS CloudFormation, once the Termination Protection feature is enabled, you will not be able to delete the stack containing the instance until the feature has been disabled (which sets the DisableApiTermination attribute value to false) in your CloudFormation template.
This rule resolution is part of the Conformity Security & Compliance tool for AWS.
By default, the EBS volumes associated with the Amazon EC2 instances are deleted when these are terminated (when the DeletionOnTermination attribute value is set to true). With Termination Protection feature enabled, you have the guarantee that your EC2 instances can't be terminated accidentally and make sure that your data remains safe.
Audit
To determine if your existing Amazon EC2 instances (provisioned manually or automatically via AWS CloudFormation) have Termination Protection enabled, perform the following actions:
Remediation / Resolution
Case A: To enable Termination Protection for the Amazon EC2 instances launched manually using the AWS Management Console, AWS API, or AWS CLI, perform the following actions:
Case B: To enable Termination Protection for Amazon EC2 instances launched automatically using an AWS CloudFormation stack, perform the following actions:
References
- AWS Documentation
- Amazon EC2 FAQs
- Terminate Your Instance
- AWS Command Line Interface (CLI) Documentation
- ec2
- describe-instances
- describe-instance-attribute
- modify-instance-attribute
- cloudformation
- update-termination-protection
Unlock the Remediation Steps
Free 30-day Trial
Automatically audit your configurations with Conformity
and gain access to our cloud security platform.
You are auditing:
EC2 Instance Termination Protection
Risk Level: Medium