Updated Nov 23, 20267 min read

How to Migrate from Amazon S3 to Google Cloud Storage

A step-by-step migration of S3 buckets to Cloud Storage: mapping storage classes, policies, presigned URLs and lifecycle rules, copying objects with Storage Transfer Service using federated access instead of long-lived keys, running incremental syncs until cutover, verifying counts and bytes, and moving application code off the S3 API.

Illustration for How to Migrate from Amazon S3 to Google Cloud Storage

Moving a bucket from S3 to Cloud Storage is mostly a copy job with a long tail. The objects move with one managed service, and then come the presigned URLs in emails, the lifecycle rules, the IAM policies and every place in the code that calls the S3 API.

This guide covers both parts, in the order that keeps S3 as a fallback until the end.

How do S3 concepts map to Cloud storage?

Amazon S3Google Cloud Storage
Bucket, global namespaceBucket, global namespace
Standard, Standard-IA, Glacier classesStandard, Nearline, Coldline, Archive
Bucket policy and IAM policiesIAM on the bucket, with uniform bucket-level access
Presigned URL, up to 7 daysV4 signed URL, up to 7 days
Lifecycle rulesObject Lifecycle Management rules
VersioningObject versioning
x-amz-meta-* metadatax-goog-meta-* metadata
S3 event notificationsPub/Sub notifications for Cloud Storage
ETag, MD5 for single-part uploadsMD5 and CRC32C hashes

The S3 vs Cloud Storage comparison goes deeper on pricing and features.

Step 1: inventory what uses the bucket

Before copying anything, list:

  • Buckets, object counts and total size, from S3 Storage Lens or aws s3 ls --recursive --summarize.
  • Storage classes in use, since Glacier objects need a restore before they can be read and copied.
  • Who reads and writes, from bucket policies, IAM policies and CloudTrail data events.
  • Presigned URLs with long lifetimes, in emails, exports or partner integrations, which will break at cutover.
  • Event notifications that trigger Lambda functions or queues.
  • Public access, through a bucket policy or CloudFront.

Step 2: create the destination bucket

Pick a location close to the services that will read the data, turn on uniform bucket-level access so permissions come from IAM only, and set versioning and lifecycle rules to match the S3 bucket before data arrives. If the application is moving to GCP at the same time, the bucket can come from application code, as shown in step 5.

Step 3: copy with storage transfer service

Storage Transfer Service copies from S3 with no servers of your own. It needs s3:ListBucket and s3:GetObject on the source, per the S3 source docs, and it can authenticate with an AWS role that trusts Google's identity instead of an access key. The trust policy for that role:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Federated": "accounts.google.com" }, "Action": "sts:AssumeRoleWithWebIdentity", "Condition": { "StringEquals": { "accounts.google.com:sub": "SUBJECT_ID" } } } ] }

SUBJECT_ID is the subject ID of the transfer service agent for your project, which the Storage Transfer Service docs show how to look up. Attach a policy with s3:ListBucket on the bucket and s3:GetObject on its objects, and use the role ARN when creating the job in the console or the API.

From the command line, gcloud transfer jobs create takes a credentials file, which suits a short-lived migration user whose key you delete afterwards:

~
$ gcloud transfer jobs create s3://acme-documents gs://acme-documents-gcs \ --source-creds-file=creds.json \ --overwrite-when=different \ --schedule-repeats-every=1h

The first run copies everything, and each hourly run copies only new or changed objects, since --overwrite-when=different compares ETags or checksums. The default is to delete nothing on either side, which keeps S3 intact. AWS bills the data transferred out of S3, so check the estimate against the inventory from step 1 before starting a large job.

Step 4: verify the copy

Storage Transfer Service checks each object's integrity during the transfer and logs failures, so start with the job's run history. Then compare totals per prefix:

~
$ aws s3 ls s3://acme-documents/invoices/ --recursive --summarize | tail -2$ gcloud storage du gs://acme-documents-gcs/invoices/ --summarize

Object counts and byte totals should match for every prefix that no longer receives writes. Prefixes still being written will lag by up to one sync interval.

Step 5: move the application code

Every S3 client call has to change: uploads, downloads, existence checks, listing and presigned URL generation. Doing it through a storage interface that the application owns, instead of swapping one SDK for another, keeps the next move cheaper.

Encore

Encore brings infrastructure from code, and a bucket is declared in the service that uses it with the object storage API, and deploying to a GCP environment provisions it as a Cloud Storage bucket in your own project, with access granted to that service's account, as the GCP infrastructure docs describe. If you created the destination bucket in step 2 and filled it with Storage Transfer Service, import it from the environment's infrastructure page instead, and the code keeps using the same bucket name.

Application code passes through Encore and infrastructure guardrails to resources provisioned in your own AWS or GCP account.

Set up the app

Get started
brew install encoredev/tap/encore &&
encore app create
Copy

Run in your terminal to get started locally.

~
$ encore app create documents --example=hello-world$ cd documents && mkdir documents

The service below replaces the S3 calls for a document store: signed upload and download URLs, and an inventory endpoint that reports counts and bytes per prefix for the verification in step 4:

