create_snapshot
¶
create_snapshot(
*,
config_overrides: Optional[EC2ClientConfig] = None,
description: Optional[String] = None,
outpost_arn: Optional[String] = None,
volume_id: Optional[VolumeId] = None,
tag_specifications: Optional[TagSpecificationList] = None,
location: Optional[SnapshotLocationEnum] = None,
dry_run: Optional[Boolean] = None,
) -> Snapshot
Creates a snapshot of an EBS volume and stores it in Amazon S3. You can use snapshots for backups, to make copies of EBS volumes, and to save data before shutting down an instance.
The location of the source EBS volume determines where you can create the snapshot.
-
If the source volume is in a Region, you must create the snapshot in the same Region as the volume.
-
If the source volume is in a Local Zone, you can create the snapshot in the same Local Zone or in its parent Amazon Web Services Region.
-
If the source volume is on an Outpost, you can create the snapshot on the same Outpost or in its parent Amazon Web Services Region.
When a snapshot is created, any Amazon Web Services Marketplace product codes that are associated with the source volume are propagated to the snapshot.
You can take a snapshot of an attached volume that is in use. However, snapshots only capture data that has been written to your Amazon EBS volume at the time the snapshot command is issued; this might exclude any data that has been cached by any applications or the operating system. If you can pause any file systems on the volume long enough to take a snapshot, your snapshot should be complete. However, if you cannot pause all file writes to the volume, you should unmount the volume from within the instance, issue the snapshot command, and then remount the volume to ensure a consistent and complete snapshot. You may remount and use your volume while the snapshot status is pending.
When you create a snapshot for an EBS volume that serves as a root device, we recommend that you stop the instance before taking the snapshot.
Snapshots that are taken from encrypted volumes are automatically encrypted. Volumes that are created from encrypted snapshots are also automatically encrypted. Your encrypted volumes and any associated snapshots always remain protected. For more information, see Amazon EBS encryption in the Amazon EBS User Guide.
Parameters:
-
description(Optional[String], default:None) –A description for the snapshot.
-
outpost_arn(Optional[String], default:None) –Only supported for volumes on Outposts. If the source volume is not on an Outpost, omit this parameter.
-
To create the snapshot on the same Outpost as the source volume, specify the ARN of that Outpost. The snapshot must be created on the same Outpost as the volume.
-
To create the snapshot in the parent Region of the Outpost, omit this parameter.
For more information, see Create local snapshots from volumes on an Outpost in the Amazon EBS User Guide.
-
-
volume_id(Optional[VolumeId], default:None) –The ID of the Amazon EBS volume.
-
tag_specifications(Optional[TagSpecificationList], default:None) –The tags to apply to the snapshot during creation.
-
location(Optional[SnapshotLocationEnum], default:None) –Only supported for volumes in Local Zones. If the source volume is not in a Local Zone, omit this parameter.
-
To create a local snapshot in the same Local Zone as the source volume, specify
local. -
To create a regional snapshot in the parent Region of the Local Zone, specify
regionalor omit this parameter.
Default value:
regional -
-
dry_run(Optional[Boolean], default:None) –Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is
DryRunOperation. Otherwise, it isUnauthorizedOperation.
Raises:
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To create a snapshot
This example creates a snapshot of the volume with a volume ID of vol-1234567890abcdef0 and a short description to identify the snapshot.
>>> client.create_snapshot(volume_id='vol-1234567890abcdef0', description='This is my root volume snapshot.')
Source code in docs_src/capo_ec2/_services/ec2.py
12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 | |