|
aliyun configure set --auto-plugin-install true
CLI_VERSION=$(aliyun version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
[ "$(printf '%s\n' "3.3.2" "$CLI_VERSION" | sort -V | head -n1)" != "3.3.2" ] && echo "❌ CLI < 3.3.2" && exit 1
aliyun product command MUST include --user-agent AlibabaCloud-Agent-Skills (NOT on configure commands)aliyun vpc allocate-eip-address, NOT INLINECODE4--biz-region-id only sets the RegionId parameter in the API request body; it does NOT control which API endpoint the CLI connects to. The API endpoint is determined by the CLI profile's configured region. Before running any VPC command, you MUST set the CLI profile region to match the target region: aliyun configure set --region {REGION}
jq is NOT available — use grep to parse JSON outputCREATED_EIPS: Array of EIP AllocationIds created in this session (for user-controlled cleanup on failure)USE_EXISTING_EIP = false)cn-beijing, cn-hangzhou) - MUST be explicitly provided, no defaultNetworkInterface: Must have PrivateIpAddress (private IP to bind)
- If IpAddress: Must have VpcId (VPC ID where IP address resides)
If ANY required parameter is missing, STOP and ask user:
❌ Missing: Region[REQUIRED] | ResourceType[ECS/ENI/CLB/NAT/HAVIP/IP] | ResourceID | [PrivateIP for ENI] | [VpcId for IP]
CRITICAL:
^[a-z]{2,3}-[a-z]+-\d*[a-z]*$ (e.g., cn-beijing, ap-southeast-1)aliyun configure set --region {REGION}
This ensures the CLI connects to the correct regional API endpoint.
| User Input | AssociatedInstanceType Value |
|---|---|
| ECS | EcsInstance |
| ENI |
aliyun vpc describe-eip-addresses \
--biz-region-id {REGION} \
--associated-instance-type {INSTANCE_TYPE} \
--associated-instance-id {RESOURCE_ID} \
--user-agent AlibabaCloud-Agent-Skills
Check response:
If TotalCount > 0 (resource already has EIP bound):
❌ ERROR: Resource {RESOURCE_ID} already has EIP bound.
Existing EIP: {EipAddress} | ID: {AllocationId} | Bandwidth: {Bandwidth}Mbps | Status: {Status}
To bind a different EIP, first unbind existing: aliyun vpc unassociate-eip-address --biz-region-id {REGION} --allocation-id {AllocationId} --instance-id {RESOURCE_ID} --instance-type {INSTANCE_TYPE}
STOP. Do not proceed.
If TotalCount = 0 (resource has no EIP bound):
✅ Resource {RESOURCE_ID} has no EIP bound. Proceeding to next validation...
Continue to Step 1.3.5.
Purpose: Check if the ECS instance already has a Public IP (PIP) assigned at creation time. PIP is different from EIP:This step is ONLY executed when
INSTANCE_TYPE = EcsInstance.
For other resource types (ENI, CLB, NAT, HAVIP, IP), skip directly to Step 1.4.
aliyun ecs describe-instance-attribute \
--instance-id {RESOURCE_ID} \
--user-agent AlibabaCloud-Agent-Skills
Parse response and check PublicIpAddress field:
Case 1: PublicIpAddress.IpAddress is not empty (ECS has PIP):
❌ ERROR: ECS instance {RESOURCE_ID} already has a Public IP (PIP) assigned.
Public IP: {PublicIpAddress.IpAddress[0]} | Type: PIP (fixed, created with ECS)
⚠️ You CANNOT bind an EIP to an ECS instance that already has a PIP.
Options:
1. Use the existing Public IP (no action needed)
2. Convert PIP to EIP (requires ECS Stopped): aliyun vpc convert-nat-public-ip-to-eip --biz-region-id {REGION} --instance-id {RESOURCE_ID}
3. Release and recreate ECS without PIP
Operation stopped.
STOP. Do not proceed.
Case 2: PublicIpAddress.IpAddress is empty (no PIP):
✅ ECS instance {RESOURCE_ID} has no Public IP (PIP). Ready to bind EIP.
Continue to Step 1.4.
Case 3: API call fails (e.g., InvalidInstanceId.NotFound):
❌ ERROR: ECS instance {RESOURCE_ID} not found in region {REGION}.
Error: {ERROR_CODE} - {ERROR_MESSAGE}
Please verify: instance ID, region, and permissions.
STOP. Do not proceed.
Options for {RESOURCE_TYPE} {RESOURCE_ID}:
A) Use existing EIP (query available or provide ID)
B) Create new EIP (configure bandwidth, ISP, billing)
Choice (A/B):
If user selects Option A (use existing EIP), proceed to Step 1.5.
If user selects Option B (create new EIP), proceed to Step 1.6.
Have specific EIP ID? (yes: provide ID / no: query available)
If user provides EIP ID:
Query all Available EIPs in the region:
aliyun vpc describe-eip-addresses \
--biz-region-id {REGION} \
--status Available \
--page-size 100 \
--user-agent AlibabaCloud-Agent-Skills
TotalCount > 100, make multiple requests with --page-number 2, 3, ... until all Available EIPs are retrievedTotalCount = 0):❌ No available EIPs in {REGION}. Create new EIP? (yes/no)
Found {TOTAL_COUNT} available EIP(s) in {REGION}:
1. eip-bp1xxx | 47.1.2.3 | 5Mbps | BGP | PayByTraffic
2. eip-bp1yyy | 47.4.5.6 | 10Mbps | BGP | PayByBandwidth
...
Select: Enter number (1-5), EIP ID, or "new" for new EIP:
Wait for user selection.
Validate user selection:
AllocationId.
Set USE_EXISTING_EIP = true (to skip EIP allocation in Phase 2).
Skip to Phase 3 (bind existing EIP).
Create new EIP in {REGION} for {RESOURCE_TYPE} {RESOURCE_ID}.
Config (Enter for defaults): Bandwidth[5Mbps] | ISP[BGP/BGP_PRO] | Billing[PayByTraffic/PayByBandwidth] | Purpose[optional for naming]
Defaults: BANDWIDTH=5, ISP=BGP, INTERNETCHARGETYPE=PayByTraffic
EIP Naming: If purpose provided, generate name: eip-{purpose}-{resource_type} (e.g., eip-web-ecs)
Set USE_EXISTING_EIP = false (will allocate new EIP in Phase 2).
IMPORTANT: Always create PayByTraffic (pay-by-traffic) EIP by default unless user explicitly requests PayByBandwidth.
IMPORTANT: PrePaid (subscription/包年包月) EIP is NOT supported by this skill. If user requests PrePaid EIP, respond:
❌ This skill does not support creating PrePaid (subscription) EIPs.
Please create PrePaid EIPs through the Alibaba Cloud Console: https://vpc.console.aliyun.com/eip
STOP. Do NOT proceed.
Continue to Phase 1.7 (pre-allocation validation) if creating new EIP.
This step is ONLY executed when
USE_EXISTING_EIP = false(creating new EIP).
If using existing EIP, skip directly to Phase 3.
aliyun vpc describe-eip-addresses --biz-region-id {REGION} --page-size 100
If approaching 20 (standard limit), show quota warning. This is a soft check.
aliyun ecs describe-instances --instance-ids '["ID"]'
aliyun ecs describe-network-interfaces --network-interface-id '["ID"]'
aliyun slb describe-load-balancer-attribute --load-balancer-id ID
aliyun vpc describe-nat-gateways --nat-gateway-id ID
For HaVip: aliyun vpc describe-havips --havip-id ID
For IpAddress: aliyun vpc describe-vpcs --vpc-id ID
Note: If resource not found, STOP before Phase 2.
Show user a summary:
✅ Pre-allocation validation passed!
Region: {REGION} | Target: {INSTANCE_TYPE} {RESOURCE_ID} | Status: {STATUS}
EIP Config: {BANDWIDTH}Mbps | {ISP} | {INTERNET_CHARGE_TYPE} [Name: {EIP_NAME}]
Proceeding to allocate EIP...
This phase is ONLY executed when
USE_EXISTING_EIP = false(creating new EIP).
If using existing EIP (USE_EXISTING_EIP = true), skip directly to Phase 3 (bind).
CLIENT_TOKEN=$(uuidgen | tr -d '-' | head -c 32)
Build command dynamically:
aliyun vpc allocate-eip-address \
--biz-region-id {REGION} \
--bandwidth {BANDWIDTH} \
--isp {ISP} \
--internet-charge-type {INTERNET_CHARGE_TYPE} \
--client-token $CLIENT_TOKEN \
[--name "{EIP_NAME}"] \
--user-agent AlibabaCloud-Agent-Skills
Notes:
--client-token ensures idempotency: same token within 10min returns same EIP--name parameter if EIP_NAME is not empty--internet-charge-type PayByTraffic (pay-by-traffic)AllocationId: EIP instance ID (e.g., eip-bp1xxx)47.1.2.3)CREATED_EIPS.append(AllocationId)
QuotaExceeded.Eip: STOP. List current EIPs if user wants.
Other errors (InvalidParameter, InsufficientBalance): STOP immediately.
for i in {1..30}; do
aliyun vpc describe-eip-addresses \
--biz-region-id {REGION} \
--allocation-id {ALLOCATION_ID} \
--user-agent AlibabaCloud-Agent-Skills
# Check if Status = "Available"
# If Available: break
# If not: sleep 5 seconds and retry
done
If status is NOT "Available" after 30 retries:
❌ ERROR: EIP {ALLOCATION_ID} not Available after 150s. Status: {CURRENT_STATUS}. Cleaning up...
Trigger cleanup (go to Phase 4: Cleanup on Failure).
✅ EIP allocated successfully!
EIP: {EipAddress} | ID: {AllocationId} | {BANDWIDTH}Mbps | {ISP} | {INTERNET_CHARGE_TYPE}
Proceeding to bind to {RESOURCE_TYPE} {RESOURCE_ID}...
aliyun vpc associate-eip-address \
--biz-region-id {REGION} \
--allocation-id {ALLOCATION_ID} \
--instance-id {RESOURCE_ID} \
--instance-type {INSTANCE_TYPE} \
[--private-ip-address {PRIVATE_IP}] \
[--vpc-id {VPC_ID}] \
--user-agent AlibabaCloud-Agent-Skills
Instance Type Mapping:| User Input | CLI --instance-type Value | Additional Required Params |
|---|---|---|
| ECS | EcsInstance | None |
| ENI |
INSTANCE_TYPE = NetworkInterface and PRIVATE_IP is empty: ERROR - PrivateIpAddress REQUIRED. STOP.INSTANCE_TYPE = IpAddress and VPC_ID is empty: ERROR - VpcId REQUIRED. STOP.RequestId and proceed to verification.
| Error Code | Meaning | Action |
|---|---|---|
| INLINECODE64 | ECS already has system-assigned public IP (PIP) | STOP. Show error. Trigger cleanup. PIP and EIP are mutually exclusive. |
| INLINECODE65 |
InvalidInstanId.NotFound | Resource ID does not exist (CLB/SLB) | STOP. Show error. Trigger cleanup. |
| ResourceNotFound.NetworkInterface | ENI does not exist | STOP. Show error. Trigger cleanup. |
| InvalidParams.NotFound | NAT/HAVIP does not exist | STOP. Show error. Trigger cleanup. |
| InvalidAssociation.Duplicated | Resource already has EIP bound | STOP. Show error. Trigger cleanup. |
| IncorrectEipStatus | EIP status not ready | Retry up to 3 times (wait 5s between retries). If still fails, STOP and trigger cleanup. |
| InvalidParameter.* | Invalid parameter value | STOP. Show error. Trigger cleanup. |
Error message template:
❌ ERROR: Failed to bind EIP to {RESOURCE_TYPE} {RESOURCE_ID}
Error: {ERROR_CODE} - {ERROR_MESSAGE}
Possible causes: Resource not exist, already has EIP bound, wrong state, invalid parameters.
Cleaning up...
Trigger cleanup (Phase 4).
CRITICAL: Do NOT retry indefinitely. Do NOT query resources to "fix" the issue. Fail fast and cleanup.
aliyun vpc describe-eip-addresses \
--biz-region-id {REGION} \
--allocation-id {ALLOCATION_ID} \
--user-agent AlibabaCloud-Agent-Skills
Expected response:
Status: INLINECODE73✅ SUCCESS: EIP binding completed!
EIP: {EipAddress} | ID: {AllocationId} | Bound to: {INSTANCE_TYPE} {RESOURCE_ID} | Region: {REGION} | Status: InUse
Remove from cleanup tracking:
CREATED_EIPS.remove(AllocationId) # Binding successful, no cleanup needed
If verification fails (Status != InUse or wrong InstanceId):
⚠️ WARNING: Binding command succeeded but verification failed.
Expected: Status=InUse, InstanceId={RESOURCE_ID}
Actual: Status={ACTUAL_STATUS}, InstanceId={ACTUAL_INSTANCE_ID}
Please check EIP status manually in Console.
Do NOT trigger cleanup in this case (binding may be in progress).
This phase is ONLY executed when an unrecoverable error occurs during Phase 2 or Phase 3.
IMPORTANT: Only applies to newly created EIPs (USE_EXISTING_EIP = false). Do NOT release user's existing EIPs.
CREATED_EIPS is not empty (newly created EIP in this session):
List the newly created EIPs:
aliyun vpc describe-eip-addresses \
--biz-region-id {REGION} \
--allocation-id {ALLOCATION_ID} \
--user-agent AlibabaCloud-Agent-Skills
❌ ERROR: EIP binding failed. Error: {ERROR_CODE} - {ERROR_MESSAGE}
Newly Created EIP: {EipAddress} | ID: {AllocationId} | {BANDWIDTH}Mbps | {ISP}
⚠️ This EIP was created but binding failed.
Options: A) Keep EIP (bind later) | B) Release EIP (avoid charges)
Your choice (A/B):
# If InUse: aliyun vpc unassociate-eip-address --allocation-id {ALLOCATION_ID} --instance-id {INSTANCE_ID} --instance-type {INSTANCE_TYPE}
# Release: aliyun vpc release-eip-address --allocation-id {ALLOCATION_ID}
Success: ✅ Released EIP {AllocationId}
Fail: INLINECODE81
✅ EIP {AllocationId} ({EipAddress}) kept. Bind later with: aliyun vpc associate-eip-address --allocation-id {AllocationId} --instance-id <ID> --instance-type <TYPE>
Operation aborted. Binding: Failed | Error: {ERROR_CODE} | EIP: {AllocationId} | Cleanup: [Kept/Released]
| Error Code | Action |
|---|---|
| INLINECODE82 | STOP. User resolves quota manually. |
| INLINECODE83 |
InvalidInstance.NotExist, InvalidInstanId.NotFound, ResourceNotFound.*, InvalidParams.NotFound | STOP. Resource not found. |
| InvalidAssociation.Duplicated | STOP. Already has EIP. |
| IncorrectEipStatus | Retry 3x (5s wait), then STOP. |
| InvalidParameter.* | STOP. Invalid parameters. |
| InsufficientBalance | STOP. No cleanup (allocation failed). |
Fail Fast: STOP on unrecoverable errors, ask user for cleanup decision.
| Document | Description |
|---|---|
| references/cli-commands.md | CLI command examples for all EIP operations |
| AssociateEipAddress API |
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 alibabacloud-network-eip-associate-1775918582 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 alibabacloud-network-eip-associate-1775918582 技能
skillhub install alibabacloud-network-eip-associate-1775918582
文件大小: 19 KB | 发布时间: 2026-4-12 08:52