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

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use opentofu and pulumi together by sharing cloud state outputs across stacks. OpenTofu builds base cloud networks while Pulumi deploys app services on top. This split lets network admins use declarative files for core cloud rules. App developers then use general code languages to ship their own services. Both tools read and write to remote state buckets in the cloud. When teams link those state files with care, updates run fast and clean. How opentofu and pulumi share identity and stat

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 opentofu and pulumi together by sharing cloud state outputs across stacks. OpenTofu builds base cloud networks while Pulumi deploys app services on top.

This split lets network admins use declarative files for core cloud rules. App developers then use general code languages to ship their own services. Both tools read and write to remote state buckets in the cloud. When teams link those state files with care, updates run fast and clean.

How opentofu and pulumi share identity and state

Each tool needs its own cloud role to run jobs and read state. OpenTofu runs first and writes network IDs into a remote state file. That state file sits in cloud object storage with strict read rules. Pulumi then logs in with a separate role to read those outputs.

Pulumi reads the network IDs and builds app stacks in those subnets. It never changes the base state file that OpenTofu owns and manages. Instead, Pulumi writes its own app state to a second storage path. This one-way data flow stops the two tools from fighting over resources.

Both tools log in to the cloud provider through short-lived workload tokens. Your build pipeline requests a fresh token before each run starts up. The cloud provider checks the pipeline identity and grants a scoped role. Neither tool needs long-lived static keys saved on developer laptops or build servers.

Common failure modes in dual stack workflows

Many teams fail when they share one admin role across both tools. If a build script has full cloud rights, any small bug can delete data. A bad Pulumi script might wipe out core subnets built by OpenTofu. Shared service accounts also make cloud audit logs very hard to read.

When both tools use one identity, you cannot tell who made a change. Security teams cannot trace a bad firewall rule back to a specific job. Another common issue happens when developers run updates from their local machines. Local runs often use broad personal keys and skip peer review steps.

Pulumi Policy as Code + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

State lock clashes also break builds when two tools share one storage path. If both tools try to write to the same state bucket, runs fail. You also risk leaking database passwords stored as plain text inside state files. Anyone with broad read rights on the state bucket can see those secrets.

Scoping roles and network paths between stacks

To fix these issues, create separate cloud roles for each tool and stage. Give the OpenTofu role write rights only on base network and storage items. Give the Pulumi role write rights only on app compute and service items. Allow the Pulumi role to read the OpenTofu state file without write rights.

Lock down network paths so build runners only reach required cloud endpoints. Run all state updates from central build workers inside a private subnet. Block write runs from developer laptops by restricting who can assume deploy roles. Let developers run read-only plan checks when they test code changes locally.

Encrypt all state files at rest using keys managed by your cloud provider. Grant key read rights only to the specific roles that need state outputs. Mask sensitive fields like emails, phone numbers, card numbers, or national IDs in logs. Turn on storage access logs so you can audit every state read event.

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

Which tool should own shared cloud resources?

Let OpenTofu own shared base resources like virtual networks, DNS zones, and IAM roles. Let Pulumi own app-level resources like containers, queues, and serverless functions that change often.

Can Pulumi read OpenTofu state without write permissions?

Yes, Pulumi only needs read permissions on the remote storage bucket holding OpenTofu state. You should block write access so app deployments never alter your base network state.

How do we handle secrets passed between the two tools?

Do not pass raw secrets through shared state outputs between the two tools. Instead, write secrets to a cloud secret manager and pass only the secret reference ID.

The query runs. The emails stay hidden.