function copyVolume()

in ec2/gov-cloud-import.js [467:506]


function copyVolume(taskData){
    return new Promise((resolve, reject) => {
	      let govRegion = findGovRegion();
        //Set Object & Params for GovCloud S3 Upload
        let s3 = new AWS.S3({
            region: govRegion,
            accessKeyId: taskData.accessKeyId,
            secretAccessKey: taskData.secretAccessKey
        });
        // call S3 to retrieve upload file to specified bucket
        let uploadParams = {Bucket: taskData.s3Bucket, Key: taskData.volumeId, Body: ''};

        //Read Volume Mount point and set it as S3 boday
        let fileStream = fs.createReadStream(taskData.device);
        fileStream.on('error', function(err) {
            writeToLog(JSON.stringify(err), 'log');
        });
        uploadParams.Body = fileStream;
        //Set S3 Upload Options
        let options = {partSize: 10 * 1024 * 1024, queueSize: 4};
        //call S3 to upload
        s3.upload(uploadParams, options, function (err, data){
            if (err) {
                removeHeartbeat(heartbeat, taskData.taskToken);
                //Send a failure to Step Functions
                sendTaskFailure(taskData.taskToken);
                writeToLog(JSON.stringify(err)), 'log';
                removeVolume(taskData.volumeId);
                reject(err);
            } if (data) {
                removeHeartbeat(heartbeat, taskData.taskToken);
                writeToLog(JSON.stringify(data), 'log');
                resolve(data);
            }
        }).on('httpUploadProgress', function(evt) {
            msg = taskData.volumeId+' Progress: '+formatBytes(evt.loaded)
            writeToLog(msg, "imageProgressLog");
        });
    });
}