The Simplest Way to Make Drone and IAM Roles Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use drone and iam roles together to run build pipelines with cloud permissions. Drone runs container steps while IAM roles grant temporary cloud permissions to those jobs. This workflow lets build runners push code, update servers, and read secrets without long-lived keys. Your team gets a clean pipeline that follows strict cloud security rules. How drone and iam roles share permissions and data Drone runs every pipeline step inside a fresh container on a host runner. When a build step

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 drone and iam roles together to run build pipelines with cloud permissions. Drone runs container steps while IAM roles grant temporary cloud permissions to those jobs.

This workflow lets build runners push code, update servers, and read secrets without long-lived keys. Your team gets a clean pipeline that follows strict cloud security rules.

How drone and iam roles share permissions and data

Drone runs every pipeline step inside a fresh container on a host runner. When a build step needs cloud resources, it must prove its identity first.

Many teams attach an IAM role straight to the host machine or cluster node. Other teams use federated tokens to trade a build job identity for a cloud role.

Once the cloud provider checks the identity, it returns a short-lived session token. The build container uses this token to call cloud APIs and push build files.

Data flows from your code repo into the Drone runner during the build step. Then the runner sends built artifacts out to your cloud storage or server fleet.

When the step ends, Drone destroys the container and wipes the temporary workspace. The temporary cloud session expires on its own after a set clock limit.

Common failure modes with shared runners and broad roles

The biggest risk happens when teams bind one broad role to a shared host. Every container on that host can grab the same cloud permissions from local metadata.

A test branch from a pull request could read production secrets or delete buckets. Static cloud keys stored inside Drone secret stores create another major security gap.

AWS IAM Policies + Lambda Execution Roles: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Long-lived keys sit in settings for months and rarely get rotated by busy engineers. If a build log prints those keys by mistake, attackers can steal them fast.

Shared service roles also ruin your cloud audit logs during a security review. Cloud logs show the role name, not the person who triggered the Drone build.

You can fix this by blocking host metadata paths from default build containers. Give each repo or branch its own tight role with narrow cloud rules.

Scoping network paths and role rules for build jobs

Start by splitting your runners into separate groups for test and production workloads. Put production runners in a private network segment with strict outbound firewall rules.

Next, write IAM role trust rules that check the exact repo and branch name. Only allow a main branch build to assume a role that touches production.

Feature branches should only get roles that read test data or push draft images. Keep the session time limit short so tokens die right after the build finishes.

When build scripts query databases, make sure sensitive fields get handled with care. Data masking can rewrite emails, phone numbers, card numbers, and national IDs in results.

Tag every assumed role session with the build number and commit author name. This simple habit links every cloud API call back to a specific code change.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Why should we avoid host instance roles on shared Drone runners?

Any container on a shared host can reach the local metadata service by default. That means untrusted test builds can use the same cloud permissions as production jobs.

How do we restrict which Drone branches can assume a production role?

Use identity tokens or separate runner pools that map to specific git branches. Set the cloud role trust policy to reject requests from feature or pull request branches.

How can we trace cloud changes back to a specific Drone build?

Pass the Drone build number and git commit hash as session tags during role assumption. Your cloud audit logs will record those tags alongside every API call made.

The query runs. The emails stay hidden.