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:
In order to share a backup, it must be in a 'READY' state and you must own it.
While you can share a backup using the CloudHSM PutResourcePolicy operation, we recommend using Resource Access Manager (RAM) instead. Using RAM provides multiple benefits as it creates the policy for you, allows multiple resources to be shared at one time, and increases the discoverability of shared resources. If you use PutResourcePolicy and want consumers to be able to describe the backups you share with them, you must promote the backup to a standard RAM Resource Share using the RAM PromoteResourceShareCreatedFromPolicy API operation. For more information, see Working with shared backups in the CloudHSM User Guide
Cross-account use: No. You cannot perform this operation on an CloudHSM resource in a different Amazon Web Services account.
Parameters:
Raises:
Source code in docs_src/capo_cloudhsm_v2/_services/cloud_hsmv2.py
| def put_resource_policy(
self,
*,
config_overrides: Optional[CloudHSMV2ClientConfig] = None,
resource_arn: Optional[
"capo_cloudhsm_v2.types.cloud_hsm_arn.CloudHsmArn"
] = None,
policy: Optional[
"capo_cloudhsm_v2.types.resource_policy.ResourcePolicy"
] = None,
) -> (
"capo_cloudhsm_v2.types.put_resource_policy_response.PutResourcePolicyResponse"
):
"""<p>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: </p> <ul> <li> <p> Backup - The resource policy allows you to describe the backup and restore a cluster from the backup in another Amazon Web Services account.</p> </li> </ul> <p>In order to share a backup, it must be in a 'READY' state and you must own it.</p> <important> <p>While you can share a backup using the CloudHSM PutResourcePolicy operation, we recommend using Resource Access Manager (RAM) instead. Using RAM provides multiple benefits as it creates the policy for you, allows multiple resources to be shared at one time, and increases the discoverability of shared resources. If you use PutResourcePolicy and want consumers to be able to describe the backups you share with them, you must promote the backup to a standard RAM Resource Share using the RAM PromoteResourceShareCreatedFromPolicy API operation. For more information, see <a href="https://docs.aws.amazon.com/cloudhsm/latest/userguide/sharing.html"> Working with shared backups</a> in the CloudHSM User Guide</p> </important> <p> <b>Cross-account use:</b> No. You cannot perform this operation on an CloudHSM resource in a different Amazon Web Services account.</p>
Args:
resource_arn: <p>Amazon Resource Name (ARN) of the resource to which you want to attach a policy. </p>
policy: <p>The policy you want to associate with a resource. </p> <p>For an example policy, see <a href="https://docs.aws.amazon.com/cloudhsm/latest/userguide/sharing.html"> Working with shared backups</a> in the CloudHSM User Guide</p>
Raises:
capo_cloudhsm_v2.errors.cloud_hsm_access_denied_exception.CloudHsmAccessDeniedException: <p>The request was rejected because the requester does not have permission to perform the requested operation.</p>
capo_cloudhsm_v2.errors.cloud_hsm_internal_failure_exception.CloudHsmInternalFailureException: <p>The request was rejected because of an CloudHSM internal failure. The request can be retried.</p>
capo_cloudhsm_v2.errors.cloud_hsm_invalid_request_exception.CloudHsmInvalidRequestException: <p>The request was rejected because it is not a valid request.</p>
capo_cloudhsm_v2.errors.cloud_hsm_resource_not_found_exception.CloudHsmResourceNotFoundException: <p>The request was rejected because it refers to a resource that cannot be found.</p>
capo_cloudhsm_v2.errors.cloud_hsm_service_exception.CloudHsmServiceException: <p>The request was rejected because an error occurred.</p>
capo_cloudhsm_v2.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_cloudhsm_v2.types.put_resource_policy_request.PutResourcePolicyRequest]",
) -> OperationResponse[
"capo_cloudhsm_v2.types.put_resource_policy_response.PutResourcePolicyResponse"
]:
import capo_cloudhsm_v2._operations.baldr_api_service.put_resource_policy
output, http_response = (
capo_cloudhsm_v2._operations.baldr_api_service.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_cloudhsm_v2.types.put_resource_policy_request.PutResourcePolicyRequest = {}
if resource_arn is not None:
input_["resource_arn"] = resource_arn
if policy is not None:
input_["policy"] = policy
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|