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.

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.
The S3 vs Cloud Storage comparison goes deeper on pricing and features.
Before copying anything, list:
aws s3 ls --recursive --summarize.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.
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:
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.
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:
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.
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 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.

Run in your terminal to get started locally.
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.
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.
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.
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.
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.