Skip to content

put_resource_policy async

put_resource_policy(
    resource_arn: str,
    policy: str,
    *,
    config_overrides: Optional[AsyncRedshiftServerlessClientConfig] = None,
) -> PutResourcePolicyResponse

Creates or updates a resource policy. Currently, you can use policies to share snapshots across Amazon Web Services accounts.

Parameters:

  • resource_arn (str) –

    The Amazon Resource Name (ARN) of the account to create or update a resource policy for.

  • policy (str) –

    The policy to create or update. For example, the following policy grants a user authorization to restore a snapshot.

    "{\"Version\": \"2012-10-17\", \"Statement\" : [{ \"Sid\": \"AllowUserRestoreFromSnapshot\", \"Principal\":{\"AWS\": [\"739247239426\"]}, \"Action\": [\"redshift-serverless:RestoreFromSnapshot\"] , \"Effect\": \"Allow\" }]}"

Raises:

Source code in docs_src/capo_redshift_serverless/_services/async_redshift_serverless.py
async def put_resource_policy(
    self,
    resource_arn: str,
    policy: str,
    *,
    config_overrides: Optional[AsyncRedshiftServerlessClientConfig] = None,
) -> "capo_redshift_serverless.types.put_resource_policy_response.PutResourcePolicyResponse":
    r"""<p>Creates or updates a resource policy. Currently, you can use policies to share snapshots across Amazon Web Services accounts.</p>

    Args:
        resource_arn: <p>The Amazon Resource Name (ARN) of the account to create or update a resource policy for.</p>
        policy: <p>The policy to create or update. For example, the following policy grants a user authorization to restore a snapshot.</p> <p> <code>"{\"Version\": \"2012-10-17\", \"Statement\" : [{ \"Sid\": \"AllowUserRestoreFromSnapshot\", \"Principal\":{\"AWS\": [\"739247239426\"]}, \"Action\": [\"redshift-serverless:RestoreFromSnapshot\"] , \"Effect\": \"Allow\" }]}"</code> </p>

    Raises:
        capo_redshift_serverless.errors.conflict_exception.ConflictException: <p>The submitted action has conflicts.</p>
        capo_redshift_serverless.errors.internal_server_exception.InternalServerException: <p>The request processing has failed because of an unknown error, exception or failure.</p>
        capo_redshift_serverless.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource could not be found.</p>
        capo_redshift_serverless.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The service limit was exceeded.</p>
        capo_redshift_serverless.errors.validation_exception.ValidationException: <p>The input failed to satisfy the constraints specified by an Amazon Web Services service.</p>
        capo_redshift_serverless.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_redshift_serverless.types.put_resource_policy_request.PutResourcePolicyRequest]",
    ) -> AsyncOperationResponse[
        "capo_redshift_serverless.types.put_resource_policy_response.PutResourcePolicyResponse"
    ]:
        import capo_redshift_serverless._operations.redshift_serverless.put_resource_policy

        (
            output,
            http_response,
        ) = await capo_redshift_serverless._operations.redshift_serverless.put_resource_policy.async_put_resource_policy(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutResourcePolicy")
    )
    input_: capo_redshift_serverless.types.put_resource_policy_request.PutResourcePolicyRequest = {
        "resource_arn": resource_arn,
        "policy": policy,
    }

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