Skip to content

delete_replication_group async

delete_replication_group(
    *,
    config_overrides: Optional[AsyncElastiCacheClientConfig] = None,
    replication_group_id: Optional[String] = None,
    retain_primary_cluster: Optional[BooleanOptional] = None,
    final_snapshot_identifier: Optional[String] = None,
) -> DeleteReplicationGroupResult

Deletes an existing replication group. By default, this operation deletes the entire replication group, including the primary/primaries and all of the read replicas. If the replication group has only one primary, you can optionally delete only the read replicas, while retaining the primary by setting RetainPrimaryCluster=true.

When you receive a successful response from this operation, Amazon ElastiCache immediately begins deleting the selected resources; you cannot cancel or revert this operation.

  • CreateSnapshot permission is required to create a final snapshot. Without this permission, the API call will fail with an Access Denied exception.

  • This operation is valid for Redis OSS only.

Parameters:

  • replication_group_id (Optional[String], default: None ) –

    The identifier for the cluster to be deleted. This parameter is not case sensitive.

  • retain_primary_cluster (Optional[BooleanOptional], default: None ) –

    If set to true, all of the read replicas are deleted, but the primary node is retained.

  • final_snapshot_identifier (Optional[String], default: None ) –

    The name of a final node group (shard) snapshot. ElastiCache creates the snapshot from the primary node in the cluster, rather than one of the replicas; this is to ensure that it captures the freshest data. After the final snapshot is taken, the replication group is immediately deleted.

Raises:

Examples:

DeleteReplicationGroup Deletes the Amazon ElastiCache replication group my-redis-rg.

>>> await client.delete_replication_group(replication_group_id='my-redis-rg', retain_primary_cluster=False)
Source code in docs_src/capo_elasticache/_services/async_elasti_cache.py
async def delete_replication_group(
    self,
    *,
    config_overrides: Optional[AsyncElastiCacheClientConfig] = None,
    replication_group_id: Optional["capo_elasticache.types.string.String"] = None,
    retain_primary_cluster: Optional[
        "capo_elasticache.types.boolean_optional.BooleanOptional"
    ] = None,
    final_snapshot_identifier: Optional[
        "capo_elasticache.types.string.String"
    ] = None,
) -> "capo_elasticache.types.delete_replication_group_result.DeleteReplicationGroupResult":
    """<p>Deletes an existing replication group. By default, this operation deletes the entire replication group, including the primary/primaries and all of the read replicas. If the replication group has only one primary, you can optionally delete only the read replicas, while retaining the primary by setting <code>RetainPrimaryCluster=true</code>.</p> <p>When you receive a successful response from this operation, Amazon ElastiCache immediately begins deleting the selected resources; you cannot cancel or revert this operation.</p> <note> <ul> <li> <p> <code>CreateSnapshot</code> permission is required to create a final snapshot. Without this permission, the API call will fail with an <code>Access Denied</code> exception.</p> </li> <li> <p>This operation is valid for Redis OSS only.</p> </li> </ul> </note>

    Args:
        replication_group_id: <p>The identifier for the cluster to be deleted. This parameter is not case sensitive.</p>
        retain_primary_cluster: <p>If set to <code>true</code>, all of the read replicas are deleted, but the primary node is retained.</p>
        final_snapshot_identifier: <p>The name of a final node group (shard) snapshot. ElastiCache creates the snapshot from the primary node in the cluster, rather than one of the replicas; this is to ensure that it captures the freshest data. After the final snapshot is taken, the replication group is immediately deleted.</p>

    Raises:
        capo_elasticache.errors.invalid_parameter_combination_exception.InvalidParameterCombinationException: <p>Two or more incompatible parameters were specified.</p>
        capo_elasticache.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>The value for a parameter is invalid.</p>
        capo_elasticache.errors.invalid_replication_group_state_fault.InvalidReplicationGroupStateFault: <p>The requested replication group is not in the <code>available</code> state.</p>
        capo_elasticache.errors.replication_group_not_found_fault.ReplicationGroupNotFoundFault: <p>The specified replication group does not exist.</p>
        capo_elasticache.errors.snapshot_already_exists_fault.SnapshotAlreadyExistsFault: <p>You already have a snapshot with the given name.</p>
        capo_elasticache.errors.snapshot_feature_not_supported_fault.SnapshotFeatureNotSupportedFault: <p>You attempted one of the following operations:</p> <ul> <li> <p>Creating a snapshot of a Valkey or Redis OSS cluster running on a <code>cache.t1.micro</code> cache node.</p> </li> <li> <p>Creating a snapshot of a cluster that is running Memcached rather than Valkey or Redis OSS.</p> </li> </ul> <p>Neither of these are supported by ElastiCache.</p>
        capo_elasticache.errors.snapshot_quota_exceeded_fault.SnapshotQuotaExceededFault: <p>The request cannot be processed because it would exceed the maximum number of snapshots.</p>
        capo_elasticache.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        DeleteReplicationGroup
        Deletes the Amazon ElastiCache replication group my-redis-rg.

        >>> await client.delete_replication_group(replication_group_id='my-redis-rg', retain_primary_cluster=False)
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_elasticache.types.delete_replication_group_message.DeleteReplicationGroupMessage]",
    ) -> AsyncOperationResponse[
        "capo_elasticache.types.delete_replication_group_result.DeleteReplicationGroupResult"
    ]:
        import capo_elasticache._operations.amazon_elasti_cache_v9.delete_replication_group

        (
            output,
            http_response,
        ) = await capo_elasticache._operations.amazon_elasti_cache_v9.delete_replication_group.async_delete_replication_group(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteReplicationGroup")
    )
    input_: capo_elasticache.types.delete_replication_group_message.DeleteReplicationGroupMessage = {}
    if replication_group_id is not None:
        input_["replication_group_id"] = replication_group_id
    if retain_primary_cluster is not None:
        input_["retain_primary_cluster"] = retain_primary_cluster
    if final_snapshot_identifier is not None:
        input_["final_snapshot_identifier"] = final_snapshot_identifier

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