> For the complete documentation index, see [llms.txt](https://docs.e6data.com/query-engine/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.e6data.com/query-engine/guides/deployment/aws-in-vpc/delete-workspace.md).

# Delete workspace

Tear down an In-VPC e6data workspace and its AWS resources in the reverse order they were created.

Removing a workspace means tearing down its Kubernetes resources and the AWS resources created for it, in roughly the reverse order of deployment.

{% hint style="warning" %}
Deleting a workspace is irreversible. It removes the workspace's clusters, catalog registrations, and the metadata stored in its S3 bucket. Confirm the workspace is no longer in use before you begin.
{% endhint %}

## Step 1: Remove the workspace components

Delete the workspace custom resources by re-rendering the chart and deleting what it produced (or delete the `NamespaceConfig` and `QueryRouter` directly):

```bash
helm template "${WORKSPACE_NAME}-ws" "${E6_WORKSPACE_CHART}" \
  --namespace "${NAMESPACE}" --values workspace-values.yaml \
  | kubectl delete -f -

# Confirm the custom resources are gone
kubectl get namespaceconfig,queryrouter,monitoringservices -n ${NAMESPACE}
```

## Step 2: Remove the workspace NodePool and namespace

```bash
kubectl delete nodepool.karpenter.sh ${WORKSPACE_NAME}-nodepool
kubectl delete ec2nodeclass.karpenter.k8s.aws ${WORKSPACE_NAME}-nodeclass
kubectl delete namespace ${NAMESPACE}
```

Karpenter terminates the workspace's nodes once the NodePool is gone and no pods remain.

## Step 3: Remove the Pod Identity associations

```bash
aws eks list-pod-identity-associations \
  --cluster-name ${CLUSTER_NAME}-eks --namespace ${WORKSPACE_NAME} --region ${REGION} \
  --query 'associations[].associationId' --output text \
| xargs -n1 -I{} aws eks delete-pod-identity-association \
  --cluster-name ${CLUSTER_NAME}-eks --association-id {} --region ${REGION}
```

## Step 4: Remove the workspace IAM roles

Delete the inline policies, then the roles:

```bash
for role in ${WORKSPACE_NAME}-engine-role ${WORKSPACE_NAME}-console-role ${WORKSPACE_NAME}-app-role; do
  for policy in $(aws iam list-role-policies --role-name "$role" --query 'PolicyNames' --output text); do
    aws iam delete-role-policy --role-name "$role" --policy-name "$policy"
  done
  aws iam delete-role --role-name "$role"
done
```

## Step 5: Remove the metadata bucket

```bash
aws s3 rm s3://e6-${WORKSPACE_NAME}-metadata --recursive
aws s3api delete-bucket --bucket e6-${WORKSPACE_NAME}-metadata --region ${REGION}
```

{% hint style="info" %}
This removes one workspace. The shared cluster components (EKS, Karpenter, the ALB Controller, cert-manager, the e6-operator) remain in place to serve other workspaces. Remove those only if you are decommissioning the entire EKS cluster.
{% endhint %}

## See also

* [Deploy workspace and e6data](/query-engine/guides/deployment/aws-in-vpc/deploy-workspace-and-e6data.md) - what these steps reverse.
* [Troubleshooting](/query-engine/guides/deployment/aws-in-vpc/troubleshooting.md) - resources stuck during teardown.


---

# 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://docs.e6data.com/query-engine/guides/deployment/aws-in-vpc/delete-workspace.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.
