Provision a Dify instance automatically via Alibaba Cloud OpenAPI. Supports Simple Mode (create all resources from scratch) and Advanced Mode (fine-grained control over each component).
[REQUIRED] Verify Aliyun CLI version >= 3.3.1 before proceeding.
bash
aliyun version
If the command is not found or the version is below 3.3.1, install or upgrade:
macOS (Homebrew, recommended)
bash
brew install aliyun-cli
# Upgrade if already installed
brew upgrade aliyun-cli
After installation, enable automatic plugin installation:
bash
aliyun configure set --auto-plugin-install true
[REQUIRED] Generate a session-id at the start of every skill session. Use it consistently across ALL CLI commands and Python SDK calls.
openssl rand -hex 16)bash
export SKILL_SESSION_ID=$(openssl rand -hex 16)
text
AlibabaCloud-Agent-Skills/alibabacloud-dms-data-agent-platform-setup/{session-id}
detect_dify_instance.py, openAPI_call.py): read SKILL_SESSION_ID from environment automatically--user-agent flag on each command:bash
aliyun dms-enterprise <action> \
--endpoint dms-enterprise.aliyuncs.com \
--user-agent "AlibabaCloud-Agent-Skills/alibabacloud-dms-data-agent-platform-setup/${SKILL_SESSION_ID}"
Do NOT use
aliyun configure ai-mode set-user-agent(deprecated). Always use per-command--user-agentinjection.
[REQUIRED] Both credential sets must be configured — Aliyun CLI credentials AND Python SDK credentials. Neither can be omitted. NEVER read, echo, or print AK/SK values.
This skill performs two types of operations, each using a different credential method:
aliyun dms-enterprise list-instances): uses Aliyun CLI credentialsopenAPI_call.py): uses the Alibaba Cloud default credential chainbash
aliyun configure list
Confirm that a valid profile exists in the output (AK, STS, or OAuth).
If no valid profile exists, stop and prompt the user to:
Obtain an AccessKey from the Alibaba Cloud Console
Configure credentials outside of this session to avoid exposing secrets: bash
aliyun configure set \
--mode AK \
--access-key-id <your-access-key-id> \
--access-key-secret <your-access-key-secret> \
--region cn-hangzhou
Re-run aliyun configure list to confirm the profile is active
openAPI_call.py uses the Alibaba Cloud default credential chain — no environment variables need to be set manually. The SDK automatically resolves credentials in the following order: environment variables, credentials file, instance RAM role, etc.
Configure your credentials by following the official guide: Alibaba Cloud Python SDK v2 — Manage Access Credentials
NEVER hardcode AK/SK values in code or pass them as command-line arguments.
It is recommended to use uv to create an isolated virtual environment with pinned dependencies:
bash
uv venv .venv
uv pip install --python .venv/bin/python -r scripts/requirements.txt
requirements.txt is provided in ./scripts/.
./scripts/detect_dify_instance.py — Check whether the DMS Dify service is available in the target region./scripts/openAPI_call.py — Provision a Dify instanceRun commands from the directory containing this
SKILL.mdfile.
[REQUIRED] Before running
openAPI_call.py, rundetect_dify_instance.pyto verify that the DMS service is accessible in the target region.
bash
.venv/bin/python ./scripts/detect_dify_instance.py <region-id>
Example:
bash
.venv/bin/python ./scripts/detect_dify_instance.py cn-shanghai
[]), that is normal — it means no Dify instances exist yet, but the service is available.All components (Workspace, database, KV store, vector database) are newly created.
ParameterDescriptionVpcIdVPC IDVSwitchIdVSwitch IDBackupVSwitchIdBackup VSwitch IDSecurityGroupIdSecurity Group IDZoneIdAvailability Zone IDDataRegionData regionWorkspaceNameName for the new WorkspaceAccountDatabase account (used for DbInstanceAccount, KvStoreAccount, VectordbAccount; default: dify_user)PasswordDatabase password (used for DbInstancePassword, KvStorePassword, VectordbPassword)DryRunRecommended: set to true for a dry run first, then false to provision
bash
.venv/bin/python ./scripts/openAPI_call.py '{
"VpcId": "<VpcId>",
"VSwitchId": "<VSwitchId>",
"BackupVSwitchId": "<BackupVSwitchId>",
"SecurityGroupId": "<SecurityGroupId>",
"ZoneId": "<ZoneId>",
"DataRegion": "<DataRegion>",
"ResourceQuota": "12CU",
"WorkspaceOption": "CreateNewInstance",
"WorkspaceName": "<WorkspaceName>",
"DatabaseOption": "CreateNewInstance",
"DbInstanceAccount": "<account>",
"DbInstancePassword": "<password>",
"KvStoreOption": "CreateNewInstance",
"KvStoreAccount": "<account>",
"KvStorePassword": "<password>",
"VectordbOption": "CreateNewInstance",
"VectordbAccount": "<account>",
"VectordbPassword": "<password>",
"StorageType": "cloud_essd",
"NatGatewayOption": "NoNeed",
"MajorVersion": "1.13.x",
"Edition": "OpenCommunity",
"DryRun": true
}'
Allows fine-grained control over all parameters, including using existing Workspace, database, KV store, and vector database instances.
Ask the user for the following:
ParameterDescriptionVpcIdVPC IDVSwitchIdVSwitch IDBackupVSwitchIdBackup VSwitch IDSecurityGroupIdSecurity Group IDZoneIdAvailability Zone IDDataRegionData region
Ask the user: use an existing Workspace or create a new one?
UseExistingInstance: user must provide WorkspaceId (string)CreateNewInstance: user must provide WorkspaceNameWorkspaceId and WorkspaceName are mutually exclusive. If both are provided, prompt the user to correct the input.Ask the user to choose for each of the following independently:
CreateNewInstance: no additional parameters needed; uses default configuration
UseExistingInstance:
Ask the user if they know the DbResourceId (integer)
If not, run the following command and find the InstanceId from InstanceList.Instance:
bash
aliyun dms-enterprise list-instances \
--endpoint dms-enterprise.aliyuncs.com \
--user-agent "AlibabaCloud-Agent-Skills/alibabacloud-dms-data-agent-platform-setup/${SKILL_SESSION_ID}"
CreateNewInstance: no additional parameters needed
UseExistingInstance:
Ask the user if they know the KvStoreResourceId (integer)
If not, run: bash
aliyun dms-enterprise list-instances \
--endpoint dms-enterprise.aliyuncs.com \
--user-agent "AlibabaCloud-Agent-Skills/alibabacloud-dms-data-agent-platform-setup/${SKILL_SESSION_ID}"
CreateNewInstance: no additional parameters needed
UseExistingInstance:
Ask the user if they know the VectordbResourceId (integer)
If not, run: bash
aliyun dms-enterprise list-instances \
--endpoint dms-enterprise.aliyuncs.com \
--user-agent "AlibabaCloud-Agent-Skills/alibabacloud-dms-data-agent-platform-setup/${SKILL_SESSION_ID}"
Ask the user for account name and password, and fill in:
DbInstanceAccount / DbInstancePasswordKvStoreAccount / KvStorePasswordVectordbAccount / VectordbPasswordThe following parameters have default values. Ask the user if any need to be changed:
ParameterDefaultAllowed ValuesResourceQuota``12CUCustom stringReplicas``1IntegerNatGatewayOption``NoNeed``NoNeed, Enable``PayType``PrePaid``PrePaid, PostPaid``PayPeriodType``Month``Month, Year``PayPeriod``1IntegerMajorVersion``1.13.xCustom stringEdition``OpenCommunity``OpenCommunity, Community, Enterprise``EnableExtraEndpoint``true``true, false``OnlyIntranet``false``true, false``DryRun``trueRecommended: true for dry run first, then false to provision
DryRun=true and run the scriptDryRun to false and run again to provisionWorkspaceId (use existing Workspace) and WorkspaceName (create new Workspace) are mutually exclusiveDbResourceId, KvStoreResourceId, and VectordbResourceId are all integer typesDryRun=true before final provisioningSKILL_SESSION_ID is exported before running any command in this workflow