Skip to content

put_resource_policy

put_resource_policy(
    name: AppMonitorName,
    policy_document: str,
    *,
    config_overrides: Optional[RUMClientConfig] = None,
    policy_revision_id: Optional[PolicyRevisionId] = None,
) -> PutResourcePolicyResponse

Use this operation to assign a resource-based policy to a CloudWatch RUM app monitor to control access to it. Each app monitor can have one resource-based policy. The maximum size of the policy is 4 KB. To learn more about using resource policies with RUM, see Using resource-based policies with CloudWatch RUM.

Parameters:

  • name (AppMonitorName) –

    The name of the app monitor that you want to apply this resource-based policy to. To find the names of your app monitors, you can use the ListAppMonitors operation.

  • policy_document (str) –

    The JSON to use as the resource policy. The document can be up to 4 KB in size. For more information about the contents and syntax for this policy, see Using resource-based policies with CloudWatch RUM.

  • policy_revision_id (Optional[PolicyRevisionId], default: None ) –

    A string value that you can use to conditionally update your policy. You can provide the revision ID of your existing policy to make mutating requests against that policy.

    When you assign a policy revision ID, then later requests about that policy will be rejected with an InvalidPolicyRevisionIdException error if they don't provide the correct current revision ID.

Raises:

Source code in docs_src/capo_rum/_services/rum.py
def put_resource_policy(
    self,
    name: "capo_rum.types.app_monitor_name.AppMonitorName",
    policy_document: str,
    *,
    config_overrides: Optional[RUMClientConfig] = None,
    policy_revision_id: Optional[
        "capo_rum.types.policy_revision_id.PolicyRevisionId"
    ] = None,
) -> "capo_rum.types.put_resource_policy_response.PutResourcePolicyResponse":
    """<p>Use this operation to assign a resource-based policy to a CloudWatch RUM app monitor to control access to it. Each app monitor can have one resource-based policy. The maximum size of the policy is 4 KB. To learn more about using resource policies with RUM, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-RUM-resource-policies.html">Using resource-based policies with CloudWatch RUM</a>.</p>

    Args:
        name: <p>The name of the app monitor that you want to apply this resource-based policy to. To find the names of your app monitors, you can use the <a href="https://docs.aws.amazon.com/cloudwatchrum/latest/APIReference/API_ListAppMonitors.html">ListAppMonitors</a> operation.</p>
        policy_document: <p>The JSON to use as the resource policy. The document can be up to 4 KB in size. For more information about the contents and syntax for this policy, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-RUM-resource-policies.html">Using resource-based policies with CloudWatch RUM</a>.</p>
        policy_revision_id: <p>A string value that you can use to conditionally update your policy. You can provide the revision ID of your existing policy to make mutating requests against that policy.</p> <p>When you assign a policy revision ID, then later requests about that policy will be rejected with an <code>InvalidPolicyRevisionIdException</code> error if they don't provide the correct current revision ID.</p>

    Raises:
        capo_rum.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient permissions to perform this action.</p>
        capo_rum.errors.conflict_exception.ConflictException: <p>This operation attempted to create a resource that already exists.</p>
        capo_rum.errors.internal_server_exception.InternalServerException: <p>Internal service exception.</p>
        capo_rum.errors.invalid_policy_revision_id_exception.InvalidPolicyRevisionIdException: <p>The policy revision ID that you provided doeesn't match the latest policy revision ID.</p>
        capo_rum.errors.malformed_policy_document_exception.MalformedPolicyDocumentException: <p>The policy document that you specified is not formatted correctly.</p>
        capo_rum.errors.policy_size_limit_exceeded_exception.PolicySizeLimitExceededException: <p>The policy document is too large. The limit is 4 KB.</p>
        capo_rum.errors.resource_not_found_exception.ResourceNotFoundException: <p>Resource not found.</p>
        capo_rum.errors.throttling_exception.ThrottlingException: <p>The request was throttled because of quota limits.</p>
        capo_rum.errors.validation_exception.ValidationException: <p>One of the arguments for the request is not valid.</p>
        capo_rum.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_rum.types.put_resource_policy_request.PutResourcePolicyRequest]",
    ) -> OperationResponse[
        "capo_rum.types.put_resource_policy_response.PutResourcePolicyResponse"
    ]:
        import capo_rum._operations.rum.put_resource_policy

        output, http_response = (
            capo_rum._operations.rum.put_resource_policy.put_resource_policy(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutResourcePolicy")
    )
    input_: capo_rum.types.put_resource_policy_request.PutResourcePolicyRequest = {
        "name": name,
        "policy_document": policy_document,
    }
    if policy_revision_id is not None:
        input_["policy_revision_id"] = policy_revision_id

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