Skip to content

delete_resource_policy

delete_resource_policy(
    resource_arn: ResourceArnString,
    policy_id: PolicyId,
    policy_hash: PolicyHash,
    *,
    config_overrides: Optional[SSMClientConfig] = None,
    deletion_mode: Optional[DeletionMode] = None,
) -> DeleteResourcePolicyResponse

Deletes a Systems Manager resource policy. A resource policy helps you to define the IAM entity (for example, an Amazon Web Services account) that can manage your Systems Manager resources. The following resources support Systems Manager resource policies.

  • OpsItemGroup - The resource policy for OpsItemGroup enables Amazon Web Services accounts to view and interact with OpsCenter operational work items (OpsItems).

  • Parameter - The resource policy is used to share a parameter with other accounts using Resource Access Manager (RAM). For more information about cross-account sharing of parameters, see Working with shared parameters in the Amazon Web Services Systems Manager User Guide.

  • Document – Shares the document using Resource Access Manager (RAM). For more information about sharing documents, see Sharing Systems Manager documents in the Amazon Web Services Systems Manager User Guide.

Parameters:

  • resource_arn (ResourceArnString) –

    Amazon Resource Name (ARN) of the resource to which the policies are attached.

  • policy_id (PolicyId) –

    The policy ID.

  • policy_hash (PolicyHash) –

    ID of the current policy version. The hash helps to prevent multiple calls from attempting to overwrite a policy.

  • deletion_mode (Optional[DeletionMode], default: None ) –

    Specifies the intended outcome of the operation. Applies only to the Document resource type. The operation ignores this parameter for other resource types. Optional. Defaults to RemoveSharing.

    • RemoveSharing – Deletes the resource policy and removes sharing of the document.

    • RollbackMigration – Reverts the document to Custom sharing, preserving existing consumer access, instead of removing the policy.

Raises:

Source code in docs_src/capo_ssm/_services/ssm.py
def delete_resource_policy(
    self,
    resource_arn: "capo_ssm.types.resource_arn_string.ResourceArnString",
    policy_id: "capo_ssm.types.policy_id.PolicyId",
    policy_hash: "capo_ssm.types.policy_hash.PolicyHash",
    *,
    config_overrides: Optional[SSMClientConfig] = None,
    deletion_mode: Optional["capo_ssm.types.deletion_mode.DeletionMode"] = None,
) -> "capo_ssm.types.delete_resource_policy_response.DeleteResourcePolicyResponse":
    """<p>Deletes a Systems Manager resource policy. A resource policy helps you to define the IAM entity (for example, an Amazon Web Services account) that can manage your Systems Manager resources. The following resources support Systems Manager resource policies.</p> <ul> <li> <p> <code>OpsItemGroup</code> - The resource policy for <code>OpsItemGroup</code> enables Amazon Web Services accounts to view and interact with OpsCenter operational work items (OpsItems).</p> </li> <li> <p> <code>Parameter</code> - The resource policy is used to share a parameter with other accounts using Resource Access Manager (RAM). For more information about cross-account sharing of parameters, see <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/parameter-store-shared-parameters.html">Working with shared parameters</a> in the <i>Amazon Web Services Systems Manager User Guide</i>.</p> </li> <li> <p> <code>Document</code> – Shares the document using Resource Access Manager (RAM). For more information about sharing documents, see <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/documents-ssm-sharing.html">Sharing Systems Manager documents</a> in the <i>Amazon Web Services Systems Manager User Guide</i>.</p> </li> </ul>

    Args:
        resource_arn: <p>Amazon Resource Name (ARN) of the resource to which the policies are attached.</p>
        policy_id: <p>The policy ID.</p>
        policy_hash: <p>ID of the current policy version. The hash helps to prevent multiple calls from attempting to overwrite a policy.</p>
        deletion_mode: <p>Specifies the intended outcome of the operation. Applies only to the <code>Document</code> resource type. The operation ignores this parameter for other resource types. Optional. Defaults to <code>RemoveSharing</code>.</p> <ul> <li> <p> <code>RemoveSharing</code> – Deletes the resource policy and removes sharing of the document.</p> </li> <li> <p> <code>RollbackMigration</code> – Reverts the document to Custom sharing, preserving existing consumer access, instead of removing the policy.</p> </li> </ul>

    Raises:
        capo_ssm.errors.internal_server_error.InternalServerError: <p>An error occurred on the server side.</p>
        capo_ssm.errors.malformed_resource_policy_document_exception.MalformedResourcePolicyDocumentException: <p>The specified policy document is malformed or invalid, or excessive <code>PutResourcePolicy</code> or <code>DeleteResourcePolicy</code> calls have been made.</p>
        capo_ssm.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified parameter to be shared could not be found.</p>
        capo_ssm.errors.resource_policy_conflict_exception.ResourcePolicyConflictException: <p>The hash provided in the call doesn't match the stored hash. This exception is thrown when trying to update an obsolete policy version or when multiple requests to update a policy are sent.</p>
        capo_ssm.errors.resource_policy_invalid_parameter_exception.ResourcePolicyInvalidParameterException: <p>One or more parameters specified for the call aren't valid. Verify the parameters and their values and try again.</p>
        capo_ssm.errors.resource_policy_not_found_exception.ResourcePolicyNotFoundException: <p>No policies with the specified policy ID and hash could be found.</p>
        capo_ssm.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ssm.types.delete_resource_policy_request.DeleteResourcePolicyRequest]",
    ) -> OperationResponse[
        "capo_ssm.types.delete_resource_policy_response.DeleteResourcePolicyResponse"
    ]:
        import capo_ssm._operations.amazon_ssm.delete_resource_policy

        output, http_response = (
            capo_ssm._operations.amazon_ssm.delete_resource_policy.delete_resource_policy(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteResourcePolicy")
    )
    input_: capo_ssm.types.delete_resource_policy_request.DeleteResourcePolicyRequest = {
        "resource_arn": resource_arn,
        "policy_id": policy_id,
        "policy_hash": policy_hash,
    }
    if deletion_mode is not None:
        input_["deletion_mode"] = deletion_mode

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