Decommission an Account

Decommissioning an AWS account is a two-phase process:

  1. Remove Guardrails-managed infrastructure from the AWS account (event handlers, IAM resources, CloudTrail, logging buckets).
  2. Disconnect the account from the Guardrails workspace, removing all CMDB records and policy settings.

Prerequisites

Phase 1: Decommission Guardrails Infrastructure

Create the following policy settings on the target account to clean up Guardrails-managed resources. If you want to retain a particular resource (e.g., CloudTrail for compliance), skip that policy setting.

Allow time for Guardrails to complete each removal before proceeding to Phase 2.

#PolicyValueWhat It Removes
1AWS > IAM > User > BoundaryEnforce: No BoundaryBoundary policies from IAM users.
2AWS > IAM > Role > BoundaryEnforce: No BoundaryBoundary policies from IAM roles.
3AWS > Turbot > Permissions > Superuser BoundaryNo BoundaryGuardrails-managed superuser boundary.
4AWS > Turbot > Permissions > User BoundaryNo BoundaryGuardrails-managed user boundary.
5AWS > Turbot > PermissionsEnforce: NoneGuardrails-managed IAM policies, groups, roles, and users.
6AWS > Turbot > Audit TrailEnforce: Not configuredGuardrails-managed CloudTrail.
7AWS > Turbot > Event HandlersEnforce: Not configuredRegional EventBridge rules and SNS topics.
8AWS > Turbot > Event Handlers [Global]Enforce: Not configuredGlobal EventBridge rules and SNS topics.
9AWS > Turbot > Service RolesEnforce: Not configuredGuardrails-managed IAM service roles.
10AWS > Turbot > Logging > BucketEnforce: Not configuredGuardrails-managed logging S3 buckets. Buckets must be empty before deletion. Empty them via the AWS console if needed.
11AWS > Turbot > Event PollerDisabledStops event polling. Disable this after event handler cleanup is complete, since cleanup requires active polling.

[!IMPORTANT] The order matters for steps 7–11. When event handlers are set to Not configured or Skip, the Event Poller re-enables automatically. Keep it running until event handler infrastructure is fully removed, then disable it.

Phase 2: Disconnect the Account

Once the controls from Phase 1 have completed:

  1. Delete the AWS > Account > Turbot IAM Role > External ID and AWS > Account > Turbot IAM Role policy settings on the target account.

  2. Navigate to the account's resource page in the Guardrails console.

  3. Select Actions in the top right, then Remove from Turbot.

  4. In the confirmation dialog, type the account ID to confirm, then click Delete. Leave Retain history for deleted resources checked if you want to keep the account's control and resource history in Guardrails.

Remove from Turbot confirmation dialog showing the resource and policy-setting counts, the confirmation field, and the Retain history option

Guardrails removes the account, all child resources, controls, and policy settings. The time to complete depends on the number of resources. Larger accounts take longer.

[!NOTE] Disconnecting an account does not modify anything in the AWS account itself. It only removes the records from Guardrails.

Troubleshooting

The disconnection may time out if the account has a large number of resources. The goal is to reduce the resource count before retrying.

Manual Resource Count Reduction

  1. Navigate to the account's Resources tab to identify the largest resource types.
  2. For each large resource type, create a policy setting for AWS > {Service} > {Resource Type} > CMDB set to Enforce: Disabled. This purges those CMDB entries.
  3. Wait a few minutes for the purge to complete, then retry the disconnection.
  4. Repeat until successful.

Automated Resource Count Reduction

Use the aws_account_delete script from the Guardrails Samples repository. It automates CMDB policy creation and account disconnection. See the README for setup instructions.

How Disconnection Works

Guardrails removes the account, all child resources, controls, and policy settings in a single SQL transaction. If the transaction exceeds the statement timeout (due to a large resource count), it rolls back safely and the account remains visible. Reduce the resource count and retry.

If the account cannot be disconnected after multiple attempts, Open a Support Ticket.