View a markdown version of this page

Running a mitigation plan - AWS Ops Agent (formerly DevOps Agent)

Running a mitigation plan

Prerequisites

For the agent to run a mitigation plan, you need to do the following:

  • Turn on directed actions for the Agent Space. For instructions on enabling directed actions, see Enabling directed actions on an agent space.

  • Register an elevated role for each AWS account that the plan changes. The role status must be valid. For instructions on registering an elevated role, see Registering an elevated role for an AWS account and Validation lifecycle.

  • Make sure that the elevated role for each account allows each AWS change in the plan. The agent can make a change only if the elevated role for that account allows the operation. For more information about granting permissions to the elevated role, see Granting permissions to the elevated role.

  • Give each operator who approves stages access to the Agent Space in the Ops Agent web app. You run mitigation plans in Ops Agent web app chat.

If your Agent Space gets its AWS accounts from AWS Organizations, the agent can't make AWS changes. Every AWS change in the plan is a manual step that you make yourself.

If directed actions are turned off, you can still review the plan on the Mitigation plan tab and make its changes yourself. The agent can't run any part of the plan, including its checks.

Before you run a plan, make sure that each AWS account that the plan changes has a valid elevated role. Plan creation doesn't check the elevated role. If an account in the plan has no valid elevated role, the stage fails after you approve it. Register a valid elevated role, and then ask the agent to run the stage again. The stage starts again from the change that failed.

Running each stage

Run a mitigation plan after you review its stages on the Mitigation plan tab. The agent runs the plan one stage at a time, and you approve each stage before it runs.

To run a mitigation plan:

  1. In the Ops Agent web app, open the investigation.

  2. On the Mitigation plan tab, choose Start mitigation in chat. The chat panel opens, with a request to start the plan in the message box.

  3. To start running the plan, send the message. The agent gives a short overview of each stage and lists every change that can't be undone.

  4. The agent asks for your approval to run the first stage. Review the stage's approval card. The card shows the stage's checks and actions, and marks each action that can't be rolled back.

  5. To run the stage, choose Allow. If you choose Deny, the stage doesn't run. The agent asks whether to run the stage again or pause.

  6. The agent runs the stage's pre-validation checks. It makes the changes in the stage's Apply phase, and then runs its verification checks. This might take several minutes, depending on the stage. The Mitigation plan tab shows the progress of each step.

  7. If the plan has more than one stage, when a stage succeeds, the agent asks whether to continue. Choose Run next stage to repeat these steps for the next stage, or Pause here to stop for now.

When a stage needs your approval, the Mitigation plan tab says so. To answer, choose Answer in chat. You can approve a stage only in chat.

If you don't answer an approval card within 30 minutes, the card expires and nothing runs. To try again, ask the agent to run the stage.

To return to the chat later, choose Continue in chat on the Mitigation plan tab. After the plan ends, choose Open mitigation chat.

How the agent runs a plan

The agent runs the plan exactly as you see it on the Mitigation plan tab. It runs one stage at a time. In each stage, it runs the pre-validation checks, then the changes in order, and then the verification checks. The agent doesn't add, skip, or reorder steps.

The agent uses its own judgment only when a check doesn't pass. It reads the current state of your resources to decide why the check failed. For example, the system might need more time, the check might not have permission to run, or the change might have made things worse.

When the only reason is that the system needs more time, the agent waits and runs the checks again on its own, for up to 30 minutes. If the checks still don't pass, it asks you what to do. For any other reason, the agent stops, asks you what to do, and recommends one option.

Completing manual steps

When the agent reaches a change that it isn't allowed to make, it pauses the stage and shows a card for the manual step. The card shows why the agent can't make the change and what to do. For an AWS change, it shows the AWS Command Line Interface (AWS CLI) command to run and the account to run it in. For a change in a third-party system, it shows that system's command, or tells you to make the change in that system.

To complete a manual step:

  1. Make the change with your own credentials. For an AWS change, copy the command from the card and run it in the account shown.

  2. Choose Mark as done.

