All Products
Search
Document Center

Elastic Compute Service:CreatePrefixList

最終更新日:Dec 16, 2024

Creates a prefix list.

Operation description

  • A prefix list is a collection of network prefixes (CIDR blocks) and can be referenced to configure network rules for other resources. For more information, see Overview .

  • When you create a prefix list, take note of the following items:

    • You must specify an IP address family (IPv4 or IPv6) for the prefix list, and cannot change the IP address family after the prefix list is created. You cannot combine IPv4 and IPv6 CIDR blocks in a single prefix list.
    • You must specify the maximum number of entries that the prefix list can contain. You cannot modify the maximum number of entries after the prefix list is created.
    • You can specify entries for the prefix list. Each entry consists of a CIDR block and the description for the CIDR block. The total number of entries cannot exceed the maximum number of entries that you specified.
  • For more information about the limits on prefix lists and other resources, see Limits .

  • You can create Resource Access Management (RAM) users and grant them minimum permissions. This eliminates the need to share the AccessKey pair of your Alibaba Cloud account with other users and reduces security risks for your enterprises. For information about how to grant permissions on prefix lists to RAM users, see Grant a RAM user permissions on prefix lists

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
ecs:CreatePrefixListcreate
*All Resources
*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The ID of the region in which to create the prefix list.

cn-chengdu
MaxEntriesintegerYes

The maximum number of entries that the prefix list can contain. Valid values: 1 to 200.

10
AddressFamilystringYes

The IP address family. Valid values:

  • IPv4
  • IPv6
IPv4
ClientTokenstringNo

The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but you must make sure that the token is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

0c593ea1-3bea-11e9-b96b-88e9fe637760
PrefixListNamestringYes

The name of the prefix list. The name must be 2 to 128 characters in length, and can contain letters, digits, colons (:), underscores (_), periods (.), and hyphens (-). It must start with a letter and cannot start with http://, https://, com.aliyun, or com.alibabacloud.

PrefixListNameSample
DescriptionstringNo

The description of the prefix list. The description must be 2 to 256 characters in length and cannot start with http:// or https://.

This is description.
Entryarray<object>No

The details of entries in the prefix list.

objectNo
DescriptionstringNo

The description in entry N. The description must be 2 to 32 characters in length and cannot start with http:// or https://. Valid values of N: 0 to 200.

Description Sample 01
CidrstringYes

The CIDR block in entry N. Valid values of N: 0 to 200. Take note of the following items:

  • The total number of entries cannot exceed the MaxEntries value.
  • CIDR block types are determined by the IP address family. You cannot combine IPv4 and IPv6 CIDR blocks in a single prefix list.
  • CIDR blocks must be unique across all entries in a prefix list. For example, you cannot specify 192.168.1.0/24 twice in the entries of the prefix list.
  • IP addresses are supported. The system converts IP addresses into CIDR blocks. For example, if you specify 192.168.1.100, the system converts it into the 192.168.1.100/32 CIDR block.
  • If an IPv6 CIDR block is used, the system converts it into the zero compression format and changes uppercase letters into lowercase ones. For example, if you specify 2001:0DB8:0000:0000:0000:0000:0000:0000/32, the system converts it into 2001:db8::/32.

For more information about CIDR blocks, see the What is CIDR? section in the "Network FAQ" topic.

This parameter is empty by default.

192.168.1.0/24

Response parameters

ParameterTypeDescriptionExample
object
PrefixListIdstring

The ID of the prefix list.

pl-x1j1k5ykzqlixdcy****
RequestIdstring

The request ID.

38793DB8-A4B2-4AEC-BFD3-111234E9188D

Examples

Sample success responses

JSONformat

{
  "PrefixListId": "pl-x1j1k5ykzqlixdcy****",
  "RequestId": "38793DB8-A4B2-4AEC-BFD3-111234E9188D"
}

Error codes

HTTP status codeError codeError messageDescription
400MissingParameter%sA parameter is not specified.
400InvalidParameter.AddressFamilyThe parameter AddressFamily should be IPv4 or IPv6.The specified AddressFamily parameter is invalid. The valid values of this parameter are IPv4 and IPv6.
400InvalidParameter%sThe specified parameter is invalid.
400InvalidParameter.PrefixListNameThe parameter PrefixListName is not valid.The prefix list name is invalid.
400InvalidDescription.MalformedThe specified Description is wrongly formed.The resource description is invalid. The description must be 2 to 256 characters in length and cannot start with http:// or https://.
400InvalidClientToken.ValueNotSupportedThe ClientToken provided is invalid.The specified ClientToken parameter is invalid.
400InvalidParameter.CidrMalformed%sThe specified CIDR block is invalid.
400InvalidParameter.CidrDuplicated%sDuplicate CIDR blocks are specified.
400LimitExceed.EntryThe number of entries added or removed exceeds the limit.The number of entries to add or remove at a time exceeds the upper limit.
400LimitExceed.MaxEntriesThe number of entries exceeds the MaxEntries of the specified prefix list.The number of specified entries exceeds the MaxEntries value.
404LimitExceed.PrefixListPerRegionThe number of prefix lists in the region exceeds the limit.The maximum number of prefix lists in the current region has been reached.
404InvalidRegionId.NotFoundThe specified RegionId does not exist.The specified region ID does not exist.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-11-13The Error code has changedView Change Details