putResourcePolicy method
Creates or updates an CloudHSM resource policy. A resource policy helps you to define the IAM entity (for example, an Amazon Web Services account) that can manage your CloudHSM resources. The following resources support CloudHSM resource policies:
- Backup - The resource policy allows you to describe the backup and restore a cluster from the backup in another Amazon Web Services account.
May throw CloudHsmAccessDeniedException.
May throw CloudHsmInternalFailureException.
May throw CloudHsmInvalidRequestException.
May throw CloudHsmResourceNotFoundException.
May throw CloudHsmServiceException.
Parameter policy :
The policy you want to associate with a resource.
For an example policy, see Working with shared backups in the CloudHSM User Guide
Parameter resourceArn :
Amazon Resource Name (ARN) of the resource to which you want to attach a
policy.
Implementation
Future<PutResourcePolicyResponse> putResourcePolicy({
String? policy,
String? resourceArn,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'BaldrApiService.PutResourcePolicy'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
if (policy != null) 'Policy': policy,
if (resourceArn != null) 'ResourceArn': resourceArn,
},
);
return PutResourcePolicyResponse.fromJson(jsonResponse.body);
}