Skip to content

list_discovered_resources

list_discovered_resources(
    resource_type: ResourceType,
    *,
    config_overrides: Optional[ConfigServiceClientConfig] = None,
    resource_ids: Optional[ResourceIdList] = None,
    resource_name: Optional[ResourceName] = None,
    limit: Optional[Limit] = None,
    include_deleted_resources: Optional[Boolean] = None,
    next_token: Optional[NextToken] = None,
) -> ListDiscoveredResourcesResponse

Returns a list of resource resource identifiers for the specified resource types for the resources of that type. A resource identifier includes the resource type, ID, and (if available) the custom resource name.

The results consist of resources that Config has discovered, including those that Config is not currently recording. You can narrow the results to include only resources that have specific resource IDs or a resource name.

You can specify either resource IDs or a resource name, but not both, in the same request.

CloudFormation stack recording behavior in Config

When a CloudFormation stack fails to create (for example, it enters the ROLLBACK_FAILED state), Config does not record a configuration item (CI) for that stack. Configuration items are only recorded for stacks that reach the following states:

  • CREATE_COMPLETE

  • UPDATE_COMPLETE

  • UPDATE_ROLLBACK_COMPLETE

  • UPDATE_ROLLBACK_FAILED

  • DELETE_FAILED

  • DELETE_COMPLETE

Because no CI is created for a failed stack creation, you won't see configuration history for that stack in Config, even after the stack is deleted. This helps make sure that Config only tracks resources that were successfully provisioned.

Parameters:

  • resource_type (ResourceType) –

    The type of resources that you want Config to list in the response.

  • resource_ids (Optional[ResourceIdList], default: None ) –

    The IDs of only those resources that you want Config to list in the response. If you do not specify this parameter, Config lists all resources of the specified type that it has discovered. You can list a minimum of 1 resourceID and a maximum of 20 resourceIds.

  • resource_name (Optional[ResourceName], default: None ) –

    The custom name of only those resources that you want Config to list in the response. If you do not specify this parameter, Config lists all resources of the specified type that it has discovered.

  • limit (Optional[Limit], default: None ) –

    The maximum number of resource identifiers returned on each page. The default is 100. You cannot specify a number greater than 100. If you specify 0, Config uses the default.

  • include_deleted_resources (Optional[Boolean], default: None ) –

    Specifies whether Config includes deleted resources in the results. By default, deleted resources are not included.

  • next_token (Optional[NextToken], default: None ) –

    The nextToken string returned on a previous page that you use to get the next page of results in a paginated response.

Raises:

  • InvalidLimitException –

    The specified limit is outside the allowable range.

  • InvalidNextTokenException –

    The specified next token is not valid. Specify the nextToken string that was returned in the previous response to get the next page of results.

  • NoAvailableConfigurationRecorderException –

    There are no customer managed configuration recorders available to record your resources. Use the PutConfigurationRecorder operation to create the customer managed configuration recorder.

  • ValidationException –

    The requested operation is not valid. You will see this exception if there are missing required fields or if the input value fails the validation.

    For PutStoredQuery, one of the following errors:

    • There are missing required fields.

    • The input value fails the validation.

    • You are trying to create more than 300 queries.

    For DescribeConfigurationRecorders and DescribeConfigurationRecorderStatus, one of the following errors:

    • You have specified more than one configuration recorder.

    • You have provided a service principal for service-linked configuration recorder that is not valid.

    For AssociateResourceTypes and DisassociateResourceTypes, one of the following errors:

    • Your configuraiton recorder has a recording strategy that does not allow the association or disassociation of resource types.

    • One or more of the specified resource types are already associated or disassociated with the configuration recorder.

    • For service-linked configuration recorders, the configuration recorder does not record one or more of the specified resource types.

    For DeleteServiceLinkedConfigurationRecorder, one of the following errors:

    • You have provided both Arn and ServicePrincipal. Only one of Arn or ServicePrincipal can be specified.

    • You have provided a service principal for service-linked configuration recorder that is not valid.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_config_service/_services/config_service.py
