Storage Transfer Service can listen to event notifications in AWS to automatically transfer data that has been added or updated in the source location, into a Cloud Storage bucket. Learn more about the benefits of event-driven transfers.
Event-driven transfers listen to Amazon S3 Event Notifications sent to Amazon SQS to know when objects in the source bucket have been modified or added. Object deletions are not detected; deleting an object at the source does not delete the associated object in the destination bucket.
Event-driven transfers always use a Cloud Storage bucket as the destination.
Before you begin
Follow the instructions to grant the required permissions on your destination Cloud Storage bucket:
Create an SQS queue
In the AWS console, go to the Simple Queue Service page.
Click Create queue.
Enter a Name for this queue.
In the Access policy section, select Advanced. A JSON object is displayed.
Standard AWS regions
{ "Version": "2008-10-17", "Id": "\_\_default\_policy\_ID", "Statement": [ { "Sid": "\_\_owner\_statement", "Effect": "Allow", "Principal": { "AWS": "01234567890" }, "Action": [ "SQS:*" ], "Resource": "arn:aws:sqs:us-west-2:01234567890:test" } ] }
AWS GovCloud regions
{ "Version": "2008-10-17", "Id": "\_\_default\_policy\_ID", "Statement": [ { "Sid": "\_\_owner\_statement", "Effect": "Allow", "Principal": { "AWS": "01234567890" }, "Action": [ "SQS:*" ], "Resource": "arn:aws-us-gov:sqs:us-gov-west-1:01234567890:test" } ] }
Copy the values of
AWSandResource. These are unique for each project.Paste your specific values of
AWSandResourcefrom the previous step into the following JSON snippet:Standard AWS regions
{ "Version": "2012-10-17", "Id": "example-ID", "Statement": [ { "Sid": "example-statement-ID", "Effect": "Allow", "Principal": { "Service": "s3.amazonaws.com" }, "Action": "SQS:SendMessage", "Resource": "RESOURCE", "Condition": { "StringEquals": { "aws:SourceAccount": "AWS" }, "ArnLike": { "aws:SourceArn": "arn:aws:s3:::S3_BUCKET_NAME" } } } ] }
AWS GovCloud regions
{ "Version": "2012-10-17", "Id": "example-ID", "Statement": [ { "Sid": "example-statement-ID", "Effect": "Allow", "Principal": { "Service": "s3.amazonaws.com" }, "Action": "SQS:SendMessage", "Resource": "RESOURCE", "Condition": { "StringEquals": { "aws:SourceAccount": "AWS" }, "ArnLike": { "aws:SourceArn": "arn:aws-us-gov:s3:::S3_BUCKET_NAME" } } } ] }
Replace S3_BUCKET_NAME with the S3 source bucket's name.
Copy this completed JSON snippet and use it to replace the JSON displayed in the Access policy section.
Click Create queue.
Once complete, note the Amazon Resource Name (ARN) of the queue.
Enable notifications on your S3 bucket
In the AWS console, go to the S3 page.
In the Buckets list, select your source bucket.
Select the Properties tab.
In the Event notifications section, click Create event notification.
Specify a name for this event.
In the Event types section, select All object create events.
As the Destination select SQS queue and select the queue you created for this transfer.
Click Save changes.
Configure permissions
Follow the instructions in Configure access to a source: Amazon S3 to create either an access key ID and secret key, or a Federated Identity role.
While following the instructions, use the following JSON when directed to specify a custom role or a custom trust policy:
Standard AWS regions
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "sqs:DeleteMessage", "sqs:ChangeMessageVisibility", "sqs:ReceiveMessage", "s3:GetObject", "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::S3_BUCKET_NAME", "arn:aws:s3:::S3_BUCKET_NAME/*", "AWS_QUEUE_ARN" ] } ] }
Once created, note the following information:
- For a user, note the access key ID and secret key.
- For a Federated Identity role, note the Amazon Resource Name (ARN),
which has the following format:
arn:aws:iam::AWS_ACCOUNT:role/AWS_ROLE_NAME
AWS GovCloud regions
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "sqs:DeleteMessage", "sqs:ChangeMessageVisibility", "sqs:ReceiveMessage", "s3:GetObject", "s3:ListBucket" ], "Resource": [ "arn:aws-us-gov:s3:::S3_BUCKET_NAME", "arn:aws-us-gov:s3:::S3_BUCKET_NAME/*", "AWS_QUEUE_ARN" ] } ] }
Once created, note the following information:
- For a user, note the access key ID and secret key.
- For a Federated Identity role, note the Amazon Resource Name (ARN),
which has the following format:
arn:aws-us-gov:iam::AWS_ACCOUNT:role/AWS_ROLE_NAME
Create a transfer job
You can use the REST API or the Google Cloud console to create an event-based transfer job.
Cloud console
Go to the Create transfer job page in the Google Cloud console.
Select Amazon S3 as the source type, and Cloud Storage as the destination.
As the Scheduling mode select Event-driven and click Next step.
Enter your S3 bucket name. The bucket name is the name as it appears in the AWS Management Console. For example,
my-aws-bucket.Select your authentication method and enter the requested information, which you created and noted in the previous section.
Enter the Amazon SQS queue ARN that you created earlier. It uses one of the following formats:
- For standard AWS regions:
arn:aws:sqs:AWS_REGION:AWS_ACCOUNT:AWS_QUEUE_NAME - For AWS GovCloud regions:
arn:aws-us-gov:sqs:AWS_REGION:AWS_ACCOUNT:AWS_QUEUE_NAME
- For standard AWS regions:
Optionally, define any filters, then click Next step.
Select the destination Cloud Storage bucket and, optionally, path.
Optionally, enter a start and end time for the transfer. If you don't specify a time, the transfer will start immediately and will run until manually stopped.
Specify any transfer options. More information is available from the Create transfers page.
Click Create.
Once created, the transfer job starts running and an event listener waits for notifications on the SQS queue. The job details page shows one operation each hour, and includes details on data transferred for each job.
REST
To create an event-driven transfer using the REST API, send the following JSON object to the transferJobs.create endpoint:
{ "description": "DESCRIPTION", "status": "ENABLED", "projectId": "PROJECT_ID", "transferSpec": { "awsS3DataSource": { "bucketName": "S3_BUCKET_NAME", "roleArn": "AWS_ROLE_ARN" }, "gcsDataSink": { "bucketName": "GCS_BUCKET_NAME" } }, "eventStream": { "name": "AWS_QUEUE_ARN", "eventStreamStartTime": "2022-12-02T01:00:00+00:00", "eventStreamExpirationTime": "2023-01-31T01:00:00+00:00" } }
The placeholders in the preceding JSON use the following values:
- DESCRIPTION is a description of the transfer job.
- PROJECT_ID is the ID of the Google Cloud project where the transfer job is created.
- S3_BUCKET_NAME is the name of the Amazon S3 source bucket.
- AWS_ROLE_ARN is the ARN of the Federated Identity role you
created. For example,
arn:aws:iam::1234567891011:role/aws-role-namefor standard AWS regions orarn:aws-us-gov:iam::1234567891011:role/aws-role-namefor AWS GovCloud regions. - GCS_BUCKET_NAME is the name of the Cloud Storage destination bucket.
- AWS_QUEUE_ARN is the ARN of the SQS queue. For example,
arn:aws:sqs:us-east-1:1234567891011:s3-notification-queuefor standard AWS regions orarn:aws-us-gov:sqs:us-gov-east-1:1234567890:event-queuefor AWS GovCloud regions.
The eventStreamStartTime and eventStreamExpirationTime are optional.
If the start time is omitted, the transfer starts immediately; if the end
time is omitted, the transfer continues until manually stopped.
Client libraries
Go
To learn how to install and use the client library for Storage Transfer Service, see Storage Transfer Service client libraries. For more information, see the Storage Transfer Service Go API reference documentation.
To authenticate to Storage Transfer Service, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
To learn how to install and use the client library for Storage Transfer Service, see Storage Transfer Service client libraries. For more information, see the Storage Transfer Service Java API reference documentation.
To authenticate to Storage Transfer Service, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
To learn how to install and use the client library for Storage Transfer Service, see Storage Transfer Service client libraries. For more information, see the Storage Transfer Service Node.js API reference documentation.
To authenticate to Storage Transfer Service, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
To learn how to install and use the client library for Storage Transfer Service, see Storage Transfer Service client libraries. For more information, see the Storage Transfer Service Python API reference documentation.
To authenticate to Storage Transfer Service, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.