Skip to content

create_snapshots async

create_snapshots(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    description: Optional[String] = None,
    instance_specification: Optional[InstanceSpecification] = None,
    outpost_arn: Optional[String] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
    dry_run: Optional[Boolean] = None,
    copy_tags_from_source: Optional[CopyTagsFromSource] = None,
    location: Optional[SnapshotLocationEnum] = None,
) -> CreateSnapshotsResult

Creates crash-consistent snapshots of multiple EBS volumes attached to an Amazon EC2 instance. Volumes are chosen by specifying an instance. Each volume attached to the specified instance will produce one snapshot that is crash-consistent across the instance. You can include all of the volumes currently attached to the instance, or you can exclude the root volume or specific data (non-root) volumes from the multi-volume snapshot set.

The location of the source instance determines where you can create the snapshots.

  • If the source instance is in a Region, you must create the snapshots in the same Region as the instance.

  • If the source instance is in a Local Zone, you can create the snapshots in the same Local Zone or in its parent Amazon Web Services Region.

  • If the source instance is on an Outpost, you can create the snapshots on the same Outpost or in its parent Amazon Web Services Region.

Parameters:

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

    A description propagated to every snapshot specified by the instance.

  • instance_specification (Optional[InstanceSpecification], default: None ) –

    The instance to specify which volumes should be included in the snapshots.

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

    Only supported for instances on Outposts. If the source instance is not on an Outpost, omit this parameter.

    • To create the snapshots on the same Outpost as the source instance, specify the ARN of that Outpost. The snapshots must be created on the same Outpost as the instance.

    • To create the snapshots 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.

  • tag_specifications (Optional[TagSpecificationList], default: None ) –

    Tags to apply to every snapshot specified by the instance.

  • 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 is UnauthorizedOperation.

  • copy_tags_from_source (Optional[CopyTagsFromSource], default: None ) –

    Copies the tags from the specified volume to corresponding snapshot.

  • location (Optional[SnapshotLocationEnum], default: None ) –

    Only supported for instances in Local Zones. If the source instance is not in a Local Zone, omit this parameter.

    • To create local snapshots in the same Local Zone as the source instance, specify local.

    • To create regional snapshots in the parent Region of the Local Zone, specify regional or omit this parameter.

    Default value: regional

Raises:

Source code in docs_src/capo_ec2/_services/async_ec2.py
async def create_snapshots(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    description: Optional["capo_ec2.types.string.String"] = None,
    instance_specification: Optional[
        "capo_ec2.types.instance_specification.InstanceSpecification"
    ] = None,
    outpost_arn: Optional["capo_ec2.types.string.String"] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    copy_tags_from_source: Optional[
        "capo_ec2.types.copy_tags_from_source.CopyTagsFromSource"
    ] = None,
    location: Optional[
        "capo_ec2.types.snapshot_location_enum.SnapshotLocationEnum"
    ] = None,
) -> "capo_ec2.types.create_snapshots_result.CreateSnapshotsResult":
    """<p>Creates crash-consistent snapshots of multiple EBS volumes attached to an Amazon EC2 instance. Volumes are chosen by specifying an instance. Each volume attached to the specified instance will produce one snapshot that is crash-consistent across the instance. You can include all of the volumes currently attached to the instance, or you can exclude the root volume or specific data (non-root) volumes from the multi-volume snapshot set.</p> <p>The location of the source instance determines where you can create the snapshots.</p> <ul> <li> <p>If the source instance is in a Region, you must create the snapshots in the same Region as the instance.</p> </li> <li> <p>If the source instance is in a Local Zone, you can create the snapshots in the same Local Zone or in its parent Amazon Web Services Region.</p> </li> <li> <p>If the source instance is on an Outpost, you can create the snapshots on the same Outpost or in its parent Amazon Web Services Region.</p> </li> </ul>

    Args:
        description: <p> A description propagated to every snapshot specified by the instance.</p>
        instance_specification: <p>The instance to specify which volumes should be included in the snapshots.</p>
        outpost_arn: <note> <p>Only supported for instances on Outposts. If the source instance is not on an Outpost, omit this parameter.</p> </note> <ul> <li> <p>To create the snapshots on the same Outpost as the source instance, specify the ARN of that Outpost. The snapshots must be created on the same Outpost as the instance.</p> </li> <li> <p>To create the snapshots in the parent Region of the Outpost, omit this parameter.</p> </li> </ul> <p>For more information, see <a href="https://docs.aws.amazon.com/ebs/latest/userguide/snapshots-outposts.html#create-snapshot"> Create local snapshots from volumes on an Outpost</a> in the <i>Amazon EBS User Guide</i>.</p>
        tag_specifications: <p>Tags to apply to every snapshot specified by the instance.</p>
        dry_run: <p>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 <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
        copy_tags_from_source: <p>Copies the tags from the specified volume to corresponding snapshot.</p>
        location: <note> <p>Only supported for instances in Local Zones. If the source instance is not in a Local Zone, omit this parameter.</p> </note> <ul> <li> <p>To create local snapshots in the same Local Zone as the source instance, specify <code>local</code>.</p> </li> <li> <p>To create regional snapshots in the parent Region of the Local Zone, specify <code>regional</code> or omit this parameter.</p> </li> </ul> <p>Default value: <code>regional</code> </p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ec2.types.create_snapshots_request.CreateSnapshotsRequest]",
    ) -> AsyncOperationResponse[
        "capo_ec2.types.create_snapshots_result.CreateSnapshotsResult"
    ]:
        import capo_ec2._operations.amazon_ec2.create_snapshots

        (
            output,
            http_response,
        ) = await capo_ec2._operations.amazon_ec2.create_snapshots.async_create_snapshots(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateSnapshots")
    )
    input_: capo_ec2.types.create_snapshots_request.CreateSnapshotsRequest = {}
    if description is not None:
        input_["description"] = description
    if instance_specification is not None:
        input_["instance_specification"] = instance_specification
    if outpost_arn is not None:
        input_["outpost_arn"] = outpost_arn
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if copy_tags_from_source is not None:
        input_["copy_tags_from_source"] = copy_tags_from_source
    if location is not None:
        input_["location"] = location

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