def list_discovered_resources(
    self,
    resource_type: "capo_config_service.types.resource_type.ResourceType",
    *,
    config_overrides: Optional[ConfigServiceClientConfig] = None,
    resource_ids: Optional[
        "capo_config_service.types.resource_id_list.ResourceIdList"
    ] = None,
    resource_name: Optional[
        "capo_config_service.types.resource_name.ResourceName"
    ] = None,
    limit: Optional["capo_config_service.types.limit.Limit"] = None,
    include_deleted_resources: Optional[
        "capo_config_service.types.boolean.Boolean"
    ] = None,
    next_token: Optional["capo_config_service.types.next_token.NextToken"] = None,
) -> "capo_config_service.types.list_discovered_resources_response.ListDiscoveredResourcesResponse":
    """<p>Returns a list of resource resource identifiers for the specified resource types for the resources of that type. A <i>resource identifier</i> includes the resource type, ID, and (if available) the custom resource name.</p> <p>The results consist of resources that Config has <i>discovered</i>, including those that Config is not currently recording. You can narrow the results to include only resources that have specific resource IDs or a resource name.</p> <note> <p>You can specify either resource IDs or a resource name, but not both, in the same request.</p> </note> <important> <p> <i>CloudFormation stack recording behavior in Config</i> </p> <p>When a CloudFormation stack fails to create (for example, it enters the <code>ROLLBACK_FAILED</code> state), Config does not record a configuration item (CI) for that stack. Configuration items are only recorded for stacks that reach the following states:</p> <ul> <li> <p> <code>CREATE_COMPLETE</code> </p> </li> <li> <p> <code>UPDATE_COMPLETE</code> </p> </li> <li> <p> <code>UPDATE_ROLLBACK_COMPLETE</code> </p> </li> <li> <p> <code>UPDATE_ROLLBACK_FAILED</code> </p> </li> <li> <p> <code>DELETE_FAILED</code> </p> </li> <li> <p> <code>DELETE_COMPLETE</code> </p> </li> </ul> <p>Because no CI is created for a failed stack creation, you won't see configuration history for that stack in Config, even after the stack is deleted. This helps make sure that Config only tracks resources that were successfully provisioned.</p> </important>

    Args:
        resource_type: <p>The type of resources that you want Config to list in the response.</p>
        resource_ids: <p>The IDs of only those resources that you want Config to list in the response. If you do not specify this parameter, Config lists all resources of the specified type that it has discovered. You can list a minimum of 1 resourceID and a maximum of 20 resourceIds.</p>
        resource_name: <p>The custom name of only those resources that you want Config to list in the response. If you do not specify this parameter, Config lists all resources of the specified type that it has discovered.</p>
        limit: <p>The maximum number of resource identifiers returned on each page. The default is 100. You cannot specify a number greater than 100. If you specify 0, Config uses the default.</p>
        include_deleted_resources: <p>Specifies whether Config includes deleted resources in the results. By default, deleted resources are not included.</p>
        next_token: <p>The <code>nextToken</code> string returned on a previous page that you use to get the next page of results in a paginated response.</p>

    Raises:
        capo_config_service.errors.invalid_limit_exception.InvalidLimitException: <p>The specified limit is outside the allowable range.</p>
        capo_config_service.errors.invalid_next_token_exception.InvalidNextTokenException: <p>The specified next token is not valid. Specify the <code>nextToken</code> string that was returned in the previous response to get the next page of results.</p>
        capo_config_service.errors.no_available_configuration_recorder_exception.NoAvailableConfigurationRecorderException: <p>There are no customer managed configuration recorders available to record your resources. Use the <a href="https://docs.aws.amazon.com/config/latest/APIReference/API_PutConfigurationRecorder.html">PutConfigurationRecorder</a> operation to create the customer managed configuration recorder.</p>
        capo_config_service.errors.validation_exception.ValidationException: <p>The requested operation is not valid. You will see this exception if there are missing required fields or if the input value fails the validation.</p> <p>For <a href="https://docs.aws.amazon.com/config/latest/APIReference/API_PutStoredQuery.html">PutStoredQuery</a>, one of the following errors:</p> <ul> <li> <p>There are missing required fields.</p> </li> <li> <p>The input value fails the validation.</p> </li> <li> <p>You are trying to create more than 300 queries.</p> </li> </ul> <p>For <a href="https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeConfigurationRecorders.html">DescribeConfigurationRecorders</a> and <a href="https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeConfigurationRecorderStatus.html">DescribeConfigurationRecorderStatus</a>, one of the following errors:</p> <ul> <li> <p>You have specified more than one configuration recorder.</p> </li> <li> <p>You have provided a service principal for service-linked configuration recorder that is not valid.</p> </li> </ul> <p>For <a href="https://docs.aws.amazon.com/config/latest/APIReference/API_AssociateResourceTypes.html">AssociateResourceTypes</a> and <a href="https://docs.aws.amazon.com/config/latest/APIReference/API_DisassociateResourceTypes.html">DisassociateResourceTypes</a>, one of the following errors:</p> <ul> <li> <p>Your configuraiton recorder has a recording strategy that does not allow the association or disassociation of resource types.</p> </li> <li> <p>One or more of the specified resource types are already associated or disassociated with the configuration recorder.</p> </li> <li> <p>For service-linked configuration recorders, the configuration recorder does not record one or more of the specified resource types.</p> </li> </ul> <p>For <a href="https://docs.aws.amazon.com/config/latest/APIReference/API_DeleteServiceLinkedConfigurationRecorder.html">DeleteServiceLinkedConfigurationRecorder</a>, one of the following errors:</p> <ul> <li> <p>You have provided both <code>Arn</code> and <code>ServicePrincipal</code>. Only one of <code>Arn</code> or <code>ServicePrincipal</code> can be specified.</p> </li> <li> <p>You have provided a service principal for service-linked configuration recorder that is not valid.</p> </li> </ul>
        capo_config_service.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_config_service.types.list_discovered_resources_request.ListDiscoveredResourcesRequest]",
    ) -> OperationResponse[
        "capo_config_service.types.list_discovered_resources_response.ListDiscoveredResourcesResponse"
    ]:
        import capo_config_service._operations.starling_dove_service.list_discovered_resources

        output, http_response = (
            capo_config_service._operations.starling_dove_service.list_discovered_resources.list_discovered_resources(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListDiscoveredResources")
    )
    input_: capo_config_service.types.list_discovered_resources_request.ListDiscoveredResourcesRequest = {
        "resource_type": resource_type
    }
    if resource_ids is not None:
        input_["resource_ids"] = resource_ids
    if resource_name is not None:
        input_["resource_name"] = resource_name
    if limit is not None:
        input_["limit"] = limit
    if include_deleted_resources is not None:
        input_["include_deleted_resources"] = include_deleted_resources
    if next_token is not None:
        input_["next_token"] = next_token

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output