Skip to content

get_resource

get_resource(
    type_name: TypeName,
    identifier: Identifier,
    *,
    config_overrides: Optional[CloudControlClientConfig] = None,
    type_version_id: Optional[TypeVersionId] = None,
    role_arn: Optional[RoleArn] = None,
) -> GetResourceOutput

Returns information about the current state of the specified resource. For details, see Reading a resource's current state.

You can use this action to return information about an existing resource in your account and Amazon Web Services Region, whether those resources were provisioned using Cloud Control API.

Parameters:

  • type_name (TypeName) –

    The name of the resource type.

  • type_version_id (Optional[TypeVersionId], default: None ) –

    For private resource types, the type version to use in this resource operation. If you do not specify a resource version, CloudFormation uses the default version.

  • role_arn (Optional[RoleArn], default: None ) –

    The Amazon Resource Name (ARN) of the Identity and Access Management (IAM) role for Cloud Control API to use when performing this resource operation. The role specified must have the permissions required for this operation. The necessary permissions for each event handler are defined in the handlers section of the resource type definition schema.

    If you do not specify a role, Cloud Control API uses a temporary session created using your Amazon Web Services user credentials.

    For more information, see Specifying credentials in the Amazon Web Services Cloud Control API User Guide.

  • identifier (Identifier) –

    The identifier for the resource.

    You can specify the primary identifier, or any secondary identifier defined for the resource type in its resource schema. You can only specify one identifier. Primary identifiers can be specified as a string or JSON; secondary identifiers must be specified as JSON.

    For compound primary identifiers (that is, one that consists of multiple resource properties strung together), to specify the primary identifier as a string, list the property values in the order they are specified in the primary identifier definition, separated by |.

    For more information, see Identifying resources in the Amazon Web Services Cloud Control API User Guide.

Raises:

  • AlreadyExistsException –

    The resource with the name requested already exists.

  • GeneralServiceException –

    The resource handler has returned that the downstream service generated an error that doesn't map to any other handler error code.

  • HandlerFailureException –

    The resource handler has failed without a returning a more specific error code. This can include timeouts.

  • HandlerInternalFailureException –

    The resource handler has returned that an unexpected error occurred within the resource handler.

  • InvalidCredentialsException –

    The resource handler has returned that the credentials provided by the user are invalid.

  • InvalidRequestException –

    The resource handler has returned that invalid input from the user has generated a generic exception.

  • NetworkFailureException –

    The resource handler has returned that the request couldn't be completed due to networking issues, such as a failure to receive a response from the server.

  • NotStabilizedException –

    The resource handler has returned that the downstream resource failed to complete all of its ready-state checks.

  • NotUpdatableException –

    One or more properties included in this resource operation are defined as create-only, and therefore can't be updated.

  • PrivateTypeException –

    Cloud Control API hasn't received a valid response from the resource handler, due to a configuration error. This includes issues such as the resource handler returning an invalid response, or timing out.

  • ResourceConflictException –

    The resource is temporarily unavailable to be acted upon. For example, if the resource is currently undergoing an operation and can't be acted upon until that operation is finished.

  • ResourceNotFoundException –

    A resource with the specified identifier can't be found.

  • ServiceInternalErrorException –

    The resource handler has returned that the downstream service returned an internal error, typically with a 5XX HTTP status code.

  • ServiceLimitExceededException –

    The resource handler has returned that a non-transient resource limit was reached on the service side.

  • ThrottlingException –

    The request was denied due to request throttling.

  • TypeNotFoundException –

    The specified extension doesn't exist in the CloudFormation registry.

  • UnsupportedActionException –

    The specified resource doesn't support this resource operation.

  • UnknownServiceError –

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

