---
title: EC2 instance management
source: https://docs.newrelic.com/docs/workflow-automation/workflow-examples/advanced/ec2-management
---

Respond to New Relic CPU alerts, request Slack approval, and automate EC2 instance resizing via AWS Systems Manager.

**Requirements:**

-   AWS credentials (EC2 + Systems Manager)
-   New Relic alert condition
-   Slack token

**What this workflow does:**

-   Receive high CPU alerts from New Relic
-   Retrieve alert details and identify impacted EC2 instance
-   Send Slack notification with instance details and request approval
-   Create SSM document after approval to automate resizing
-   Stop instance, modify instance type, and restart
-   Send progress updates to Slack during resizing
-   Wait for completion and send status
-   Clean up SSM document and send final confirmation

**Key actions**: `newrelic.nerdgraph.execute`, `newrelic.nrdb.query`, `slack.chat.postMessage`, `slack.chat.getReactions`, `aws.systemsManager.writeDocument`, `aws.systemsManager.startAutomation`, `aws.systemsManager.waitForAutomationStatus`, `aws.systemsManager.deleteDocument`, `utils.datetime.fromEpoch`, `utils.uuid.generate`

## Related topics [#related-topics]

[API gateway rollback](https://docs.newrelic.com/docs/workflow-automation/workflow-examples/advanced/api-gateway-rollback)

Automate API Gateway deployments

[Deployment rollback](https://docs.newrelic.com/docs/workflow-automation/workflow-examples/advanced/deployment-rollback)

Monitor and manage deployments

[Set up AWS credentials](https://docs.newrelic.com/docs/workflow-automation/setup-and-configure/set-up-aws-credentials)

Configure IAM roles for EC2 workflows
