MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

storagetransfer/aws-request.js:19–103  ·  view source on GitHub ↗
(
  projectId,
  description,
  awsSourceBucket,
  gcsSinkBucket,
  awsAccessKeyId = process.env.AWS_ACCESS_KEY_ID,
  awsSecretAccessKey = process.env.AWS_SECRET_ACCESS_KEY
)

Source from the content-addressed store, hash-verified

17'use strict';
18
19async function main(
20 projectId,
21 description,
22 awsSourceBucket,
23 gcsSinkBucket,
24 awsAccessKeyId = process.env.AWS_ACCESS_KEY_ID,
25 awsSecretAccessKey = process.env.AWS_SECRET_ACCESS_KEY
26) {
27 // [START storagetransfer_transfer_from_aws]
28
29 // Imports the Google Cloud client library
30 const {
31 StorageTransferServiceClient,
32 } = require('@google-cloud/storage-transfer');
33
34 /**
35 * TODO(developer): Uncomment the following lines before running the sample.
36 */
37 // The ID of the Google Cloud Platform Project that owns the job
38 // projectId = 'my-project-id'
39
40 // A useful description for your transfer job
41 // description = 'My transfer job'
42
43 // AWS S3 source bucket name
44 // awsSourceBucket = 'my-s3-source-bucket'
45
46 // AWS Access Key ID
47 // awsAccessKeyId = 'AKIA...'
48
49 // AWS Secret Access Key
50 // awsSecretAccessKey = 'HEAoMK2.../...ku8'
51
52 // Google Cloud Storage destination bucket name
53 // gcsSinkBucket = 'my-gcs-destination-bucket'
54
55 // Creates a client
56 const client = new StorageTransferServiceClient();
57
58 /**
59 * Creates a one-time transfer job from Amazon S3 to Google Cloud Storage.
60 */
61 async function transferFromS3() {
62 // Setting the start date and the end date as the same time creates a
63 // one-time transfer
64 const now = new Date();
65 const oneTimeSchedule = {
66 day: now.getDate(),
67 month: now.getMonth() + 1,
68 year: now.getFullYear(),
69 };
70
71 // Runs the request and creates the job
72 const [transferJob] = await client.createTransferJob({
73 transferJob: {
74 projectId,
75 description,
76 status: 'ENABLED',

Callers 1

aws-request.jsFile · 0.70

Calls 1

transferFromS3Function · 0.85

Tested by

no test coverage detected