// DefaultCredentials assumes a user has logged in with gcloud. // See here for more information: // https://cloud.google.com/docs/authentication/getting-started creds, err := gcp.DefaultCredentials(ctx) if err != nil { return nil, err } c, err := gcp.NewHTTPClient(gcp.DefaultTransport(), gcp.CredentialsTokenSource(creds)) if err != nil { return nil, err } // The bucket name must be globally unique. return gcsblob.OpenBucket(ctx, bucket, c) }
c := &aws.Config{ // Either hard-code the region or use AWS_REGION. Region: aws.String("us-east-2"), // credentials.NewEnvCredentials assumes two environment variables are // present: // 1. AWS_ACCESS_KEY_ID, and // 2. AWS_SECRET_ACCESS_KEY. Credentials: credentials.NewEnvCredentials(), } s := session.Must(session.NewSession(c)) return s3blob.OpenBucket(ctx, s, bucket) }