Source code in docs_src/capo_cloudcontrol/_services/cloud_control.py
def get_resource(
    self,
    type_name: "capo_cloudcontrol.types.type_name.TypeName",
    identifier: "capo_cloudcontrol.types.identifier.Identifier",
    *,
    config_overrides: Optional[CloudControlClientConfig] = None,
    type_version_id: Optional[
        "capo_cloudcontrol.types.type_version_id.TypeVersionId"
    ] = None,
    role_arn: Optional["capo_cloudcontrol.types.role_arn.RoleArn"] = None,
) -> "capo_cloudcontrol.types.get_resource_output.GetResourceOutput":
    """<p>Returns information about the current state of the specified resource. For details, see <a href="https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-operations-read.html">Reading a resource's current state</a>.</p> <p>You can use this action to return information about an existing resource in your account and Amazon Web Services Region, whether those resources were provisioned using Cloud Control API.</p>

    Args:
        type_name: <p>The name of the resource type.</p>
        type_version_id: <p>For private resource types, the type version to use in this resource operation. If you do not specify a resource version, CloudFormation uses the default version.</p>
        role_arn: <p>The Amazon Resource Name (ARN) of the Identity and Access Management (IAM) role for Cloud Control API to use when performing this resource operation. The role specified must have the permissions required for this operation. The necessary permissions for each event handler are defined in the <code> <a href="https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-schema.html#schema-properties-handlers">handlers</a> </code> section of the <a href="https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-schema.html">resource type definition schema</a>.</p> <p>If you do not specify a role, Cloud Control API uses a temporary session created using your Amazon Web Services user credentials.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-operations.html#resource-operations-permissions">Specifying credentials</a> in the <i>Amazon Web Services Cloud Control API User Guide</i>.</p>
        identifier: <p>The identifier for the resource.</p> <p>You can specify the primary identifier, or any secondary identifier defined for the resource type in its resource schema. You can only specify one identifier. Primary identifiers can be specified as a string or JSON; secondary identifiers must be specified as JSON.</p> <p>For compound primary identifiers (that is, one that consists of multiple resource properties strung together), to specify the primary identifier as a string, list the property values <i>in the order they are specified</i> in the primary identifier definition, separated by <code>|</code>.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-identifier.html">Identifying resources</a> in the <i>Amazon Web Services Cloud Control API User Guide</i>.</p>

    Raises:
        capo_cloudcontrol.errors.already_exists_exception.AlreadyExistsException: <p>The resource with the name requested already exists.</p>
        capo_cloudcontrol.errors.general_service_exception.GeneralServiceException: <p>The resource handler has returned that the downstream service generated an error that doesn't map to any other handler error code.</p>
        capo_cloudcontrol.errors.handler_failure_exception.HandlerFailureException: <p>The resource handler has failed without a returning a more specific error code. This can include timeouts.</p>
        capo_cloudcontrol.errors.handler_internal_failure_exception.HandlerInternalFailureException: <p>The resource handler has returned that an unexpected error occurred within the resource handler.</p>
        capo_cloudcontrol.errors.invalid_credentials_exception.InvalidCredentialsException: <p>The resource handler has returned that the credentials provided by the user are invalid.</p>
        capo_cloudcontrol.errors.invalid_request_exception.InvalidRequestException: <p>The resource handler has returned that invalid input from the user has generated a generic exception.</p>
        capo_cloudcontrol.errors.network_failure_exception.NetworkFailureException: <p>The resource handler has returned that the request couldn't be completed due to networking issues, such as a failure to receive a response from the server.</p>
        capo_cloudcontrol.errors.not_stabilized_exception.NotStabilizedException: <p>The resource handler has returned that the downstream resource failed to complete all of its ready-state checks.</p>
        capo_cloudcontrol.errors.not_updatable_exception.NotUpdatableException: <p>One or more properties included in this resource operation are defined as create-only, and therefore can't be updated.</p>
        capo_cloudcontrol.errors.private_type_exception.PrivateTypeException: <p>Cloud Control API hasn't received a valid response from the resource handler, due to a configuration error. This includes issues such as the resource handler returning an invalid response, or timing out.</p>
        capo_cloudcontrol.errors.resource_conflict_exception.ResourceConflictException: <p>The resource is temporarily unavailable to be acted upon. For example, if the resource is currently undergoing an operation and can't be acted upon until that operation is finished.</p>
        capo_cloudcontrol.errors.resource_not_found_exception.ResourceNotFoundException: <p>A resource with the specified identifier can't be found.</p>
        capo_cloudcontrol.errors.service_internal_error_exception.ServiceInternalErrorException: <p>The resource handler has returned that the downstream service returned an internal error, typically with a <code>5XX HTTP</code> status code.</p>
        capo_cloudcontrol.errors.service_limit_exceeded_exception.ServiceLimitExceededException: <p>The resource handler has returned that a non-transient resource limit was reached on the service side.</p>
        capo_cloudcontrol.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_cloudcontrol.errors.type_not_found_exception.TypeNotFoundException: <p>The specified extension doesn't exist in the CloudFormation registry.</p>
        capo_cloudcontrol.errors.unsupported_action_exception.UnsupportedActionException: <p>The specified resource doesn't support this resource operation.</p>
        capo_cloudcontrol.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_cloudcontrol.types.get_resource_input.GetResourceInput]",
    ) -> OperationResponse[
        "capo_cloudcontrol.types.get_resource_output.GetResourceOutput"
    ]:
        import capo_cloudcontrol._operations.cloud_api_service.get_resource

        output, http_response = (
            capo_cloudcontrol._operations.cloud_api_service.get_resource.get_resource(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_cloudcontrol.types.get_resource_output.GetResourceOutput",
    ) -> dict[str, Any]:
        import capo_cloudcontrol.types.get_resource_output

        return capo_cloudcontrol.types.get_resource_output.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("GetResource", redact_output=_redact_output),
    )
    input_: capo_cloudcontrol.types.get_resource_input.GetResourceInput = {
        "type_name": type_name,
        "identifier": identifier,
    }
    if type_version_id is not None:
        input_["type_version_id"] = type_version_id
    if role_arn is not None:
        input_["role_arn"] = role_arn

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