putResourcePolicy method

Future<PutResourcePolicyResponse> putResourcePolicy({
  1. required String name,
  2. required String policyDocument,
  3. String? policyRevisionId,
})

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.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw InvalidPolicyRevisionIdException. May throw MalformedPolicyDocumentException. May throw PolicySizeLimitExceededException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw ValidationException.

Parameter name : 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.

Parameter policyDocument : 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.

Parameter policyRevisionId : 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.

Implementation

Future<PutResourcePolicyResponse> putResourcePolicy({
  required String name,
  required String policyDocument,
  String? policyRevisionId,
}) async {
  final $payload = <String, dynamic>{
    'PolicyDocument': policyDocument,
    if (policyRevisionId != null) 'PolicyRevisionId': policyRevisionId,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri: '/appmonitor/${Uri.encodeComponent(name)}/policy',
    exceptionFnMap: _exceptionFns,
  );
  return PutResourcePolicyResponse.fromJson(response);
}