ListResources
Returns a list of resources and their details that match the specified criteria. This query must use a view. If you don’t explicitly specify a view, then Resource Explorer uses the default view for the AWS Region in which you call this operation.
Minimum permissions
To call this operation, you must have the following permissions:
-
Action:
resource-explorer-2:SearchResource: No specific resource (*).
Request Syntax
POST /ListResources HTTP/1.1
Content-type: application/json
{
"Filters": {
"FilterString": "string"
},
"MaxResults": number,
"NextToken": "string",
"ViewArn": "string"
}
URI Request Parameters
The request does not use any URI parameters.
Request Body
The request accepts the following data in JSON format.
- Filters
-
An array of strings that specify which resources are included in the results of queries made using this view. When you use this view in a Search operation, the filter string is combined with the search's
QueryStringparameter using a logicalANDoperator.For information about the supported syntax, see Search query reference for Resource Explorer in the AWS Resource Explorer User Guide.
Important
This query string in the context of this operation supports only filter prefixes with optional operators. It doesn't support free-form text. For example, the string
region:us* service:ec2 -tag:stage=prodincludes all Amazon EC2 resources in any AWS Region that begins with the lettersusand is not tagged with a keyStagethat has the valueprod.Type: SearchFilter object
Required: No
- MaxResults
-
The maximum number of results that you want included on each page of the response. If you do not include this parameter, it defaults to a value appropriate to the operation. If additional items exist beyond those included in the current response, the
NextTokenresponse element is present and has a value (is not null). Include that value as theNextTokenrequest parameter in the next call to the operation to get the next part of the results.Note
An API operation can return fewer results than the maximum even when there are more results available. You should check
NextTokenafter every operation to ensure that you receive all of the results.Type: Integer
Valid Range: Minimum value of 1. Maximum value of 1000.
Required: No
- NextToken
-
The parameter for receiving additional results if you receive a
NextTokenresponse in a previous request. ANextTokenresponse indicates that more output is available. Set this parameter to the value of the previous call'sNextTokenresponse to indicate where the output should continue from. The pagination tokens expire after 24 hours.Note
The
ListResourcesoperation does not generate aNextTokenif you setMaxResultsto 1000.Type: String
Length Constraints: Minimum length of 1. Maximum length of 2048.
Required: No
- ViewArn
-
Specifies the Amazon resource name (ARN) of the view to use for the query. If you don't specify a value for this parameter, then the operation automatically uses the default view for the AWS Region in which you called this operation. If the Region either doesn't have a default view or if you don't have permission to use the default view, then the operation fails with a 401 Unauthorized exception.
Type: String
Length Constraints: Minimum length of 0. Maximum length of 1000.
Required: No
Response Syntax
HTTP/1.1 200
Content-type: application/json
{
"NextToken": "string",
"Resources": [
{
"Arn": "string",
"LastReportedAt": "string",
"OwningAccountId": "string",
"Properties": [
{
"Data": JSON value,
"LastReportedAt": "string",
"Name": "string"
}
],
"Region": "string",
"ResourceType": "string",
"Service": "string"
}
],
"ViewArn": "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.
- NextToken
-
If present, indicates that more output is available than is included in the current response. Use this value in the
NextTokenrequest parameter in a subsequent call to the operation to get the next part of the output. You should repeat this until theNextTokenresponse element comes back asnull. The pagination tokens expire after 24 hours.Type: String
Length Constraints: Minimum length of 1. Maximum length of 2048.
- Resources
-
The list of structures that describe the resources that match the query.
Type: Array of Resource objects
- ViewArn
-
The Amazon resource name (ARN) of the view that this operation used to perform the search.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 1011.
Errors
For information about the errors that are common to all actions, see Common Errors.
- AccessDeniedException
-
The credentials that you used to call this operation don't have the minimum required permissions.
HTTP Status Code: 403
- InternalServerException
-
The request failed because of internal service error. Try your request again later.
HTTP Status Code: 500
- ResourceNotFoundException
-
You specified a resource that doesn't exist. Check the ID or ARN that you used to identity the resource, and try again.
HTTP Status Code: 404
- ThrottlingException
-
The request failed because you exceeded a rate limit for this operation. For more information, see Quotas for Resource Explorer.
HTTP Status Code: 429
- UnauthorizedException
-
The principal making the request isn't permitted to perform the operation.
HTTP Status Code: 401
- ValidationException
-
You provided an invalid value for one of the operation's parameters. Check the syntax for the operation, and try again.
- FieldList
-
An array of the request fields that had validation errors.
HTTP Status Code: 400
Examples
Example
The following example shows how to list of all supported resource types,
across all AWS services, within your account or organization. The example
response includes a NextToken value, which indicates that there is
more output available to retrieve with additional calls.
Sample Request
POST /ListResources HTTP/1.1
Host: resource-explorer-2.us-east-1.amazonaws.com
X-Amz-Date: 20221101T200059Z
Accept-Encoding: identity
User-Agent: <UserAgentString>
Content-Length: <PayloadSizeBytes>
Authorization: AWS4-HMAC-SHA256 Credential=<Credential>, SignedHeaders=<Headers>, Signature=<Signature>
{
"Filters": {
"FilterString": "service:ec2"
},
"ViewArn": "arn:aws:resource-explorer-2:us-east-1:123456789012:view/my-default-view/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111",
"MaxResults": 2,
"NextToken": "AG9VOEF1KLEXAMPLEOhJHVwo5chEXAMPLER5XiEpNrgsEXAMPLE...b0CmOFOryHEXAMPLE"
}
Sample Response
HTTP/1.1 200 OK
Date: Tue, 01 Nov 2022 20:00:59 GMT
Content-Type: application/json
Content-Length: <PayloadSizeBytes>
{
"NextToken": "AG9VOEF1KLEXAMPLEOhJHVwo5chEXAMPLER5XiEpNrgsEXAMPLE...b0CmOFOryHEXAMPLE",
"Resources": [
{
"Arn": "arn:aws:iam::123456789012:policy/service-role/Policy-For-A-Service-Role",
"LastReportedAt": "2024-07-21T12:34:42Z",
"OwningAccountId": "111122223333",
"Properties": [
{
"Data": [
{
"Key": "Name",
"Value": "Example-Name"
},
{
"Key": "aws:cloudformation:stack-name",
"Value": "Stack-Name"
},
{
"Key": "aws:cloudformation:stack-id",
"Value": "arn:aws:cloudformation:us-east-1:111122223333:stack/stack-name-username-region/EXAMPLE8-90ab-cdef-fedc-EXAMPLE33333"
},
{
"Key": "aws:cloudformation:logical-id",
"Value": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"
}
],
"LastReportedAt": "2024-02-26T13:47:30Z",
"Name": "tags"
}
],
"Region": "us-east-1",
"ResourceType": "ec2:natgateway",
"Service": "ec2"
},
{
"Arn": "arn:aws:iam::111122223333:policy/service-role/Policy-For-A-Service-Role",
"LastReportedAt": "2024-07-21T12:34:42Z",
"OwningAccountId": "111122223333",
"Properties": [],
"Region": "us-east-1",
"ResourceType": "ec2:internet-gateway",
"Service": "ec2"
}
],
"ViewArn": "arn:aws:resource-explorer-2:us-east-1:123456789012:view/my-default-view/EXAMPLE8-90ab-cdef-fedc-EXAMPLE22222"
}
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: