The Simplest Way to Make Cloud Functions and S3 Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use cloud functions and S3 to run code and store files across clouds. A function runs on demand and reads or writes objects in a bucket. This setup helps teams process logs, resize images, and move backups across cloud accounts. It keeps storage costs low while letting small apps run only when needed. Many teams keep code in one cloud and data in another cloud. That split requires clear identity rules, safe network paths, and good audit logs. How cloud functions and S3 share roles and

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Teams use cloud functions and S3 to run code and store files across clouds. A function runs on demand and reads or writes objects in a bucket.

This setup helps teams process logs, resize images, and move backups across cloud accounts. It keeps storage costs low while letting small apps run only when needed.

Many teams keep code in one cloud and data in another cloud. That split requires clear identity rules, safe network paths, and good audit logs.

How cloud functions and S3 share roles and move data

First, the function starts when a timer, webhook, or queue sends an event. Next, the runtime checks its own cloud identity before making an outbound call.

Standard setups once used long-lived secret keys stored inside the function settings. A safer pattern uses workload identity federation between the two cloud providers.

With federation, the function presents a short token from its own host platform. The storage provider checks that token and grants a temporary role for the bucket.

Once the role is active, the function sends a secure request over TLS. It reads the target file, processes the content, or writes a new object back.

Data flows over the public internet unless teams set up private network links. Good bucket rules check both the caller role and the source network path.

Memory limits on the function also shape how data moves between both services. Instead of loading huge files at once, the code streams chunks from the bucket.

Common failure modes and how to scope permissions

Shared service accounts cause the biggest security gaps in cross-cloud file workflows. When ten functions share one key, a single bug exposes every bucket at once.

Broad bucket policies create another common problem for growing engineering teams. Giving a function full read and write rights lets bad code delete core backups.

Cloud Functions IAM + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Unlogged requests also hurt teams during security reviews and incident checks. If bucket access logs are off, nobody knows which function read a sensitive file.

Sensitive files often hold emails, phone numbers, card numbers, or national IDs. Without data masking to rewrite matched fields in results, test runs expose real records.

To fix these issues, give every function its own dedicated identity and role. Scope each role to the exact bucket prefix and action the code needs.

Read-only jobs should never hold permission to write or delete objects in storage. Write-only log shippers should never hold permission to list or read old files.

Turn on object-level audit logs in the storage account to track every request. Record the caller identity, the timestamp, the bucket path, and the response code.

Testing and running cross-cloud workflows in production

Local testing often pushes developers to download static keys onto their laptops. Those local keys can leak in chat logs, code commits, or build outputs.

Instead, developers should test against small staging buckets with short-lived test roles. Automated checks in the build pipeline should reject any code with hardcoded keys.

Timeouts and retries also need clear limits when functions talk to remote buckets. A slow network call can cause the function to run out of time.

If a function retries without a unique request ID, it might write duplicate files. Using clear file names and idempotent writes keeps bucket data clean during retries.

Teams should also watch outbound bandwidth bills when moving files across cloud regions. Placing compute and storage in nearby regions cuts transfer latency and lowers monthly costs.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

How can a function access S3 without static access keys?

Use workload identity federation between your function host and the storage account. The function exchanges its native identity token for a short-lived storage role.

How do you limit what a function can read in a bucket?

Give each function a unique role and scope permissions to specific folder prefixes. Only allow the exact read or write actions required for that single task.

What is the best way to handle large files in a function?

Stream the file in small chunks rather than loading it all into memory. You can also generate a presigned URL so clients upload directly to storage.

The query runs. The emails stay hidden.