Alibaba Cloud DataHub full-lifecycle resource management skill. Use for creating, querying, updating, and deleting DataHub Projects, Topics, and Subscription...
---
name: alibabacloud-datahub-manage
description: |
Alibaba Cloud DataHub full-lifecycle resource management skill.
Use for creating, querying, updating, and deleting DataHub Projects, Topics, and Subscriptions via Aliyun CLI.
Triggers: "datahub", "datahub project", "datahub topic", "datahub subscription", "datahub resource management", "streaming data management".
---
# DataHub Resource Management
Manage the full lifecycle of Alibaba Cloud DataHub resources (Project → Topic → Subscription) using the Aliyun CLI plugin mode.
**Architecture**: `Region → Project → Topic → Subscription`
---
## Prerequisites
**Pre-check: Aliyun CLI >= 3.3.3 required**
> Run `aliyun version` to verify >= 3.3.3. If not installed or version too low,
> see `references/cli-installation-guide.md` for installation instructions.
**Pre-check: Aliyun CLI plugin update required**
> [MUST] run `aliyun configure set --auto-plugin-install true` to enable automatic plugin installation.
> [MUST] run `aliyun plugin update` to ensure that any existing plugins are always up-to-date.
---
## Authentication
> **Pre-check: Alibaba Cloud Credentials Required**
>
> **Security Rules:**
> - **NEVER** read, echo, or print AK/SK values (e.g., `echo $ALIBABA_CLOUD_ACCESS_KEY_ID` is FORBIDDEN)
> - **NEVER** ask the user to input AK/SK directly in the conversation or command line
> - **NEVER** use `aliyun configure set` with literal credential values
> - **ONLY** use `aliyun configure list` to check credential status
>
> ```bash
> aliyun configure list
> ```
> Check the output for a valid profile (AK, STS, or OAuth identity).
>
> **If no valid profile exists, STOP here.**
> 1. Obtain credentials from [Alibaba Cloud Console](https://ram.console.aliyun.com/manage/ak)
> 2. Configure credentials **outside of this session** (via `aliyun configure` in terminal or environment variables in shell profile)
> 3. Return and re-run after `aliyun configure list` shows a valid profile
---
## RAM Policy
This skill requires DataHub permissions. See `references/ram-policies.md` for the full policy document.
Required actions: `dhs:ListProjects`, `dhs:CreateProject`, `dhs:GetProject`, `dhs:UpdateProject`, `dhs:DeleteProject`, `dhs:ListTopics`, `dhs:CreateTopic`, `dhs:GetTopic`, `dhs:UpdateTopic`, `dhs:DeleteTopic`, `dhs:ListSubscriptions`, `dhs:CreateSubscription`, `dhs:GetSubscription`, `dhs:DeleteSubscription`.
> **[MUST] Permission Failure Handling:** When any command or API call fails due to permission errors at any point during execution, follow this process:
> 1. Read `references/ram-policies.md` to get the full list of permissions required by this SKILL
> 2. Use `ram-permission-diagnose` skill to guide the user through requesting the necessary permissions
> 3. Pause and wait until the user confirms that the required permissions have been granted
---
## Parameter Confirmation
> **IMPORTANT: Parameter Confirmation** — Before executing any command or API call,
> ALL user-customizable parameters (e.g., RegionId, instance names, CIDR blocks,
> passwords, domain names, resource specifications, etc.) MUST be confirmed with the
> user. Do NOT assume or use default values without explicit user approval.
| Parameter | Required | Description | Default |
|-----------|----------|-------------|---------|
| `region` | Yes | Target region for DataHub resources | — (must confirm) |
| `project-name` | Yes | DataHub project name (3-32 chars, letter start, alphanumeric + underscore) | — |
| `topic-name` | Yes (for Topic ops) | Topic name (3-128 chars) | — |
| `record-type` | Yes (for create-topic) | BLOB or TUPLE | — |
| `shard-count` | Yes (for create-topic) | Number of shards | — |
| `lifecycle` | Yes (for create-topic) | Data retention in days | — |
| `record-schema` | Conditional | Required when record-type is TUPLE | — |
| `application` | Yes (for create-subscription) | Application description (max 256 chars) | — |
| `subscription-id` | Optional | Manual subscription ID (4-40 chars, lowercase) | Auto-generated |
---
## Observability (MUST follow for every aliyun command)
Upon loading this skill, generate a random session ID (32-char lowercase hex string) once for the entire session. Use it as `{session-id}` below.
**Rule: Every `aliyun` CLI command that calls a cloud API MUST include the `--user-agent` flag.**
Local utility commands (e.g. `configure`, `plugin`, `version`) do not support this flag and should be excluded.
```
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
```
Example (assuming session-id is `a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6`):
```bash
aliyun datahub list-projects --region cn-hangzhou --user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6
```
Do not skip, alter the format, or omit `--user-agent` on any `aliyun` API command invocation.
---
## Core Workflow
### Resource Dependency
```
Region
└── Project
└── Topic (BLOB / TUPLE)
└── Subscription
```
**Creation order**: Project → Topic → Subscription
**Deletion order** (reverse): Subscription → Topic → Project
---
### Step 1: Create Project
```bash
# 1.1 List existing projects to check name conflicts
aliyun datahub list-projects \
--region <region> \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
# 1.2 Create project
aliyun datahub create-project \
--region <region> \
--project-name <project-name> \
--comment "<project-description>" \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
# 1.3 Verify creation
aliyun datahub get-project \
--region <region> \
--project-name <project-name> \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
```
---
### Step 2: Create Topic
#### 2.1 Create BLOB Topic (binary data)
```bash
aliyun datahub create-topic \
--region <region> \
--project-name <project-name> \
--topic-name <blob-topic-name> \
--comment "<topic-description>" \
--shard-count <shard-count> \
--record-type BLOB \
--lifecycle <days> \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
```
#### 2.2 Create TUPLE Topic (structured data with schema)
```bash
aliyun datahub create-topic \
--region <region> \
--project-name <project-name> \
--topic-name <tuple-topic-name> \
--comment "<topic-description>" \
--shard-count <shard-count> \
--record-type TUPLE \
--lifecycle <days> \
--record-schema '{"fields":[{"name":"<field_name>","type":"STRING","notnull":"false"}]}' \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
```
#### 2.3 Verify topic
```bash
aliyun datahub get-topic \
--region <region> \
--project-name <project-name> \
--topic-name <topic-name> \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
```
#### 2.4 Update topic description
```bash
aliyun datahub update-topic \
--region <region> \
--project-name <project-name> \
--topic-name <topic-name> \
--comment "<new-description>" \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
```
---
### Step 3: Create Subscription
```bash
# Option A: Auto-generated subscription-id
aliyun datahub create-subscription \
--region <region> \
--project-name <project-name> \
--topic-name <topic-name> \
--application "<application-description>" \
--comment "<subscription-description>" \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
# Option B: Manual subscription-id
aliyun datahub create-subscription \
--region <region> \
--project-name <project-name> \
--topic-name <topic-name> \
--application "<application-description>" \
--comment "<subscription-description>" \
--subscription-id <subscription-id> \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
```
Verify:
```bash
aliyun datahub get-subscription \
--region <region> \
--project-name <project-name> \
--topic-name <topic-name> \
--subscription-id <subscription-id> \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
```
---
### Step 4: Resource Cleanup
**[MUST] Delete in reverse dependency order.**
> **⚠️ DESTRUCTIVE OPERATION — User Confirmation Required**
>
> Before executing ANY delete command (`delete-subscription`, `delete-topic`, `delete-project`),
> you **MUST** explicitly list the resources to be deleted and ask the user for confirmation.
> **Do NOT proceed until the user explicitly approves the deletion.**
>
> Example prompt to user:
> > "I am about to delete the following resources (this action is **irreversible**):
> > - Subscription: `<subscription-id>` on topic `<topic-name>`
> > - Topic: `<topic-name>` in project `<project-name>`
> > - Project: `<project-name>`
> >
> > Do you confirm? (yes/no)"
#### 4.1 Delete Subscription
```bash
aliyun datahub delete-subscription \
--region <region> \
--project-name <project-name> \
--topic-name <topic-name> \
--subscription-id <subscription-id> \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
```
#### 4.2 Delete Topic (pre-check: no active subscriptions)
```bash
# Pre-check
aliyun datahub list-subscriptions \
--region <region> \
--project-name <project-name> \
--topic-name <topic-name> \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
# Delete topic
aliyun datahub delete-topic \
--region <region> \
--project-name <project-name> \
--topic-name <topic-name> \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
```
#### 4.3 Delete Project (pre-check: no active topics)
```bash
# Pre-check
aliyun datahub list-topics \
--region <region> \
--project-name <project-name> \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
# Delete project
aliyun datahub delete-project \
--region <region> \
--project-name <project-name> \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
```
> **⚠️ WARNING**: Deleting a Project removes all its Topics, data, and Subscriptions. This operation is **irreversible**. Always obtain explicit user confirmation before execution.
---
## Success Verification
See `references/verification-method.md` for detailed verification steps for each operation.
---
## Best Practices
1. **Always verify after creation** — Use `get-project`, `get-topic`, `get-subscription` to confirm resources exist.
2. **Follow dependency order** — Create: Project → Topic → Subscription; Delete: reverse.
3. **Pre-check before deletion** — List child resources before deleting parent resources.
4. **Use meaningful names** — Follow naming conventions (see `references/related-commands.md`).
5. **Set appropriate lifecycle** — Configure data retention (`--lifecycle`) based on business requirements.
6. **Choose correct record-type** — Use BLOB for binary streams, TUPLE for structured data requiring schema.
7. **Confirm parameters** — Always confirm region, project name, and other user-specific values before execution.
---
## Reference Links
| Document | Description |
|----------|-------------|
| [references/ram-policies.md](references/ram-policies.md) | Required RAM permissions |
| [references/related-commands.md](references/related-commands.md) | Full CLI command reference |
| [references/verification-method.md](references/verification-method.md) | Success verification steps |
| [references/acceptance-criteria.md](references/acceptance-criteria.md) | Testing acceptance criteria |
| [references/cli-installation-guide.md](references/cli-installation-guide.md) | CLI installation guide |
| [DataHub Product Docs](https://www.aliyun.com/product/datahub) | DataHub product introduction |
| [DataHub Help Center](https://help.aliyun.com/zh/datahub/) | Detailed usage guide |
don't have the plugin yet? install it then click "run inline in claude" again.
manage the complete lifecycle of alibaba cloud datahub resources (projects, topics, subscriptions) using the aliyun cli. use this skill when you need to provision streaming data infrastructure, configure topic schemas, set up data subscriptions, or tear down datahub resources. covers creation, querying, updates, and deletion across the region → project → topic → subscription hierarchy.
external connections:
aliyun version. install or upgrade via references/cli-installation-guide.mdaliyun configure set --auto-plugin-install true. run aliyun plugin update before first use~/.aliyun/config.json or environment variables (ALIBABA_CLOUD_ACCESS_KEY_ID, ALIBABA_CLOUD_ACCESS_KEY_SECRET). verify with aliyun configure list (never echo credentials directly)dhs:ListProjects, dhs:CreateProject, dhs:GetProject, dhs:UpdateProject, dhs:DeleteProject, dhs:ListTopics, dhs:CreateTopic, dhs:GetTopic, dhs:UpdateTopic, dhs:DeleteTopic, dhs:ListSubscriptions, dhs:CreateSubscription, dhs:GetSubscription, dhs:DeleteSubscription. see references/ram-policies.mduser-provided parameters (require explicit confirmation before execution):
| parameter | required | type | constraints | example |
|---|---|---|---|---|
region |
yes | string | valid aliyun region id | cn-hangzhou, cn-shanghai, us-west-1 |
project-name |
yes | string | 3-32 chars, starts with letter, alphanumeric + underscore | my_datahub_project |
topic-name |
yes (topic ops) | string | 3-128 chars, alphanumeric + underscore | user_events |
record-type |
yes (create-topic) | enum | BLOB or TUPLE |
BLOB |
shard-count |
yes (create-topic) | integer | >= 1 | 4 |
lifecycle |
yes (create-topic) | integer | days, >= 1 | 7 |
record-schema |
conditional (tuple only) | json | required if record-type=TUPLE, defines field names/types |
{"fields":[{"name":"user_id","type":"STRING","notnull":"false"}]} |
application |
yes (create-subscription) | string | max 256 chars, application description | mobile-analytics-service |
subscription-id |
optional (create-subscription) | string | 4-40 chars, lowercase alphanumeric + dash | sub-mobile-analytics-001 |
comment |
optional | string | resource description | logs from production servers |
session state:
generate a single random 32-character lowercase hex string (session-id) at skill load time. use it for all --user-agent flags in this session.
run aliyun version to confirm cli >= 3.3.3
3.4.0)references/cli-installation-guide.mdrun aliyun configure set --auto-plugin-install true to enable auto-install
run aliyun plugin update to sync plugins
run aliyun configure list to verify credentials
aliyun configure outside this session, then returnconfirm ram permissions via user attestation or ram-permission-diagnose skill
prompt user: "what region will you use?"
{region}run list-projects to check for name conflicts:
aliyun datahub list-projects \
--region {region} \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
{region}, {session-id}prompt user: "what project name (3-32 chars, starts with letter, alphanumeric + underscore)?"
{project-name}prompt user (optional): "add a project description or comment?"
{project-comment} (default: empty string)run create-project:
aliyun datahub create-project \
--region {region} \
--project-name {project-name} \
--comment "{project-comment}" \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
{region}, {project-name}, {project-comment}, {session-id}ram-permission-diagnose skill, ask user to confirm permissions granted, then retryverify project creation:
aliyun datahub get-project \
--region {region} \
--project-name {project-name} \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
{region}, {project-name}, {session-id}prompt user: "create a topic now? (yes/no)"
prompt user: "what topic name (3-128 chars)?"
{topic-name}prompt user: "will this be BLOB (binary) or TUPLE (structured with schema)?"
prompt user: "how many shards? (integer >= 1)"
{shard-count}prompt user: "data retention in days? (integer >= 1)"
{lifecycle}prompt user (optional): "add a topic description?"
{topic-comment} (default: empty)run create-topic for BLOB:
aliyun datahub create-topic \
--region {region} \
--project-name {project-name} \
--topic-name {topic-name} \
--comment "{topic-comment}" \
--shard-count {shard-count} \
--record-type BLOB \
--lifecycle {lifecycle} \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
{session-id}ram-permission-diagnose, wait for confirmation, retryverify topic creation:
aliyun datahub get-topic \
--region {region} \
--project-name {project-name} \
--topic-name {topic-name} \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
steps 4a.1-4a.6 apply here (name, comment, shard-count, lifecycle)
prompt user: "define your tuple schema in json format. example: {"fields":[{"name":"user_id","type":"STRING","notnull":"false"}]}"
{record-schema}run create-topic for TUPLE:
aliyun datahub create-topic \
--region {region} \
--project-name {project-name} \
--topic-name {topic-name} \
--comment "{topic-comment}" \
--shard-count {shard-count} \
--record-type TUPLE \
--lifecycle {lifecycle} \
--record-schema '{record-schema}' \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
verify topic:
prompt user: "update topic description? (yes/no)"
prompt user: "new description?"
{new-comment}run update-topic:
aliyun datahub update-topic \
--region {region} \
--project-name {project-name} \
--topic-name {topic-name} \
--comment "{new-comment}" \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
prompt user: "create a subscription now? (yes/no)"
prompt user: "subscription application name (max 256 chars)? (e.g., 'mobile-analytics-service')"
{application}prompt user (optional): "subscription description or comment?"
{subscription-comment} (default: empty)prompt user (optional): "manual subscription-id (4-40 chars, lowercase alphanumeric + dash), or auto-generate?"
{subscription-id} to empty string, skip to step 5.6{subscription-id} and validate formatdisplay summary:
creating subscription with:
- project: {project-name}
- topic: {topic-name}
- application: {application}
- subscription-id: {subscription-id} (or auto if empty)
- comment: {subscription-comment}
confirm? (yes/no)
run create-subscription:
aliyun datahub create-subscription \
--region {region} \
--project-name {project-name} \
--topic-name {topic-name} \
--application "{application}" \
--comment "{subscription-comment}" \
[--subscription-id {subscription-id}] \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
ram-permission-diagnose, wait, retry{actual-subscription-id}verify subscription:
aliyun datahub get-subscription \
--region {region} \
--project-name {project-name} \
--topic-name {topic-name} \
--subscription-id {actual-subscription-id} \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
prompt user: "delete resources? (yes/no)"
prompt user: "delete subscriptions, topics, or entire project?"
{deletion-scope} (subscription / topic / project)prompt user: "list subscriptions to delete? (yes/no)"
aliyun datahub list-subscriptions \
--region {region} \
--project-name {project-name} \
--topic-name {topic-name} \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
{target-subscription-id}display confirmation prompt (required, do not skip):
YOU ARE ABOUT TO DELETE (IRREVERSIBLE):
- subscription: {target-subscription-id}
- topic: {topic-name}
- project: {project-name}
THIS ACTION CANNOT BE UNDONE.
type 'confirm-delete' to proceed, or 'cancel' to abort:
confirm-delete, abort deletion and exit step 6arun delete-subscription:
aliyun datahub delete-subscription \
--region {region} \
--project-name {project-name} \
--topic-name {topic-name} \
--subscription-id {target-subscription-id} \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
notify user: "subscription deleted successfully"
pre-check: list subscriptions on topic:
aliyun datahub list-subscriptions \
--region {region} \
--project-name {project-name} \
--topic-name {topic-name} \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
subscription-id and run delete-subscription (step 6a.3) for each, skipping the confirmation prompt (since user already confirmed topic deletion)display confirmation prompt (required):
YOU ARE ABOUT TO DELETE (IRREVERSIBLE):
- topic: {topic-name}
- project: {project-name}
- all subscriptions on this topic
THIS ACTION CANNOT BE UNDONE.
type 'confirm-delete' to proceed, or 'cancel' to abort:
confirm-delete, abortrun delete-topic:
aliyun datahub delete-topic \
--region {region} \
--project-name {project-name} \
--topic-name {topic-name} \
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-datahub-manage/{session-id}
notify user: "topic deleted successfully"