> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/amazon-web-services-manual-onboarding/aws-manual-onboarding-guide/offboarding-and-resource-decommissioning-optional.md).

# Offboarding and resource decommissioning (optional)

```shell
# 1. (Reverses Step 2.7) Delete scanner role (optional — only if outpost scanning was configured)
aws iam detach-role-policy --role-name "${SCANNER_ROLE_NAME}" \
  --policy-arn "arn:aws:iam::aws:policy/ReadOnlyAccess"
aws iam detach-role-policy --role-name "${SCANNER_ROLE_NAME}" \
  --policy-arn "arn:aws:iam::aws:policy/SecurityAudit"
aws iam delete-role --role-name "${SCANNER_ROLE_NAME}"

# 2. (Reverses Step 2.6) Delete inline policy from logs ingestion role
aws iam delete-role-policy \
  --role-name "${LOGS_ROLE_NAME}" \
  --policy-name "CloudTrailReadAccessPolicy"

# 3. (Reverses Step 2.6) Delete logs ingestion role
aws iam delete-role --role-name "${LOGS_ROLE_NAME}"

# 4. (Reverses Step 2.5) Unsubscribe SQS from SNS (find subscription ARN first)
SUBSCRIPTION_ARN=$(aws sns list-subscriptions-by-topic \
  --topic-arn "${CLOUDTRAIL_SNS_ARN}" \
  --query "Subscriptions[?Endpoint=='${SQS_QUEUE_ARN}'].SubscriptionArn" \
  --output text)
aws sns unsubscribe --subscription-arn "${SUBSCRIPTION_ARN}"

# 5. (Reverses Step 2.4) Delete SQS queue policy (reset to default — no explicit policy)
aws sqs set-queue-attributes \
  --queue-url "${SQS_QUEUE_URL}" \
  --attributes '{"Policy":""}'

# 6. (Reverses Step 2.3) Delete SQS queue
aws sqs delete-queue --queue-url "${SQS_QUEUE_URL}"

# 7. (Reverses Step 2.2) Detach managed policies from platform role
aws iam detach-role-policy --role-name "${CORTEX_ROLE_NAME}" \
  --policy-arn "arn:aws:iam::aws:policy/ReadOnlyAccess"
aws iam detach-role-policy --role-name "${CORTEX_ROLE_NAME}" \
  --policy-arn "arn:aws:iam::aws:policy/AmazonMemoryDBReadOnlyAccess"
aws iam detach-role-policy --role-name "${CORTEX_ROLE_NAME}" \
  --policy-arn "arn:aws:iam::aws:policy/SecurityAudit"
aws iam detach-role-policy --role-name "${CORTEX_ROLE_NAME}" \
  --policy-arn "arn:aws:iam::aws:policy/AmazonSQSReadOnlyAccess"
aws iam detach-role-policy --role-name "${CORTEX_ROLE_NAME}" \
  --policy-arn "arn:aws:iam::aws:policy/AWSOrganizationsReadOnlyAccess"
aws iam detach-role-policy --role-name "${CORTEX_ROLE_NAME}" \
  --policy-arn "${DISCOVERY_POLICY_ARN}"

# 8. (Reverses Step 2.2) Delete platform role
aws iam delete-role --role-name "${CORTEX_ROLE_NAME}"

# 9. (Reverses Step 2.1) Delete custom discovery policy
aws iam delete-policy --policy-arn "${DISCOVERY_POLICY_ARN}"
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cortex-docs.paloaltonetworks.com/amazon-web-services-manual-onboarding/aws-manual-onboarding-guide/offboarding-and-resource-decommissioning-optional.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