The stage continues with its next change and its verification checks. On the Mitigation plan tab, the step shows Done by operator. The agent doesn't check that you ran the command. The stage's verification checks show whether the change took effect.

Stopping a mitigation plan

Stop a mitigation plan if you no longer want the agent to run its stages.

You can stop a mitigation plan while it's in progress or waiting for you.

To stop a mitigation plan:

  1. In the Ops Agent web app, open the investigation.

  2. On the Mitigation plan tab, choose Stop.

  3. In Stop this mitigation plan?, choose Stop.

A step that is already running finishes first, and no later steps run. The plan shows Stopped.

To resume a stopped plan, choose Resume in chat on the Mitigation plan tab, or ask the agent in chat to run the plan again. The approval card for the next stage tells you that approving it resumes the plan.

What happens when a mitigation plan finishes

After the last stage, the plan shows Completed. The agent gives a summary of the plan in chat. The summary lists each stage and whether it's done or partially succeeded, each change with the current value of the setting that it changed, the checks that still don't pass, and follow-up steps. For example, the agent reminds you to make each change in your infrastructure as code, so that a later deployment doesn't undo it.

Troubleshooting mitigation plans

Common causes of problems with mitigation plans include directed actions that are turned off, a missing or invalid elevated role, a policy that blocks an operation, and an approval card that expired. Use the following information to fix these problems.

Pre-validation checks fail

The agent doesn't make any changes in the stage. It tells you which check failed and why, and checks the current state of your resources. The agent first suggests that you wait and run the stage again. Continue only when you know why the check failed, and you know the stage's changes are still safe. To continue, ask the agent to continue past the failed pre-validation checks. The agent then shows an approval card to override the pre-validation checks. If you choose Allow, the agent runs the changes for the stage and the verification checks anyway.

Verification checks don't pass yet

Some changes take time to take effect. While your system is recovering, the agent waits and runs the verification checks again on its own. When the checks pass, the stage succeeds. If the checks still don't pass, the agent stops. It asks what to do. The agent recommends one option, such as waiting longer, marking the stage as done, rolling back the stage, or looking deeper. You can also pause. If you mark the stage as done, the agent shows an approval card. Choosing Allow only marks the stage Partially succeeded. This lets the next stage start. It doesn't make more changes in your AWS accounts.

Chat says that the action is not available

Chat says "This action is not available in this agent space, so it was not executed." With directed actions turned off for the Agent Space, the agent can't run any part of a stage, including its pre-validation and verification checks. Turn on directed actions, then ask the agent to run the stage again. For instructions, see Enabling directed actions on an agent space.

A stage fails because the agent couldn't use the elevated role

The agent couldn't get credentials from the elevated role for the account. Check that an elevated role is registered for the account, that its status is valid, and that its permission policy allows the operation. Then ask the agent to run the stage again. For more information, see Registering an elevated role for an AWS account.

A step fails with an access denied error

The elevated role, a service control policy, or a permissions boundary doesn't allow the operation on that resource. Update the policy that blocks the operation, and then ask the agent to run the stage again. The stage starts again from the change that failed.

An approval card wasn't answered in time

If you don't answer an approval card within 30 minutes, it expires and nothing runs. Ask the agent to run the stage again. The agent shows a new approval card for the stage.

The approval card says that your decision could not be submitted

The approval card says "Your decision could not be submitted." This can happen when the connection drops after you choose. Your decision might still have reached the agent. To continue, ask the agent in chat whether the stage ran.

The Mitigation plan tab doesn't appear

The agent builds the plan in the background after the investigation finds the root cause, so the plan can take a few minutes. If the investigation completed and no plan appears, choose Generate mitigation plan on the Root cause tab. If the button isn't available, pause your pointer on it to see why.

The Mitigation plan tab shows a summary and no stages

The agent decided that no change is needed now. The summary says why. If the investigation didn't find a root cause, the summary says what the agent couldn't reach and who should look.

The Mitigation plan tab shows an error

The Mitigation plan tab shows "Can't load the mitigation plan" or another error. Choose Try again.