# AWS: Enable or Disable Instance Protection in an ASG

Toggles scale-in protection on specific EC2 instances in an Auto Scaling Group so they won't be terminated during scale-in events.


> **Availability:** See the [Incident Workflow Actions Overview table](/workflow-actions) for the plans this workflow is available on.

## Description

**Premium.** This action is a Premium Workflow Action, billed separately from your PagerDuty plan. In the workflow action picker, this action appears as **Auto Scaling: Set Instance Protection**.

Enable or disable "Protected from scale-in" on selected instances in an Auto Scaling Group (ASG). When protection is enabled, the ASG will not terminate these instances during scale-in events, which is useful when you are about to move an instance to Standby or terminate it in a controlled way. This action is useful for:

- Protecting an instance from scale-in before rotating it out of the ASG (e.g., before Enter Standby and Terminate)
- Ensuring a specific instance is not chosen for termination during automatic scale-in
- Building runbooks that combine with Describe Auto Scaling Instances, Enter Standby, and Terminate Instance in Auto Scaling Group for safe instance rotation
- Temporarily shielding instances during maintenance or troubleshooting

## Instructions

1. If you have not done so, follow the instructions to [Create an Incident Workflow](/ai-automation/automation/incident-workflows#create-an-incident-workflow).
2. When the instructions prompt you to [add actions](/ai-automation/automation/incident-workflows#add-actions), select **this action**.
3. Enter the following **Inputs** and click **Save**.
4. Continue following instructions to **Publish** the Workflow.
5. When the action runs, you will see the **Outputs** listed below.

## Inputs

> **Field References:** Fields with the **\{+\}** icon accept [Field References](/ai-automation/automation/incident-workflows#field-references), which can be useful for referencing incident data or outputs created in prior workflow steps. To add Field References, click **\{+\}**, or enter `{{`, and select relevant fields. Refer to the [Field References](/ai-automation/automation/incident-workflows#field-references) article for more information.

| Name                    | Description                                                                                                                                                                      |
| :---------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Integration             | Select a [Workflow Integration](/ai-automation/automation/incident-workflows/workflow-integrations) or click **New AWS Connection** to establish a new one.                           |
| Auto Scaling Group Name | The name of the Auto Scaling Group that contains the instances.                                                                                                                  |
| Instance IDs            | One or more EC2 instance IDs to set or clear protection for (comma-separated). Can be from a prior step (e.g., Describe Auto Scaling Instances) or from incident custom details. |
| AWS Region              | The AWS region where the ASG is located. If left blank, the action uses `us-east-1` as the default.                                                                              |
| Protected From Scale In | Set to **true** to protect the instances from scale-in (recommended before rotating an instance out). Set to **false** to remove protection.                                     |

## Outputs

| Name                    | Description                                                            |
| :---------------------- | :--------------------------------------------------------------------- |
| ASG Name                | The Auto Scaling Group that was targeted.                              |
| Protected               | Array of instance IDs that were set to the requested protection state. |
| Protected From Scale In | The protection value that was applied (**true** or **false**).         |
| Result                  | Whether the action succeeded: **Success** or **Failed**.               |
| Result Summary          | Brief description of what the action did or if it failed.              |
| Error                   | Error message, if the action failed.                                   |

> **Tips:** - **Instance Rotation**: In a rotate-instance runbook, set **Protected From Scale In** = **true** before **Enter Standby** so the ASG does not select this instance for scale-in while you are rotating it out.
> - **Chaining Actions**: Use **Auto Scaling Group Name** and **Instance IDs** from **Auto Scaling: Describe Auto Scaling Instances** (e.g., `instances[0].asgName`, and the same instance IDs) so the workflow works when the incident only provides an instance ID.
