GetInstances
Returns information about all Amazon Lightsail virtual private servers, or instances.
Request Syntax
{
"pageToken": "string
"
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
- pageToken
-
The token to advance to the next page of results from your request.
To get a page token, perform an initial
GetInstances
request. If your results are paginated, the response will return a next page token that you can specify as the page token in a subsequent request.Type: String
Required: No
Response Syntax
{
"instances": [
{
"addOns": [
{
"duration": "string",
"name": "string",
"nextSnapshotTimeOfDay": "string",
"snapshotTimeOfDay": "string",
"status": "string",
"threshold": "string"
}
],
"arn": "string",
"blueprintId": "string",
"blueprintName": "string",
"bundleId": "string",
"createdAt": number,
"hardware": {
"cpuCount": number,
"disks": [
{
"addOns": [
{
"duration": "string",
"name": "string",
"nextSnapshotTimeOfDay": "string",
"snapshotTimeOfDay": "string",
"status": "string",
"threshold": "string"
}
],
"arn": "string",
"attachedTo": "string",
"attachmentState": "string",
"autoMountStatus": "string",
"createdAt": number,
"gbInUse": number,
"iops": number,
"isAttached": boolean,
"isSystemDisk": boolean,
"location": {
"availabilityZone": "string",
"regionName": "string"
},
"name": "string",
"path": "string",
"resourceType": "string",
"sizeInGb": number,
"state": "string",
"supportCode": "string",
"tags": [
{
"key": "string",
"value": "string"
}
]
}
],
"ramSizeInGb": number
},
"ipAddressType": "string",
"ipv6Addresses": [ "string" ],
"isStaticIp": boolean,
"location": {
"availabilityZone": "string",
"regionName": "string"
},
"metadataOptions": {
"httpEndpoint": "string",
"httpProtocolIpv6": "string",
"httpPutResponseHopLimit": number,
"httpTokens": "string",
"state": "string"
},
"name": "string",
"networking": {
"monthlyTransfer": {
"gbPerMonthAllocated": number
},
"ports": [
{
"accessDirection": "string",
"accessFrom": "string",
"accessType": "string",
"cidrListAliases": [ "string" ],
"cidrs": [ "string" ],
"commonName": "string",
"fromPort": number,
"ipv6Cidrs": [ "string" ],
"protocol": "string",
"toPort": number
}
]
},
"privateIpAddress": "string",
"publicIpAddress": "string",
"resourceType": "string",
"sshKeyName": "string",
"state": {
"code": number,
"name": "string"
},
"supportCode": "string",
"tags": [
{
"key": "string",
"value": "string"
}
],
"username": "string"
}
],
"nextPageToken": "string"
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- instances
-
An array of key-value pairs containing information about your instances.
Type: Array of Instance objects
- nextPageToken
-
The token to advance to the next page of results from your request.
A next page token is not returned if there are no more results to display.
To get the next page of results, perform another
GetInstances
request and specify the next page token using thepageToken
parameter.Type: String
Errors
For information about the errors that are common to all actions, see Common Errors.
- AccessDeniedException
-
Lightsail throws this exception when the user cannot be authenticated or uses invalid credentials to access a resource.
HTTP Status Code: 400
- AccountSetupInProgressException
-
Lightsail throws this exception when an account is still in the setup in progress state.
HTTP Status Code: 400
- InvalidInputException
-
Lightsail throws this exception when user input does not conform to the validation rules of an input field.
Note
Domain and distribution APIs are only available in the N. Virginia (
us-east-1
) AWS Region. Please set your AWS Region configuration tous-east-1
to create, view, or edit these resources.HTTP Status Code: 400
- NotFoundException
-
Lightsail throws this exception when it cannot find a resource.
HTTP Status Code: 400
- OperationFailureException
-
Lightsail throws this exception when an operation fails to execute.
HTTP Status Code: 400
- ServiceException
-
A general service exception.
HTTP Status Code: 500
- UnauthenticatedException
-
Lightsail throws this exception when the user has not been authenticated.
HTTP Status Code: 400
Examples
In the following example or examples, the Authorization header contents
(AUTHPARAMS
) must be replaced with an AWS Signature Version 4 signature. For
more information about creating these signatures, see Signature Version 4 Signing Process
in the
AWS General Reference.
You need to learn how to sign HTTP requests only if you intend to manually create them.
When you use the AWS Command Line Interface (AWS CLI)
Get instances
The following example returns all instances in the us-west-2
AWS Region.
Sample Request
POST / HTTP/1.1
Host: lightsail.us-west-2.amazonaws.com
Accept-Encoding: identity
X-Amz-Target: Lightsail_20161128.GetInstances
Content-Type: application/x-amz-json-1.1
User-Agent: AGENT
X-Amz-Date: 20201019T144314Z
Authorization: AUTHPARAMS
Signature=AUTHPARAMS
Content-Length: 2
{}
Sample Response
HTTP/1.1 200 OK
Server: Server
Date: Mon, 22 Apr 2024 14:43:17 GMT
Content-Type: application/x-amz-json-1.1
Content-Length: 2750
x-amzn-RequestId: aaa1993d-8d60-4a13-899c-bEXAMPLE9bc7
Connection: keep-alive
{
"instances": [
{
"addOns": [
{
"name": "AutoSnapshot",
"snapshotTimeOfDay": "06:00",
"status": "Enabled"
}
],
"arn": "arn:aws:lightsail:us-west-2:111122223333:Instance/93d19bc4-bd2a-4deb-9048-4EXAMPLE4236",
"blueprintId": "wordpress",
"blueprintName": "WordPress",
"bundleId": "micro_3_0",
"createdAt": 1.590771192493E9,
"hardware": {
"cpuCount": 2,
"disks": [
{
"attachedTo": "WordPress-1",
"attachmentState": "attached",
"createdAt": 1.590771192493E9,
"iops": 120,
"isSystemDisk": true,
"path": "/dev/xvda",
"sizeInGb": 40
}
],
"ramSizeInGb": 1.0
},
"isStaticIp": true,
"location": {
"availabilityZone": "us-west-2a",
"regionName": "us-west-2"
},
"name": "WordPress-1",
"networking": {
"monthlyTransfer": {"gbPerMonthAllocated": 2048},
"ports": [
{
"accessDirection": "inbound",
"accessFrom": "Anywhere (0.0.0.0/0)",
"accessType": "public",
"cidrListAliases": [],
"cidrs": ["0.0.0.0/0"],
"commonName": "",
"fromPort": 80,
"protocol": "tcp",
"toPort": 80
},
{
"accessDirection": "inbound",
"accessFrom": "Anywhere (0.0.0.0/0)",
"accessType": "public",
"cidrListAliases": [],
"cidrs": ["0.0.0.0/0"],
"commonName": "",
"fromPort": 22,
"protocol": "tcp",
"toPort": 22
},
{
"accessDirection": "inbound",
"accessFrom": "Anywhere (0.0.0.0/0)",
"accessType": "public",
"cidrListAliases": [],
"cidrs": ["0.0.0.0/0"],
"commonName": "",
"fromPort": 443,
"protocol": "tcp",
"toPort": 443
}
]
},
"privateIpAddress": "192.0.2.1",
"publicIpAddress": "192.0.2.2",
"resourceType": "Instance",
"sshKeyName": "LightsailDefaultKeyPair",
"state": {
"code": 16,
"name": "running"
},
"supportCode": "1234567890/i-0dEXAMPLE1abad00e",
"tags": [],
"username": "bitnami"
},
{
"arn": "arn:aws:lightsail:us-west-2:111122223333:Instance/bd08b156-5c35-4b89-9e90-8EXAMPLEd006",
"blueprintId": "amazon_linux_2023",
"blueprintName": "Amazon Linux 2023",
"bundleId": "nano_3_0",
"createdAt": 1.591802416964E9,
"hardware": {
"cpuCount": 2,
"disks": [
{
"attachedTo": "Amazon_Linux-2023",
"attachmentState": "attached",
"createdAt": 1.591802416964E9,
"iops": 3000,
"isSystemDisk": true,
"path": "/dev/xvda",
"sizeInGb": 20
}
],
"ramSizeInGb": 0.5
},
"isStaticIp": true,
"location": {
"availabilityZone": "us-west-2a",
"regionName": "us-west-2"
},
"name": "Amazon_Linux-1",
"networking": {
"monthlyTransfer": {"gbPerMonthAllocated": 1024},
"ports": [
{
"accessDirection": "inbound",
"accessFrom": "Anywhere (0.0.0.0/0)",
"accessType": "public",
"cidrListAliases": [],
"cidrs": ["0.0.0.0/0"],
"commonName": "",
"fromPort": 80,
"protocol": "tcp",
"toPort": 80
},
{
"accessDirection": "inbound",
"accessFrom": "Anywhere (0.0.0.0/0)",
"accessType": "public",
"cidrListAliases": [],
"cidrs": ["0.0.0.0/0"],
"commonName": "",
"fromPort": 22,
"protocol": "tcp",
"toPort": 22
}
]
},
"privateIpAddress": "192.0.2.3",
"publicIpAddress": "192.0.2.4",
"resourceType": "Instance",
"sshKeyName": "LightsailDefaultKeyPair",
"state": {
"code": 16,
"name": "running"
},
"supportCode": "1234567890/i-0dEXAMPLE1abad00e",
"tags": [],
"username": "ec2-user"
}
]
}
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: