putResourcePolicy method

Future<PutResourcePolicyOutput> putResourcePolicy({
  1. required String policy,
  2. required String resourceArn,
})

Attaches or replaces a resource-based policy on an Amazon Web Services Payment Cryptography key. A resource-based policy can grant cross-account access to your key.

If the policy would grant public access, the request fails with a PublicPolicyException.

To remove a resource-based policy from a key, use DeleteResourcePolicy.

Cross-account use: This operation can't be used across different Amazon Web Services accounts.

Related operations:

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw PublicPolicyException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ServiceUnavailableException. May throw ThrottlingException. May throw ValidationException.

Parameter policy : The resource-based policy to attach to the key, in JSON format.

Parameter resourceArn : The KeyARN of the key to attach the resource-based policy to.

Implementation

Future<PutResourcePolicyOutput> putResourcePolicy({
  required String policy,
  required String resourceArn,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'PaymentCryptographyControlPlane.PutResourcePolicy'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Policy': policy,
      'ResourceArn': resourceArn,
    },
  );

  return PutResourcePolicyOutput.fromJson(jsonResponse.body);
}