Skip to content

put_cluster_policy async

put_cluster_policy(
    identifier: ClusterId,
    policy: PolicyDocument,
    *,
    config_overrides: Optional[AsyncDSQLClientConfig] = None,
    bypass_policy_lockout_safety_check: Optional[BypassPolicyLockoutSafetyCheck] = None,
    expected_policy_version: Optional[PolicyVersion] = None,
    client_token: Optional[ClientToken] = None,
) -> PutClusterPolicyOutput

Attaches a resource-based policy to a cluster. This policy defines access permissions and conditions for the cluster, allowing you to control which principals can perform actions on the cluster.

Parameters:

  • policy (PolicyDocument) –

    The resource-based policy document to attach to the cluster. This should be a valid JSON policy document that defines permissions and conditions.

  • bypass_policy_lockout_safety_check (Optional[BypassPolicyLockoutSafetyCheck], default: None ) –

    A flag that allows you to bypass the policy lockout safety check. When set to true, this parameter allows you to apply a policy that might lock you out of the cluster. Use with caution.

  • expected_policy_version (Optional[PolicyVersion], default: None ) –

    The expected version of the current policy. This parameter ensures that you're updating the correct version of the policy and helps prevent concurrent modification conflicts.

Raises:

Source code in docs_src/capo_dsql/_services/async_dsql.py
async def put_cluster_policy(
    self,
    identifier: "capo_dsql.types.cluster_id.ClusterId",
    policy: "capo_dsql.types.policy_document.PolicyDocument",
    *,
    config_overrides: Optional[AsyncDSQLClientConfig] = None,
    bypass_policy_lockout_safety_check: Optional[
        "capo_dsql.types.bypass_policy_lockout_safety_check.BypassPolicyLockoutSafetyCheck"
    ] = None,
    expected_policy_version: Optional[
        "capo_dsql.types.policy_version.PolicyVersion"
    ] = None,
    client_token: Optional["capo_dsql.types.client_token.ClientToken"] = None,
) -> "capo_dsql.types.put_cluster_policy_output.PutClusterPolicyOutput":
    """<p>Attaches a resource-based policy to a cluster. This policy defines access permissions and conditions for the cluster, allowing you to control which principals can perform actions on the cluster.</p>

    Args:
        policy: <p>The resource-based policy document to attach to the cluster. This should be a valid JSON policy document that defines permissions and conditions.</p>
        bypass_policy_lockout_safety_check: <p>A flag that allows you to bypass the policy lockout safety check. When set to true, this parameter allows you to apply a policy that might lock you out of the cluster. Use with caution.</p>
        expected_policy_version: <p>The expected version of the current policy. This parameter ensures that you're updating the correct version of the policy and helps prevent concurrent modification conflicts.</p>

    Raises:
        capo_dsql.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_dsql.errors.internal_server_exception.InternalServerException: <p>The request processing has failed because of an unknown error, exception or failure.</p>
        capo_dsql.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_dsql.errors.validation_exception.ValidationException: <p>The input failed to satisfy the constraints specified by an Amazon Web Services service.</p>
        capo_dsql.errors.conflict_exception.ConflictException: <p>The submitted action has conflicts.</p>
        capo_dsql.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource could not be found.</p>
        capo_dsql.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_dsql.types.put_cluster_policy_input.PutClusterPolicyInput]",
    ) -> AsyncOperationResponse[
        "capo_dsql.types.put_cluster_policy_output.PutClusterPolicyOutput"
    ]:
        import capo_dsql._operations.dsql.put_cluster_policy

        (
            output,
            http_response,
        ) = await capo_dsql._operations.dsql.put_cluster_policy.async_put_cluster_policy(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutClusterPolicy")
    )
    input_: capo_dsql.types.put_cluster_policy_input.PutClusterPolicyInput = {
        "identifier": identifier,
        "policy": policy,
    }
    if bypass_policy_lockout_safety_check is not None:
        input_["bypass_policy_lockout_safety_check"] = (
            bypass_policy_lockout_safety_check
        )
    if expected_policy_version is not None:
        input_["expected_policy_version"] = expected_policy_version
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output