Skip to content

create_cluster

create_cluster(
    *,
    config_overrides: Optional[DSQLClientConfig] = None,
    deletion_protection_enabled: Optional[DeletionProtectionEnabled] = None,
    kms_encryption_key: Optional[KmsEncryptionKey] = None,
    tags: Optional[TagMap] = None,
    client_token: Optional[ClientToken] = None,
    multi_region_properties: Optional[MultiRegionProperties] = None,
    policy: Optional[PolicyDocument] = None,
    bypass_policy_lockout_safety_check: Optional[BypassPolicyLockoutSafetyCheck] = None,
) -> CreateClusterOutput

The CreateCluster API allows you to create both single-Region clusters and multi-Region clusters. With the addition of the multiRegionProperties parameter, you can create a cluster with witness Region support and establish peer relationships with clusters in other Regions during creation.

Creating multi-Region clusters requires additional IAM permissions beyond those needed for single-Region clusters, as detailed in the Required permissions section below.

Required permissions

dsql:CreateCluster

Required to create a cluster.

Resources: arn:aws:dsql:region:account-id:cluster/*

dsql:TagResource

Permission to add tags to a resource.

Resources: arn:aws:dsql:region:account-id:cluster/*

dsql:PutMultiRegionProperties

Permission to configure multi-Region properties for a cluster.

Resources: arn:aws:dsql:region:account-id:cluster/*

dsql:AddPeerCluster

When specifying multiRegionProperties.clusters, permission to add peer clusters.

Resources:

  • Local cluster: arn:aws:dsql:region:account-id:cluster/*

  • Each peer cluster: exact ARN of each specified peer cluster

dsql:PutWitnessRegion

When specifying multiRegionProperties.witnessRegion, permission to set a witness Region. This permission is checked both in the cluster Region and in the witness Region.

Resources: arn:aws:dsql:region:account-id:cluster/*

Condition Keys: dsql:WitnessRegion (matching the specified witness region)

  • The witness Region specified in multiRegionProperties.witnessRegion cannot be the same as the cluster's Region.

Parameters:

  • deletion_protection_enabled (Optional[DeletionProtectionEnabled], default: None ) –

    If enabled, you can't delete your cluster. You must first disable this property before you can delete your cluster.

  • kms_encryption_key (Optional[KmsEncryptionKey], default: None ) –

    The KMS key that encrypts and protects the data on your cluster. You can specify the ARN, ID, or alias of an existing key or have Amazon Web Services create a default key for you.

  • tags (Optional[TagMap], default: None ) –

    A map of key and value pairs to use to tag your cluster.

  • client_token (Optional[ClientToken], default: None ) –

    A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Idempotency ensures that an API request completes only once. With an idempotent request, if the original request completes successfully, the subsequent retries with the same client token return the result from the original successful request and they have no additional effect.

    If you don't specify a client token, the Amazon Web Services SDK automatically generates one.

  • multi_region_properties (Optional[MultiRegionProperties], default: None ) –

    The configuration settings when creating a multi-Region cluster, including the witness region and linked cluster properties.

  • policy (Optional[PolicyDocument], default: None ) –

    An optional resource-based policy document in JSON format that defines access permissions for the cluster.

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

    An optional field that controls whether to bypass the lockout prevention check. When set to true, this parameter allows you to apply a policy that might lock you out of the cluster. Use with caution.

Raises:

Examples:

Create Cluster

>>> client.create_cluster(deletion_protection_enabled=False, tags={'MyKey': 'MyValue'})
Source code in docs_src/capo_dsql/_services/dsql.py
def create_cluster(
    self,
    *,
    config_overrides: Optional[DSQLClientConfig] = None,
    deletion_protection_enabled: Optional[
        "capo_dsql.types.deletion_protection_enabled.DeletionProtectionEnabled"
    ] = None,
    kms_encryption_key: Optional[
        "capo_dsql.types.kms_encryption_key.KmsEncryptionKey"
    ] = None,
    tags: Optional["capo_dsql.types.tag_map.TagMap"] = None,
    client_token: Optional["capo_dsql.types.client_token.ClientToken"] = None,
    multi_region_properties: Optional[
        "capo_dsql.types.multi_region_properties.MultiRegionProperties"
    ] = None,
    policy: Optional["capo_dsql.types.policy_document.PolicyDocument"] = None,
    bypass_policy_lockout_safety_check: Optional[
        "capo_dsql.types.bypass_policy_lockout_safety_check.BypassPolicyLockoutSafetyCheck"
    ] = None,
) -> "capo_dsql.types.create_cluster_output.CreateClusterOutput":
    """<p>The CreateCluster API allows you to create both single-Region clusters and multi-Region clusters. With the addition of the <i>multiRegionProperties</i> parameter, you can create a cluster with witness Region support and establish peer relationships with clusters in other Regions during creation.</p> <note> <p>Creating multi-Region clusters requires additional IAM permissions beyond those needed for single-Region clusters, as detailed in the <b>Required permissions</b> section below.</p> </note> <p> <b>Required permissions</b> </p> <dl> <dt>dsql:CreateCluster</dt> <dd> <p>Required to create a cluster.</p> <p>Resources: <code>arn:aws:dsql:region:account-id:cluster/*</code> </p> </dd> <dt>dsql:TagResource</dt> <dd> <p>Permission to add tags to a resource.</p> <p>Resources: <code>arn:aws:dsql:region:account-id:cluster/*</code> </p> </dd> <dt>dsql:PutMultiRegionProperties</dt> <dd> <p>Permission to configure multi-Region properties for a cluster.</p> <p>Resources: <code>arn:aws:dsql:region:account-id:cluster/*</code> </p> </dd> <dt>dsql:AddPeerCluster</dt> <dd> <p>When specifying <code>multiRegionProperties.clusters</code>, permission to add peer clusters.</p> <p>Resources:</p> <ul> <li> <p>Local cluster: <code>arn:aws:dsql:region:account-id:cluster/*</code> </p> </li> <li> <p>Each peer cluster: exact ARN of each specified peer cluster</p> </li> </ul> </dd> <dt>dsql:PutWitnessRegion</dt> <dd> <p>When specifying <code>multiRegionProperties.witnessRegion</code>, permission to set a witness Region. This permission is checked both in the cluster Region and in the witness Region.</p> <p>Resources: <code>arn:aws:dsql:region:account-id:cluster/*</code> </p> <p>Condition Keys: <code>dsql:WitnessRegion</code> (matching the specified witness region)</p> </dd> </dl> <important> <ul> <li> <p>The witness Region specified in <code>multiRegionProperties.witnessRegion</code> cannot be the same as the cluster's Region.</p> </li> </ul> </important>

    Args:
        deletion_protection_enabled: <p>If enabled, you can't delete your cluster. You must first disable this property before you can delete your cluster.</p>
        kms_encryption_key: <p>The KMS key that encrypts and protects the data on your cluster. You can specify the ARN, ID, or alias of an existing key or have Amazon Web Services create a default key for you.</p>
        tags: <p>A map of key and value pairs to use to tag your cluster.</p>
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Idempotency ensures that an API request completes only once. With an idempotent request, if the original request completes successfully, the subsequent retries with the same client token return the result from the original successful request and they have no additional effect.</p> <p>If you don't specify a client token, the Amazon Web Services SDK automatically generates one.</p>
        multi_region_properties: <p>The configuration settings when creating a multi-Region cluster, including the witness region and linked cluster properties.</p>
        policy: <p>An optional resource-based policy document in JSON format that defines access permissions for the cluster.</p>
        bypass_policy_lockout_safety_check: <p>An optional field that controls whether to bypass the lockout prevention 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>

    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.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The service limit was exceeded.</p>
        capo_dsql.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Create Cluster

        >>> client.create_cluster(deletion_protection_enabled=False, tags={'MyKey': 'MyValue'})
    """

    def _handler(
        req: "OperationRequest[capo_dsql.types.create_cluster_input.CreateClusterInput]",
    ) -> OperationResponse[
        "capo_dsql.types.create_cluster_output.CreateClusterOutput"
    ]:
        import capo_dsql._operations.dsql.create_cluster

        output, http_response = (
            capo_dsql._operations.dsql.create_cluster.create_cluster(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateCluster")
    )
    input_: capo_dsql.types.create_cluster_input.CreateClusterInput = {}
    if deletion_protection_enabled is not None:
        input_["deletion_protection_enabled"] = deletion_protection_enabled
    if kms_encryption_key is not None:
        input_["kms_encryption_key"] = kms_encryption_key
    if tags is not None:
        input_["tags"] = tags
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if multi_region_properties is not None:
        input_["multi_region_properties"] = multi_region_properties
    if policy is not None:
        input_["policy"] = policy
    if bypass_policy_lockout_safety_check is not None:
        input_["bypass_policy_lockout_safety_check"] = (
            bypass_policy_lockout_safety_check
        )

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