// documents/documents.go package documents import ( "context" "errors" "strings" "time" "encore.dev/beta/errs" "encore.dev/storage/objects" ) var Documents = objects.NewBucket("documents", objects.BucketConfig{Versioned: true}) type KeyParams struct { Key string `json:"key"` } type URLResponse struct { URL string `json:"url"` } func validKey(key string) bool { return key != "" && !strings.HasPrefix(key, "/") && !strings.Contains(key, "..") } //encore:api auth method=POST path=/documents/upload-url func UploadURL(ctx context.Context, p *KeyParams) (*URLResponse, error) { if !validKey(p.Key) { return nil, errs.B().Code(errs.InvalidArgument).Msg("invalid key").Err() } u, err := Documents.SignedUploadURL(ctx, p.Key, objects.WithTTL(10*time.Minute)) if err != nil { return nil, err } return &URLResponse{URL: u.URL}, nil } //encore:api auth method=POST path=/documents/download-url func DownloadURL(ctx context.Context, p *KeyParams) (*URLResponse, error) { if !validKey(p.Key) { return nil, errs.B().Code(errs.InvalidArgument).Msg("invalid key").Err() } if _, err := Documents.Attrs(ctx, p.Key); errors.Is(err, objects.ErrObjectNotFound) { return nil, errs.B().Code(errs.NotFound).Msg("document not found").Err() } else if err != nil { return nil, err } u, err := Documents.SignedDownloadURL(ctx, p.Key, objects.WithTTL(15*time.Minute)) if err != nil { return nil, err } return &URLResponse{URL: u.URL}, nil } type InventoryParams struct { Prefix string `json:"prefix"` } type InventoryResponse struct { Objects int64 `json:"objects"` Bytes int64 `json:"bytes"` } // Inventory totals objects under a prefix, to compare with the S3 listing. // //encore:api private method=POST path=/documents/inventory func Inventory(ctx context.Context, p *InventoryParams) (*InventoryResponse, error) { var resp InventoryResponse for entry, err := range Documents.List(ctx, &objects.Query{Prefix: p.Prefix}) { if err != nil { return nil, err } resp.Objects++ resp.Bytes += entry.Size } return &resp, nil }

The auth endpoints need an auth handler, and this placeholder stands in for your existing session check:

// documents/auth.go package documents import ( "context" "encore.dev/beta/auth" "encore.dev/beta/errs" ) // Replace with your session or token check. // //encore:authhandler func AuthHandler(ctx context.Context, token string) (auth.UID, error) { if token == "" { return "", errs.B().Code(errs.Unauthenticated).Msg("missing token").Err() } return auth.UID(token), nil }

encore run stores objects on the local filesystem, so the upload and download flow and the inventory endpoint work on a laptop before any cloud bucket exists. In the GCP environment the same code signs Cloud Storage URLs, with the service account granted access to the resources the service uses. A coding agent porting the remaining S3 calls can change one call site at a time and run each against the local bucket in the same change, with no IAM binding to request first.

Best fit: Applications moving their compute to GCP along with their files, that want the bucket and its permissions declared next to the code that uses them.

Step 6: cut over

  1. Deploy the new code with reads and writes going to Cloud Storage, behind a flag.
  2. Pause writes to S3 for the affected prefixes, or switch writers first and keep readers on S3 for one more sync.
  3. Run a final Storage Transfer Service sync and verify counts and bytes.
  4. Flip readers to Cloud Storage, and reissue any long-lived presigned URLs as signed URLs.
  5. Disable the recurring transfer job, and keep the S3 bucket read-only for a few weeks before deleting it.

S3 to Cloud storage migration checklist

  • Inventory buckets, classes, readers, writers and long-lived presigned URLs.
  • Restore Glacier objects that need to move before the transfer.
  • Create the destination with uniform bucket-level access, versioning and lifecycle rules.
  • Copy with a federated AWS role, or a short-lived key you delete afterwards.
  • Run incremental syncs and verify counts and bytes per prefix.
  • Move every S3 call site, then cut over and keep S3 read-only for a while.

Frequently asked questions

What is the best way to copy S3 data to Google Cloud Storage?

Storage Transfer Service is the managed option, and it lists and copies objects from S3 to a Cloud Storage bucket without servers of your own, verifies checksums, can run on a schedule for incremental syncs and can authenticate to AWS through a federated role instead of an access key. For small buckets, gcloud storage or rclone work too.

Does Storage Transfer Service delete objects from S3?

No, not by default. The delete setting defaults to never, and you can choose to delete from the source after transfer or delete destination objects that are not in the source. Keep the default during a migration so S3 stays the fallback until cutover.

Do S3 presigned URLs work on Google Cloud Storage?

No. Presigned URLs are signed for S3 and stop working once objects move. Cloud Storage has its own V4 signed URLs with a maximum lifetime of 7 days, so the code that issues URLs has to switch to the Cloud Storage client and regenerate them.

Can the new bucket be declared in application code?

Yes. With Encore, a bucket declared in code is provisioned as a Cloud Storage bucket in your own GCP project, the service that uses it gets access, and an existing bucket filled by Storage Transfer Service can be imported instead.

Deploy to your cloud on AWS and Google Cloud
without managing infrastructure

Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.

~/orders — claude
Claude Code
Claude Code v2.1.180Opus 5.5~/orders