- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
CreateSnapshotCommand
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.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { ElastiCacheClient, CreateSnapshotCommand } from "@aws-sdk/client-elasticache"; // ES Modules import
// const { ElastiCacheClient, CreateSnapshotCommand } = require("@aws-sdk/client-elasticache"); // CommonJS import
const client = new ElastiCacheClient(config);
const input = { // CreateSnapshotMessage
ReplicationGroupId: "STRING_VALUE",
CacheClusterId: "STRING_VALUE",
SnapshotName: "STRING_VALUE", // required
KmsKeyId: "STRING_VALUE",
Tags: [ // TagList
{ // Tag
Key: "STRING_VALUE",
Value: "STRING_VALUE",
},
],
};
const command = new CreateSnapshotCommand(input);
const response = await client.send(command);
// { // CreateSnapshotResult
// Snapshot: { // Snapshot
// SnapshotName: "STRING_VALUE",
// ReplicationGroupId: "STRING_VALUE",
// ReplicationGroupDescription: "STRING_VALUE",
// CacheClusterId: "STRING_VALUE",
// SnapshotStatus: "STRING_VALUE",
// SnapshotSource: "STRING_VALUE",
// CacheNodeType: "STRING_VALUE",
// Engine: "STRING_VALUE",
// EngineVersion: "STRING_VALUE",
// NumCacheNodes: Number("int"),
// PreferredAvailabilityZone: "STRING_VALUE",
// PreferredOutpostArn: "STRING_VALUE",
// CacheClusterCreateTime: new Date("TIMESTAMP"),
// PreferredMaintenanceWindow: "STRING_VALUE",
// TopicArn: "STRING_VALUE",
// Port: Number("int"),
// CacheParameterGroupName: "STRING_VALUE",
// CacheSubnetGroupName: "STRING_VALUE",
// VpcId: "STRING_VALUE",
// AutoMinorVersionUpgrade: true || false,
// SnapshotRetentionLimit: Number("int"),
// SnapshotWindow: "STRING_VALUE",
// NumNodeGroups: Number("int"),
// AutomaticFailover: "enabled" || "disabled" || "enabling" || "disabling",
// NodeSnapshots: [ // NodeSnapshotList
// { // NodeSnapshot
// CacheClusterId: "STRING_VALUE",
// NodeGroupId: "STRING_VALUE",
// CacheNodeId: "STRING_VALUE",
// NodeGroupConfiguration: { // NodeGroupConfiguration
// NodeGroupId: "STRING_VALUE",
// Slots: "STRING_VALUE",
// ReplicaCount: Number("int"),
// PrimaryAvailabilityZone: "STRING_VALUE",
// ReplicaAvailabilityZones: [ // AvailabilityZonesList
// "STRING_VALUE",
// ],
// PrimaryOutpostArn: "STRING_VALUE",
// ReplicaOutpostArns: [ // OutpostArnsList
// "STRING_VALUE",
// ],
// },
// CacheSize: "STRING_VALUE",
// CacheNodeCreateTime: new Date("TIMESTAMP"),
// SnapshotCreateTime: new Date("TIMESTAMP"),
// },
// ],
// KmsKeyId: "STRING_VALUE",
// ARN: "STRING_VALUE",
// DataTiering: "enabled" || "disabled",
// },
// };
Example Usage
CreateSnapshotCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
SnapshotName Required | string | undefined | A name for the snapshot being created. |
CacheClusterId | string | undefined | The identifier of an existing cluster. The snapshot is created from this cluster. |
KmsKeyId | string | undefined | The ID of the KMS key used to encrypt the snapshot. |
ReplicationGroupId | string | undefined | The identifier of an existing replication group. The snapshot is created from this replication group. |
Tags | Tag[] | undefined | 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. |
CreateSnapshotCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
Snapshot | Snapshot | undefined | Represents a copy of an entire Valkey or Redis OSS cluster as of the time when the snapshot was taken. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
CacheClusterNotFoundFault | client | The requested cluster ID does not refer to an existing cluster. |
InvalidCacheClusterStateFault | client | The requested cluster is not in the |
InvalidParameterCombinationException | client | Two or more incompatible parameters were specified. |
InvalidParameterValueException | client | The value for a parameter is invalid. |
InvalidReplicationGroupStateFault | client | The requested replication group is not in the |
ReplicationGroupNotFoundFault | client | The specified replication group does not exist. |
SnapshotAlreadyExistsFault | client | You already have a snapshot with the given name. |
SnapshotFeatureNotSupportedFault | client | You attempted one of the following operations:
Neither of these are supported by ElastiCache. |
SnapshotQuotaExceededFault | client | The request cannot be processed because it would exceed the maximum number of snapshots. |
TagQuotaPerResourceExceeded | client | 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. |
ElastiCacheServiceException | Base exception class for all service exceptions from ElastiCache service. |