This guide walks you through calling the DescribeInstanceList operation to query your Anti-DDoS Origin instances — from setting up a RAM user to running sample Python code and verifying the response.
Prerequisites
Before you begin, ensure that you have:
An Alibaba Cloud account
Python 3 installed (Download Python 3)
Basic familiarity with running commands in a terminal
How it works
The workflow consists of three phases:
Set up identity and permissions — Create a Resource Access Management (RAM) user and grant it the Anti-DDoS Origin policy.
Prepare your Python environment — Configure credentials as environment variables and install the required packages.
Run sample code — Download the generated sample from OpenAPI Explorer and verify the response.
Set up identity and permissions
Anti-DDoS Origin supports three identity types: an Alibaba Cloud account, a RAM user, or a RAM role. This guide uses a RAM user.
Create a RAM user
Log in to the RAM console.
Create a RAM user and record the AccessKey pair. For instructions, see Create a RAM user.
For background on identity types and credentials, see Identity, credential, and authorization.
Grant permissions
Go to the Users page in the RAM console.
Find the RAM user and click Add Permissions in the Actions column.
In the Policy section, search for
Yundunddosand select AliyunYundunDDosFullAccess.Click Grant permissions.
Anti-DDoS Origin provides two system policies:
AliyunYundunAntiDDoSBagFullAccess — full management permissions
AliyunYundunAntiDDoSBagReadOnlyAccess — read-only access For custom policies, see RAM authorization.
Create an AccessKey pair
By default, an AccessKey pair is generated when you create a RAM user. If you need to create one manually:
Open the RAM user's details page.
On the Authentication tab, click Create AccessKey.
Save the AccessKey ID and AccessKey Secret. For details, see Create an AccessKey pair.
Prepare your Python environment
Configure environment variables
Store your credentials as environment variables to avoid hard-coding them in your source code. Set the following variables:
ALIBABA_CLOUD_ACCESS_KEY_ID— your AccessKey IDALIBABA_CLOUD_ACCESS_KEY_SECRET— your AccessKey Secret
For setup instructions on Linux, macOS, and Windows, see Configure the Alibaba Cloud AccessKey environment variable.
Install dependencies
pip install alibabacloud_credentials
pip install alibabacloud_ddosbgp20180720==2.0.2
pip install alibabacloud_tea_consoleCall DescribeInstanceList
The DescribeInstanceList operation returns details for one or more Anti-DDoS Origin instances. See the API reference for the full parameter list and the API overview for all available operations.
Download sample code
Set the following parameters, then click Initiate Call:
Parameter Value InstanceIdList["ddosbgp-cn-nwy36lfg****","ddosbgp-cn-zxu3ajul****"]RegionIdcn-hangzhouPageNo1PageSize10Click the SDK Sample Code tab, then select Python in the Languages section.
Click Download Project to download the sample code package.
Extract the package and navigate to the
alibabacloud_sampledirectory.
Run the sample
python sample.pyVerify the result
A successful call returns a JSON response listing your instances:
{
"RequestId": "116D9BB2-57C0-5757-AFFB-8DE6FB13F8FC",
"Total": 2,
"InstanceList": [
{
"Status": "1",
"GmtCreate": 1681983249000,
"AutoRenewal": true,
"IpType": "IPv6",
"InstanceId": "ddosbgp-cn-nwy36lfg****",
"BlackholdingCount": 0,
"ExpireTime": 1713628800000,
"InstanceType": "1",
"CoverageType": 0,
"Remark": "ddos_ipv6_auto"
},
{
"Status": "1",
"GmtCreate": 1688628005000,
"AutoRenewal": true,
"IpType": "IPv4",
"InstanceId": "ddosbgp-cn-zxu3ajul****",
"BlackholdingCount": 0,
"ExpireTime": 1720281600000,
"InstanceType": "1",
"CoverageType": 0,
"Remark": "ddos_autotest"
}
]
}If the response contains your instance IDs in InstanceList, the call succeeded.
If you see an error or an empty InstanceList, check the following:
The environment variables
ALIBABA_CLOUD_ACCESS_KEY_IDandALIBABA_CLOUD_ACCESS_KEY_SECRETare set correctly.The RAM user has the
AliyunYundunDDosFullAccesspolicy attached.The
RegionIdmatches the region where your instances are deployed.
What's next
Browse all available Anti-DDoS Origin operations in the API overview.
Use the same pattern to call other operations by replacing
DescribeInstanceListwith your target operation in OpenAPI Explorer.