Skill 48 · Amazon Opensearch Service
Subchapter 48.27
references/provisioning-serverless-deprovision.mdMarkdown4 KBView on GitHub
Delete serverless resources in strict dependency order. Reversing the order fails, because a collection group cannot be deleted while it still has collections, and a security policy cannot be deleted while a collection it covers still exists.
The AWS MCP server is recommended for executing these teardown commands but is not required — all steps use standard AWS CLI syntax.
Destructive-action rule: before deleting anything below, list every resource that will be removed and get explicit user confirmation, because collection deletion (Step 1) is irreversible and destroys all indexed data.
aws opensearchserverless delete-collection --id <collection-id>A collection MUST be ACTIVE (or FAILED) before it can be deleted. If delete returns ConflictException about status, the collection is still being created — wait and retry, because AOSS rejects deletes on collections mid-creation.
aws opensearchserverless batch-get-collection --ids <id1> <id2>Deletion is complete when EITHER the id appears in collectionErrorDetails with "errorCode":"NOT_FOUND" OR collectionDetails is empty. Do NOT poll for a DELETED status, because AOSS removes the collection entirely and returns NOT_FOUND rather than a terminal status.
aws opensearchserverless delete-collection-group --id <group-id>If this returns ValidationException (“has collections associated”), a collection in the group is still active or still deleting — delete/await remaining collections first, because a non-empty group cannot be removed.
aws opensearchserverless delete-security-policy --type network --name <name>-network
aws opensearchserverless delete-security-policy --type encryption --name <name>-encryption
aws opensearchserverless delete-access-policy --type data --name <name>-dataDeleteCollection/DeleteCollectionGroup/Delete*Policy calls are recorded with the caller identity and timestamp.DeleteCollection/DeleteCollectionGroup from unexpected principals that notifies via SNS, because an irreversible delete warrants immediate detection rather than after-the-fact log review. Encrypt the SNS topic with a customer-managed KMS key and restrict sns:Subscribe to authorized principals via a topic policy, because teardown alerts carry resource identifiers that should not reach unintended recipients.aoss:* on all resources, because a broad teardown identity can remove unrelated production collections.