# 7. 정리 (Cleanup)

실습이 끝나면 비용이 발생하지 않도록 리소스를 삭제합니다.

***

### 7.1 OSMO Helm 릴리스 삭제

```bash
helm uninstall osmo-minimal -n osmo-minimal
helm uninstall osmo-operator -n osmo-operator
helm uninstall kai-scheduler -n kai-scheduler
```

***

### 7.2 네임스페이스 삭제

```bash
kubectl delete namespace osmo-minimal osmo-operator osmo-workflows kai-scheduler
```

***

### 7.3 IAM 리소스 정리

```bash
# Access Key 삭제
ACCESS_KEY_ID=$(aws iam list-access-keys --user-name osmo-workflow-user \
  --query 'AccessKeyMetadata[0].AccessKeyId' --output text)
aws iam delete-access-key --user-name osmo-workflow-user --access-key-id $ACCESS_KEY_ID

# Policy 삭제
aws iam delete-user-policy --user-name osmo-workflow-user --policy-name osmo-s3-access

# 사용자 삭제
aws iam delete-user --user-name osmo-workflow-user
```

***

### 7.4 CDK 스택 삭제

```bash
cd ~/aws-physical-ai-recipes/osmo/cdk
npx cdk destroy --context region=us-west-2
```

{% hint style="info" %}
CDK destroy는 약 15분 소요됩니다. EKS 클러스터 삭제가 가장 오래 걸립니다.
{% endhint %}

***

### 7.5 삭제 확인

```bash
# CloudFormation 스택이 삭제되었는지 확인
aws cloudformation describe-stacks --stack-name Osmo --region us-west-2 2>&1 | grep -q "does not exist" && echo "삭제 완료"
```

{% hint style="warning" %}
`cdk destroy` 실패 시, AWS 콘솔 → CloudFormation에서 스택을 수동 삭제하세요. 특히 S3 버킷이 비어있지 않으면 삭제가 실패할 수 있습니다. 이 경우 버킷을 먼저 비운 후 재시도합니다.
{% endhint %}


---

# Agent Instructions: 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:

```
GET https://hi-space.gitbook.io/physical-ai-on-aws/physical-ai-on-aws-guide/nvidia-osmo-on-aws/7.-cleanup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
