Terminal
Terminal/Skill
Diagnoses why an ECS instance, or a DataWorks, SAE or ACK service, cannot reach the public internet, covering security groups and NAT.
By Alibaba Cloud
Works with
npx skills add aliyun/alibabacloud-aiops-skills --skill alibabacloud-ecs-vpc-publicnetwork-troubleshootAutomated diagnosis of public network connectivity for Alibaba Cloud ECS instances and VPC cloud services. Two core capabilities only:
All diagnostic operations MUST be performed by invoking the bundled Python scripts under scripts/. There are exactly three:
| Allowed invocation | Purpose |
|---|---|
python3 scripts/sts_create.py | Obtain/validate credentials (runs first) |
python3 scripts/ecs_public_troubleshoot.py | ECS public network diagnosis |
python3 scripts/vpc_service_public_troubleshoot.py | VPC cloud service diagnosis |
Forbidden — do NOT reproduce the diagnostic logic by any other means (each is a structural violation, even if the output looks correct):
aliyun ecs ... / aliyun vpc ... / aliyun natgateway ... / aliyun antiddos-public ... / aliyun cloudfw ... / aliyun bssopenapi ... or any other aliyun CLI command for diagnosis;aliyun configure get or any command to fetch credentials manually;01_describe_ecs.sh, ...) or inline SDK/curl/HTTP code.If a script fails (non-zero exit, no JSON, credential/authorization error), stop and report the error — never fall back to any of the above.
sts_create.py runs first and writes credentials to the local cache scripts/.sts_cache.json. The two main scripts (ecs_public_troubleshoot.py, vpc_service_public_troubleshoot.py) read that cache automatically. The agent MUST NOT:
ALIBABA_CLOUD_* variables manually, pass --access-key-id / --access-key-secret / --sts-token (the scripts do not accept them), or run aliyun configure get;If sts_create.py fails, abort immediately and report the credential/authorization error.
This skill makes read-only Alibaba Cloud API calls only (Describe* / GetCallerIdentity queries); it never creates, modifies, deletes, restarts, or otherwise changes any resource. Before invoking any script:
instance_id / vswitch_id), the region_id, and that only read-only diagnostic APIs will be called against that single resource.| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| region_id | string | Yes | Alibaba Cloud region ID | cn-hangzhou |
| test_scenario | string | Yes | ecs_public / vpc_service_public (inferred from identifiers) | ecs_public |
| instance_id | string | ECS scenario | ECS instance ID | i-bp116m5pkhsle6xm5pl8 |
| vswitch_id | string | VPC scenario | VSwitch ID | vsw-bp1xat3xsvck79y8zo8yo |
| uid | string | No | Account UID (auto-obtained from credentials if omitted) | 1552974654746705 |
| service_type | string | No | Cloud service type (VPC scenario): dataworks / sae / ack / others | dataworks |
| output_format | string | No | table / json / markdown | table |
Mandatory-parameter gate: region_id plus the scenario identifier (instance_id for ECS, vswitch_id for VPC) are required. Extract everything already present in the user's prompt first. If a mandatory field is still missing, ask the user once; if it is still not provided, abort with:
Missing required parameters: [<comma-separated list>]. Aborting diagnostic workflow.
Do NOT fabricate/guess mandatory values or read external metadata to infer them.
| Module | Purpose | File |
|---|---|---|
| Preparation | Credential acquisition and CLI call templates | references/module1_preparation.md |
| RAM Policies | Minimum read-only privilege list | references/ram-policies.md |
| Scenario 1: ECS Public Network | ECS script invocation, JSON output, status logic | references/module2_ecs_public.md |
| Scenario 2: VPC Service Public | VPC script invocation, JSON output, status logic | references/module3_vpc_service.md |
| Output & Judgment | Info-table format and status column logic | references/module4_output.md |
| Solutions | Remediation advice for abnormal items | references/module5_solution.md |
Load on demand: read only the reference relevant to the current task.
Input Parsing (extract region_id + identifiers)
└─▶ Credentials: python3 scripts/sts_create.py (abort on credential/authorization error)
└─▶ Scenario Detection: instance_id → ECS scenario; vswitch_id → VPC scenario
└─▶ Main Script: ecs_public_troubleshoot.py / vpc_service_public_troubleshoot.py
│ (parallel sub-checks: ECS/SG, VPC/Route/NAT/SNAT/EIP, DDoS, CFW, account status)
└─▶ Result Rendering (module4_output.md): Branch A (direct public) or Branch B (NAT)
└─▶ Solution Output for abnormal items (module5_solution.md)
Principles: strict order (abort on any step failure, never skip or fall back); the main script decides Branch A vs Branch B by whether the ECS has a public IP/EIP.
region_id, and read-only scope to the user and confirm to proceed, per "User Confirmation" above. Do NOT invoke any script or API before this step.python3 scripts/sts_create.py; on SDK.InvalidCredential / InvalidAccessKeyId / SignatureDoesNotMatch / Forbidden / any auth error / non-zero exit, abort and report.instance_id → ECS scenario; vswitch_id → VPC scenario.python3 scripts/ecs_public_troubleshoot.py \
--region-id <region_id> \
--instance-id <instance_id> \
[--uid <UID>]
python3 scripts/vpc_service_public_troubleshoot.py \
--region-id <region_id> \
--vswitch-id <vswitch_id> \
[--uid <UID>]
Credentials are read from
sts_create.py's local cache (scripts/.sts_cache.json); scripts do not accept credential parameters. Never export plaintext credentials on the command line.
AlibabaCloud-Agent-Skills/{SKILL_NAME}/{session-id}, where {SKILL_NAME} is this skill's frontmatter name — alibabacloud-ecs-vpc-publicnetwork-troubleshoot — and {session-id} is the session identifier described below. Resolved example: AlibabaCloud-Agent-Skills/alibabacloud-ecs-vpc-publicnetwork-troubleshoot/4eefc3a1be2102b3eb41463c84e98e9b.uuid.uuid4().hex), and kept consistent across the SDK and aliyun CLI backends touched in that session. It is cached via the SKILL_SESSION_ID environment variable so every script in one session reports the same id.append_user_agent; the CLI backend propagates the same value through the ALIBABACLOUD_USER_AGENT environment variable. This User-Agent is the only tracing marker this skill injects; all calls remain read-only.sts_create.py / SDK default chain.aliyun CLI, ad-hoc/numbered shell scripts, inline SDK code, or evaluation-metadata guessing.pip install -r scripts/requirements.txt).aliyun/alibabacloud-aiops-skills.Input: "Check the public connectivity of instance i-bp116m5pkhsle6xm5pl8 in cn-hangzhou."
sts_create.py for credentialspython3 scripts/ecs_public_troubleshoot.py --region-id cn-hangzhou --instance-id i-bp116m5pkhsle6xm5pl8branch="A" → render Direct Public info table (instance / security group / DDoS / CFW)Input: "Public access to TCP 80 of i-bp116m5pkhsle6xm5pl8 in cn-hangzhou is blocked — is the security group blocking it?"
sts_create.pyInput: "DataWorks cannot access the public network, VSwitch vsw-bp1xat3xsvck79y8zo8yo in cn-hangzhou."
sts_create.pypython3 scripts/vpc_service_public_troubleshoot.py --region-id cn-hangzhou --vswitch-id vsw-bp1xat3xsvck79y8zo8yo