The Simplest Way to Make Pulumi and Terraform Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use pulumi and terraform together to share cloud state across different code bases. This setup lets app teams write general code while ops teams keep core templates. Many groups already manage core networks and databases with older state files. New app services often need modern code languages to deploy fast. Running both tools side by side avoids a risky full rewrite. Each tool reads the outputs of the other without touching raw resources. How pulumi and terraform share state and permi

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 pulumi and terraform together to share cloud state across different code bases. This setup lets app teams write general code while ops teams keep core templates.

Many groups already manage core networks and databases with older state files. New app services often need modern code languages to deploy fast. Running both tools side by side avoids a risky full rewrite. Each tool reads the outputs of the other without touching raw resources.

How pulumi and terraform share state and permissions

Both tools rely on state files to track cloud resources over time. One tool writes resource IDs and network values into a remote state store. The other tool reads those exact values during its own deployment run. This flow keeps network rules and app settings in sync at all times.

Identity roles control how each tool logs into the cloud backend. The reading tool only needs read rights on the shared state bucket. The writing tool holds full write rights for its own state path. Separating these roles stops one deploy job from breaking another team's work.

Data flows one way in the safest setups. Base cloud layers push subnet IDs and cluster names to the state backend. App layers pull those values as read-only inputs during a build run. Neither tool tries to change resources owned by the other tool.

Common failure modes and how to scope roles

Shared service accounts cause the worst outages in dual-tool setups. When both tools use one broad cloud key, any mistake can wipe out core systems. A bad script in an app repo might delete a shared database. Broad tokens also make audit logs hard to read after an incident.

State lock clashes are another common failure mode for busy teams. If two jobs try to write to the same state file, deploys fail. Teams fix this by keeping separate state files for each tool and layer. One tool never writes to a state file created by the other.

Terraform Security (tfsec, Checkov) + Pulumi Policy as Code: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Unlogged state reads also create hidden security risks. State files often hold plain text secrets like database passwords or API keys. If any developer laptop can read the state bucket, secrets leak fast. Teams must scope read roles to specific build runners and log every read request.

Best practices for day-to-day workflows

Start by drawing a clear line between base layers and app layers. Keep base networks, storage buckets, and core identity roles in one tool. Build fast-changing app tasks, serverless jobs, and queues in the second tool. This split matches how platform teams and app teams work each day.

Set up automated pipelines so engineers do not run cloud changes from local laptops. Build runners should request short-term cloud roles for each job. Tag every cloud resource with the name of the tool that owns it. Clear tags stop engineers from editing a resource in the wrong repo.

Mask sensitive fields in build logs before teams review deploy output. Masking rewrites matched fields like emails, phone numbers, card numbers, or national IDs in results. This step keeps private data out of shared build logs during debug work.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Can both tools manage the exact same cloud resource at once?

No, having two tools write to one resource causes drift and deploy errors. Always assign one owner tool per resource and share values through read-only state outputs.

Do we need to rewrite old templates to use both tools?

No rewrite is needed to use both tools in production. Keep your stable base templates as they are and read their outputs from new stacks.

How do we protect secrets stored inside shared state files?

Encrypt the remote state backend at rest and restrict read roles to build runners. Never allow broad user roles to download raw state files to local machines.

The query runs. The emails stay hidden.