Skip to content

create_snapshot

create_snapshot(
    *,
    config_overrides: Optional[ElastiCacheClientConfig] = None,
    replication_group_id: Optional[String] = None,
    cache_cluster_id: Optional[String] = None,
    snapshot_name: Optional[String] = None,
    kms_key_id: Optional[String] = None,
    tags: Optional[TagList] = None,
) -> CreateSnapshotResult

Creates a copy of an entire cluster or replication group at a specific moment in time.

This operation is valid for Valkey or Redis OSS only.

Parameters:

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

    The identifier of an existing replication group. The snapshot is created from this replication group.

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

    The identifier of an existing cluster. The snapshot is created from this cluster.

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

    A name for the snapshot being created. This value is stored as a lowercase string.

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

    The ID of the KMS key used to encrypt the snapshot.

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

    A list of tags to be added to this resource. A tag is a key-value pair. A tag key must be accompanied by a tag value, although null is accepted.

Raises:

Examples:

CreateSnapshot - NonClustered Redis, 2 read-replicas Creates a snapshot of a non-clustered Redis cluster that has only three nodes, primary and two read-replicas. CacheClusterId must be a specific node in the cluster.

>>> client.create_snapshot(cache_cluster_id='threenoderedis-001', snapshot_name='snapshot-2')
CreateSnapshot - NonClustered Redis, no read-replicas
Creates a snapshot of a non-clustered Redis cluster that has only one node.
>>> client.create_snapshot(cache_cluster_id='onenoderedis', snapshot_name='snapshot-1')
CreateSnapshot-clustered Redis
Creates a snapshot of a clustered Redis cluster that has 2 shards, each with a primary and 4 read-replicas.
>>> client.create_snapshot(replication_group_id='clusteredredis', snapshot_name='snapshot-2x5')
Source code in docs_src/capo_elasticache/_services/elasti_cache.py
def create_snapshot(
    self,
    *,
    config_overrides: Optional[ElastiCacheClientConfig] = None,
    replication_group_id: Optional["capo_elasticache.types.string.String"] = None,
    cache_cluster_id: Optional["capo_elasticache.types.string.String"] = None,
    snapshot_name: Optional["capo_elasticache.types.string.String"] = None,
    kms_key_id: Optional["capo_elasticache.types.string.String"] = None,
    tags: Optional["capo_elasticache.types.tag_list.TagList"] = None,
) -> "capo_elasticache.types.create_snapshot_result.CreateSnapshotResult":
    """<p>Creates a copy of an entire cluster or replication group at a specific moment in time.</p> <note> <p>This operation is valid for Valkey or Redis OSS only.</p> </note>

    Args:
        replication_group_id: <p>The identifier of an existing replication group. The snapshot is created from this replication group.</p>
        cache_cluster_id: <p>The identifier of an existing cluster. The snapshot is created from this cluster.</p>
        snapshot_name: <p>A name for the snapshot being created. This value is stored as a lowercase string.</p>
        kms_key_id: <p>The ID of the KMS key used to encrypt the snapshot.</p>
        tags: <p>A list of tags to be added to this resource. A tag is a key-value pair. A tag key must be accompanied by a tag value, although null is accepted.</p>

    Raises:
        capo_elasticache.errors.cache_cluster_not_found_fault.CacheClusterNotFoundFault: <p>The requested cluster ID does not refer to an existing cluster.</p>
        capo_elasticache.errors.invalid_cache_cluster_state_fault.InvalidCacheClusterStateFault: <p>The requested cluster is not in the <code>available</code> state.</p>
        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.tag_quota_per_resource_exceeded.TagQuotaPerResourceExceeded: <p>The request cannot be processed because it would cause the resource to have more than the allowed number of tags. The maximum number of tags permitted on a resource is 50.</p>
        capo_elasticache.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        CreateSnapshot - NonClustered Redis, 2 read-replicas
        Creates a snapshot of a non-clustered Redis cluster that has only three nodes, primary and two read-replicas. CacheClusterId must be a specific node in the cluster.

        >>> client.create_snapshot(cache_cluster_id='threenoderedis-001', snapshot_name='snapshot-2')
        CreateSnapshot - NonClustered Redis, no read-replicas
        Creates a snapshot of a non-clustered Redis cluster that has only one node.

        >>> client.create_snapshot(cache_cluster_id='onenoderedis', snapshot_name='snapshot-1')
        CreateSnapshot-clustered Redis
        Creates a snapshot of a clustered Redis cluster that has 2 shards, each with a primary and 4 read-replicas.

        >>> client.create_snapshot(replication_group_id='clusteredredis', snapshot_name='snapshot-2x5')
    """

    def _handler(
        req: "OperationRequest[capo_elasticache.types.create_snapshot_message.CreateSnapshotMessage]",
    ) -> OperationResponse[
        "capo_elasticache.types.create_snapshot_result.CreateSnapshotResult"
    ]:
        import capo_elasticache._operations.amazon_elasti_cache_v9.create_snapshot

        output, http_response = (
            capo_elasticache._operations.amazon_elasti_cache_v9.create_snapshot.create_snapshot(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateSnapshot")
    )
    input_: capo_elasticache.types.create_snapshot_message.CreateSnapshotMessage = {}
    if replication_group_id is not None:
        input_["replication_group_id"] = replication_group_id
    if cache_cluster_id is not None:
        input_["cache_cluster_id"] = cache_cluster_id
    if snapshot_name is not None:
        input_["snapshot_name"] = snapshot_name
    if kms_key_id is not None:
        input_["kms_key_id"] = kms_key_id
    if tags is not None:
        input_["tags"] = tags

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