Skip to content

get_resource_metrics_configuration

get_resource_metrics_configuration(
    *,
    config_overrides: Optional[CloudWatchClientConfig] = None,
    resource_arn: Optional[ResourceArn] = None,
) -> GetResourceMetricsConfigurationOutput

Retrieves the current resource metrics configuration for an Amazon Web Services resource. The response includes the resource ARN, any metric selections, and the times at which the configuration was created and last updated.

This operation returns a ResourceNotFoundException if no resource metrics configuration exists for the specified resource ARN. To create a configuration, use CreateResourceMetricsConfiguration.

To retrieve a resource metrics configuration, you must have the cloudwatch:GetResourceMetricsConfiguration permission. For information about scoping this permission to specific resources, see Condition keys for resource metrics configuration access in the Amazon CloudWatch User Guide.

Parameters:

  • resource_arn (Optional[ResourceArn], default: None ) –

    The Amazon Resource Name (ARN) of the Amazon Web Services resource to retrieve the resource metrics configuration for.

Raises:

Source code in docs_src/capo_cloudwatch/_services/cloud_watch.py
def get_resource_metrics_configuration(
    self,
    *,
    config_overrides: Optional[CloudWatchClientConfig] = None,
    resource_arn: Optional["capo_cloudwatch.types.resource_arn.ResourceArn"] = None,
) -> "capo_cloudwatch.types.get_resource_metrics_configuration_output.GetResourceMetricsConfigurationOutput":
    """<p>Retrieves the current resource metrics configuration for an Amazon Web Services resource. The response includes the resource ARN, any metric selections, and the times at which the configuration was created and last updated.</p> <p>This operation returns a <code>ResourceNotFoundException</code> if no resource metrics configuration exists for the specified resource ARN. To create a configuration, use <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_CreateResourceMetricsConfiguration.html">CreateResourceMetricsConfiguration</a>.</p> <p>To retrieve a resource metrics configuration, you must have the <code>cloudwatch:GetResourceMetricsConfiguration</code> permission. For information about scoping this permission to specific resources, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/iam-cw-condition-keys-resource-arn.html">Condition keys for resource metrics configuration access</a> in the <i>Amazon CloudWatch User Guide</i>.</p>

    Args:
        resource_arn: <p>The Amazon Resource Name (ARN) of the Amazon Web Services resource to retrieve the resource metrics configuration for.</p>

    Raises:
        capo_cloudwatch.errors.resource_not_found_exception.ResourceNotFoundException: <p>The named resource does not exist.</p>
        capo_cloudwatch.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_cloudwatch.types.get_resource_metrics_configuration_input.GetResourceMetricsConfigurationInput]",
    ) -> OperationResponse[
        "capo_cloudwatch.types.get_resource_metrics_configuration_output.GetResourceMetricsConfigurationOutput"
    ]:
        import capo_cloudwatch._operations.granite_service_version20100801.get_resource_metrics_configuration

        output, http_response = (
            capo_cloudwatch._operations.granite_service_version20100801.get_resource_metrics_configuration.get_resource_metrics_configuration(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetResourceMetricsConfiguration")
    )
    input_: capo_cloudwatch.types.get_resource_metrics_configuration_input.GetResourceMetricsConfigurationInput = {}
    if resource_arn is not None:
        input_["resource_arn"] = resource_arn

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