|« PreviousNext »|
|Did this page help you? Yes | No | Tell us about it...|
Query requests are HTTP or HTTPS requests that use the HTTP verb GET or POST and a
Query parameter named
Action. For a list of Amazon EC2 API actions, see Actions.
The Amazon EC2 documentation presents the GET requests as URLs, which can be used directly in a browser.
Because the GET requests are URLs, you must URL encode the parameter values. In the Amazon EC2 documentation, we leave the example GET requests unencoded to make them easier to read.
The request consists of the following:
Endpoint: The URL that serves as the entry point for the web service.
Action: The action that you want to perform (for example, use
RunInstance to run an instance).
Parameters: Any parameters for the action; each parameter is separated by an ampersand (&). You must also include authorization parameters that AWS uses to ensure the validity and authenticity of the request. For more information, see Query API Authentication.
The following is an example request that launches instances:
To make these example requests even easier to read, the Amazon EC2 documentation presents them in the following format:
https://ec2.amazonaws.com/?Action=RunInstances &ImageId=ami-2bb65342 &MaxCount=3 &MinCount=1 &Placement.AvailabilityZone=us-east-1b &Monitoring.Enabled=true &AWSAccessKeyId=0GS7553JW74RRM612K02EXAMPLE &Version=2013-10-15 &Expires=2010-10-10T12:00:00Z &Signature=lBP67vCvGlDMBQ1dofZxg8E8SUEXAMPLE &SignatureVersion=2 &SignatureMethod=HmacSHA256
The first line specifies the endpoint of the request. After the endpoint is a question mark (?), which separates the endpoint from the parameters.
Action parameter indicates the action to perform. For a complete
list of actions, see Actions in
the Amazon Elastic Compute Cloud API Reference.
The remaining lines specify additional parameters for the request.
An endpoint is a URL that serves as an entry point for a web service. You can select a regional endpoint for Amazon EC2 when you make your requests to reduce latency. For more information about regions, see Region and Availability Zone Concepts. For information about the endpoints for Amazon EC2, see Regions and Endpoints in the Amazon Web Services General Reference.
If you specify the general endpoint,
ec2.amazonaws.com, we use the
us-east-1. To use a different region, specify
its associated endpoint. For example, if you specify
ec2.us-west-2.amazonaws.com as the endpoint, we
direct your request to the
Each Query request must include required common parameters to handle authentication and selection of an action. For more information, see Common Query Parameters in the Amazon Elastic Compute Cloud API Reference.
Some operations take lists of parameters. These lists are specified using the param.n notation, where n is an integer starting from 1.
The following example adds multiple devices to a block device mapping using a list
http://ec2.amazonaws.com/?Action=RunInstances &ImageId.1=ami-72aa081b ... &BlockDeviceMapping.1.DeviceName=/dev/sdj &BlockDeviceMapping.1.Ebs.NoDevice=true &BlockDeviceMapping.2.DeviceName=/dev/sdh &BlockDeviceMapping.2.Ebs.VolumeSize=300 &BlockDeviceMapping.3.DeviceName=/dev/sdc &BlockDeviceMapping.3.VirtualName=ephemeral1 &AUTHPARAMS
You can send Query requests over either the HTTP or HTTPS protocol.
Regardless of which protocol you use, you must include a signature in every Query request. Amazon EC2 uses Signature Version 2. For more information, see Signature Version 2 Signing Process in the Amazon Web Services General Reference.
In the example Query requests we present in the Amazon EC2 documentation, we omit the
parameters related to authentication to make it easier for you to focus on the
parameters for the action. We replace them with the following literal string to
remind you that you must include these parameters in your request:
In response to a Query request, the service returns an XML data structure that
conforms to an XML schema defined as part of the WSDL
file for Amazon EC2. The structure of an XML response is specific to the associated
request. In general, the response data types are named according to the operation
performed and whether the data type is a container (can have children). Examples of
groupSet for security groups and
for key pairs (see the example that follows). Item elements are children of
containers, and their contents vary according to the container's role.
Every response includes a request ID in a
requestId element. The
value is a unique string that AWS assigns. If you ever have issues with a particular
request, AWS will ask for the request ID to help troubleshoot the issue. The
following shows an example response.
<DescribeKeyPairsResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/"> <requestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</requestId> <keySet> <item> <keyName>gsg-keypair</keyName> <keyFingerprint> 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 </keyFingerprint> </item> </keySet> </DescribeKeyPairsResponse>