Subnet_Operations for the Amazon EC2 REST adapter
This topic illustrates the adapter requests and responses for Subnet operations.
Create Subnet operation
The Create Subnet operation enables you create a subnet in an existing virtual private cloud (VPC). You can create up to 20 subnets in a VPC. If you add more than one subnet to a VPC, they are set up in a star topology with a logical router in the middle. The smallest subnet (and VPC) that you can create uses a /28 netmask (16 IP addresses) and the largest uses a /16 netmask (65,536 IP addresses).
The following figure shows a sample <items> XML element for the Create Subnet operation.
Sample <items> XML element for the Create Subnet operation
<item>
<parameters>
<vpc-id></vpc-id>
<cidr-block></cidr-block>
<!--Optional:-->
<availability-zone></availability-zone>
</parameters>
</item>
</items>
The following table describes the elements for this adapter request.
Adapter request elements for the Create Subnet operation
Element | Definition | Required |
---|---|---|
<access-key> | Specifies the Amazon Web Services (AWS) access key You need to generate the AWS access key by going to the Security Credentials tab in the AWS console. | Conditional;
|
<secret-key> | Specifies the AWS secret access key You need to generate the AWS secret access key by going to the Security Credentials tab in the AWS console. | Conditional;
|
<region> | Specifies the region with which you want the adapter to communicate Amazon EC2 is hosted in multiple locations world-wide. You must specify the region in which you want the adapter to perform the actions. Valid values:
| No |
<operation-name> | Contains the name of the operation: create-subnet | Yes |
<parameters> | Contains the elements required to execute the operation | Yes |
<vpc-id> | Specifies the ID of the VPC where you want to create the subnet | Yes |
<cidr-block> | Specifies the Classless Inter-Domain Routing (CIDR) block that you want the subnet to cover (for example, 10.0.0.0/24) | Yes |
<availability-zone> | Specifies the Availability Zone in which the subnet should reside | No |
The following figure shows a sample adapter request for the Create Subnet operation.
Sample adapter request for the Create Subnet operation
<operation-name>create-subnet</operation-name>
<access-key>AKIA***********8BT2Q</access-key>
<secret-key>WQisk8Irh********************8AiJx3VQVd</secret-key>
<region>us-east-1</region>
<parameters>
<vpc-id>vpc-ad9d70c8</vpc-id>
<cidr-block>10.0.0.0/28</cidr-block>
<!-Optional:->
<availability-zone></availability-zone>
</parameters>
</amazon-ec2-rest-request>
The following figure shows the response for the sample Create Subnet operation.
Sample adapter response for the Create Subnet operation
<metadata>
<status>success</status>
</metadata>
<CreateSubnetResponse>
<subnet>
<subnetId>subnet-ff5776b9</subnetId>
<state>pending</state>
<vpcId>vpc-ad9d70c8</vpcId>
<cidrBlock>10.0.0.0/28</cidrBlock>
<availableIpAddressCount>11</availableIpAddressCount>
<availabilityZone>us-east-1c</availabilityZone>
</subnet>
</CreateSubnetResponse>
</amazon-ec2-rest-response>
Delete Subnet operation
The Delete Subnet operation enables you delete a subnet from a virtual private cloud (VPC). You must terminate all running instances in the subnet before deleting it; otherwise, Amazon VPC returns an error.
The following figure shows a sample <items> XML element for the Delete Subnet operation.
Sample <items> XML element for the Delete Subnet operation
<item>
<parameters>
<subnet-id></subnet-id>
</parameters>
</item>
</items>
The following table describes the elements for this adapter request.
Adapter request elements for the Delete Subnet operation
Element | Definition | Required |
---|---|---|
<access-key> | Specifies the Amazon Web Services (AWS) access key You need to generate the AWS access key by going to the Security Credentials tab in the AWS console. | Conditional;
|
<secret-key> | Specifies the AWS secret access key You need to generate the AWS secret access key by going to the Security Credentials tab in the AWS console. | Conditional;
|
<region> | Specifies the region with which you want the adapter to communicate Amazon EC2 is hosted in multiple locations world-wide. You must specify the region in which you want the adapter to perform the actions. Valid values:
| No |
<operation-name> | Contains the name of the operation:delete-subnet | Yes |
<parameters> | Contains the <subnet-id> element required to execute the operation | Yes |
<subnet-id> | Specifies the ID of the subnet that you want to delete | Yes |
The following figure shows a sample adapter request for the Delete Subnet operation.
Sample adapter request for the Delete Subnet operation
<operation-name>delete-subnet</operation-name>
<access-key>AKIA***********8BT2Q</access-key>
<secret-key>WQisk8Irh********************8AiJx3VQVd</secret-key>
<region>us-east-1</region>
<parameters>
<subnet-id>subnet-ff5776b9</subnet-id>
</parameters>
</amazon-ec2-rest-request>
The following figure shows the sample response for the Delete Subnet operation.
Sample adapter response for the Delete Subnet operation
<metadata>
<status>success</status>
</metadata>
<DeleteSubnetResponse>
<return>true</return>
</DeleteSubnetResponse>
</amazon-ec2-rest-response>
Describe Subnet operation
The Describe Subnets operation enables you to retrieve information about your subnets.
You can filter the results to return information only about those subnets that match the criteria that you specify. For example, you could get information only about those subnets whose state is available. Also, you can specify multiple values for the filter. For example, the subnet is in a particular virtual private cloud (VPC), and the state of the subnet is available. However, at least one of the specified values must match a subnet to obtain results.
The result includes information for a particular subnet only if it matches all the specified filters. If there is no match, no special message is returned; the response is empty.
You can use wildcard characters with the filters:
- Use the asterisk (*) to match any number of characters.
- Use the question mark (?) to match a single character.
To escape a special character or metacharacter that has a special meaning in searches, precede the special character with a backslash (\ ).
The following table shows the available filters.
Filter Name | Description |
---|---|
availability-zone | Specifies the Availability Zone in which the subnet resides |
available-ip-address-count | Specifies the number of IP addresses that are available in the subnet |
cidr | Specifies the Classless Inter-Domain Routing (CIDR) block of the subnet |
state | Specifies the state of the subnet |
subnet-id | Specifies the ID of the subnet |
tag-key | Species the key assigned to a resource |
tag-value | Specifies the value of the tag assigned to the resource |
Filters the results based on a specific tag-value combination | |
vpc-id | Specifies the ID of the VPC that the subnet is in |
The following figure shows a sample <items> XML element for the Describe Subnets operation.
Sample <items> XML element for the Describe Subnets operation
<item>
<parameters>
<subnet-set>
<!--Zero or more repetition-->
<item>
<subnet-id></subnet-id>
</item>
</subnet-set>
<!--Optional:-->
<filter-set>
<!--Zero or more repetition-->
<item>
<name></name>
<value-set>
<!--Zero or more repetition-->
<item>
<value></value>
</item>
</value-set>
</item>
</filter-set>
</parameters>
</item>
</items>
The following table describes the elements for this adapter request.
Adapter request elements for the Describe Subnets operation
Element | Definition | Required |
---|---|---|
<access-key> | Specifies the Amazon Web Services (AWS) access key You need to generate the AWS access key by going to the Security Credentials tab in the AWS console. | Conditional;
|
<secret-key> | Specifies the AWS secret access key You need to generate the AWS secret access key by going to the Security Credentials tab in the AWS console. | Conditional;
|
<region> | Specifies the region with which you want the adapter to communicate Amazon EC2 is hosted in multiple locations world-wide. You must specify the region in which you want the adapter to perform the actions. Valid values:
| No |
<operation-name> | Contains the name of the operation:describe-subnets | Yes |
<parameters> | Contains the elements required to execute the operation | Yes |
<subnet-set> | Contains the list of subnets | No |
<item> | Contains information about an individual subnet | No |
<subnet-id> | Specifies the ID of the subnet whose information you want to retrieve | No |
<filter-set> | Specifies the details of the filter with thefilterName and filterValue that are used to retrieve specific information about the subnet | No |
The following figure shows a sample adapter request for the Describe Subnets operation.
Sample adapter request for the Describe Subnets operation
<access-key>AKIAI**********GROKA</access-key>
<secret-key>6hXjoZZDvWx**********1y2Yte/jZfnY6WgKCdC</secret-key>
<region>us-west-2</region>
<operation-name>describe-subnets</operation-name>
<parameters>
<subnet-set>
<item>
<subnet-id>subnet-b2376bf4</subnet-id>
</item>
</subnet-set>
<filter-set>
<item>
<name>availability-zone</name>
<value-set>
<item>
<value>us-west-2c</value>
<value>vpc-ff1f0f9d1</value>
</item>
</value-set>
</item>
</filter-set>
</parameters>
</amazon-ec2-rest-request>
The following figure shows the response for the sample Describe Subnets operation.
Sample adapter response for the Describe Subnets operation
<metadata>
<status>success</status>
</metadata>
<DescribeSubnetsResponse>
<subnetSet>
<item>
<subnetId>subnet-b2376bf4</subnetId>
<state>available</state>
<vpcId>vpc-ff1f0f9d</vpcId>
<cidrBlock>10.0.0.0/25</cidrBlock>
<availableIpAddressCount>123</availableIpAddressCount>
<availabilityZone>us-west-2c</availabilityZone>
</item>
</subnetSet>
</DescribeSubnetsResponse>
</amazon-ec2-rest-response>