Scalr\Service\Aws\Ec2\V20150415\Ec2Api::copySnapshot PHP Method

copySnapshot() public method

Copies a point-in-time snapshot of an Amazon Elastic Block Store (Amazon EBS) volume and stores it in Amazon Simple Storage Service (Amazon S3).You can copy the snapshot within the same region or from one region to another.You can use the snapshot to create new Amazon EBS volumes or Amazon Machine Images (AMIs)
public copySnapshot ( string $srcRegion, string $srcSnapshotId, string $description = null, string $destRegion = null, string $presignedUrl = null, boolean $encrypted = null, string $kmsKeyId = null ) : string
$srcRegion string The ID of the AWS region that contains the snapshot to be copied.
$srcSnapshotId string The ID of the Amazon EBS snapshot to copy.
$description string optional A description of the new Amazon EBS snapshot.
$destRegion string optional The ID of the destination region.
$presignedUrl string optional The pre-signed URL that facilitates copying an encrypted snapshot. The PresignedUrl should use the snapshot source endpoint, the CopySnapshot action, and include the SourceRegion, SourceSnapshotId, and DestinationRegion parameters.
$encrypted boolean Specifies whether the destination snapshot should be encrypted. There is no way to create an unencrypted snapshot copy from an encrypted snapshot; however, you can encrypt a copy of an unencrypted snapshot with this flag.
$kmsKeyId string The full ARN of the AWS Key Management Service (AWS KMS) CMK to use when creating the snapshot copy. This parameter is only required if you want to use a non-default CMK; if this parameter is not specified, the default CMK for EBS is used.
return string Returns ID of the created snapshot on success.
    public function copySnapshot($srcRegion, $srcSnapshotId, $description = null, $destRegion = null, $presignedUrl = null, $encrypted = null, $kmsKeyId = null)
    {
        $result = null;
        $options = ['SourceRegion' => (string) $srcRegion, 'SourceSnapshotId' => (string) $srcSnapshotId];
        if ($description !== null) {
            $options['Description'] = (string) $description;
        }
        if ($destRegion !== null) {
            //It overrides region to copy
            $options['_host'] = $this->ec2->getUrl($destRegion);
            $options['_region'] = $destRegion;
            $options['DestinationRegion'] = (string) $destRegion;
            if ($presignedUrl !== null) {
                $options['PresignedUrl'] = (string) $presignedUrl;
            }
        }
        if ($encrypted !== null) {
            $options['Encrypted'] = (bool) $encrypted;
        }
        if ($kmsKeyId !== null) {
            $options['KmsKeyId'] = (string) $kmsKeyId;
        }
        $response = $this->client->call(ucfirst(__FUNCTION__), $options);
        if ($response->getError() === false) {
            $sxml = simplexml_load_string($response->getRawContent());
            $result = (string) $sxml->snapshotId;
        }
        return $result;
    }
Ec2Api