Managing Temporal Cloud with Terraform

Managing Temporal Cloud with Terraform puts namespaces, users, service accounts and API keys under version control, with changes reviewed and applied through a pipeline instead of the console.

On this page

Managing Temporal Cloud with Terraform: when code beats the console

Terraform-based management puts Temporal Cloud namespaces, users, service accounts and API keys in version-controlled code, so every access change is reviewed, repeatable and visible. Teams need it once several namespaces, teams and worker fleets share one Temporal Cloud account and access has been changed by hand in the console. At that point, nobody can say with confidence who holds which role, which namespace a service account can reach, or why a key was created. Reviewing a pull request that changes a role binding is a far better control than trying to reconstruct a console session from memory. Code also gives you a repeatable way to create the same namespace layout in a second environment, such as a staging account, without clicking through the same screens again.

It helps to separate two layers that teams often blur. Managing the control plane as code means describing the Temporal Cloud account itself: namespaces, the users and service accounts that can act on them, their roles and the API keys they use. Managing workflow code is a different job, covering the workflow definitions, activities and workers that run inside a namespace and are released through your application pipeline. Terraform touches only the first layer. The Temporal Cloud Terraform provider is the integration point between your repository and the account, and your plan and apply steps are where a change to access is checked before it takes effect. Before you adopt it, confirm the resource names, arguments and provider version against the provider documentation in your own environment, because those details change between releases.

Drift is the main operational risk. If an engineer edits a role or rotates a key in the console while the provider still holds the old state, the next plan will show a difference, and a careless apply can undo a fix made under pressure during an incident. Decide early who may change access in the console, whether that is nobody outside break-glass accounts, and how an emergency change gets back into code within a set time. Run a scheduled plan with no changes expected, so drift surfaces as a finding instead of a surprise. The OpenTofu fork of Terraform, covered in the topic guidance, can be used for the same workflow, but confirm provider compatibility before you switch tools.

Which tooling and state options fit Temporal Cloud Terraform

This table compares the main choices for managing Temporal Cloud resources as code: the Terraform or OpenTofu engine, where state lives, where applies run and how state is split. Read each row for when the option fits and what it costs in review effort and risk. OpenTofu's website describes it as a drop-in replacement for Terraform, but confirm in the Temporal Cloud provider documentation which engines it supports before you commit.

ChoiceWhen it fitsCost in review effort and risk
Terraform engineYour team already runs Terraform and has licensing and support arrangements for itLowest migration effort. Confirm the provider's supported Terraform versions, and track any change in the engine's license terms as part of your review
OpenTofu engineYou want an MPL 2.0 licensed engine, which OpenTofu's website describes as a drop-in replacement for TerraformConfirm provider support for OpenTofu first. Run a plan against a non-production namespace and compare output before switching
Remote state with encryptionSeveral engineers or CI jobs change the same Temporal Cloud resourcesNeeds a backend that supports locking and encryption at rest. OpenTofu offers state encryption with several key providers. Someone must own key rotation and access to the state bucket
Local state fileA single operator is running a short proof of concept or a sandboxState holds account and key identifiers and can be lost with a laptop. Hard to review, hard to lock and unsafe for production
Apply from CIChanges go through pull requests with a reviewed plan and an audit trailRequires pipeline secrets for the Temporal Cloud API key, a protected branch and an approval step. Plan output may need to be reviewed before apply
Apply from an engineer workstationEarly setup, incident work or small teams without a pipelineCredentials sit on laptops, applies are hard to reproduce and drift is more likely to return. Keep it to break-glass use
One state per environmentProduction, staging and development need different owners, approvals or blast radiusMore state files and backends to maintain. Shared modules must be versioned so each environment can upgrade on its own schedule
One shared stateA small platform team manages all namespaces and users with one review pathA mistake in one plan can touch every namespace. Locking delays grow with team size and the plan takes longer to read

How a Temporal Cloud change moves from Git to the account

A change starts as HCL in a branch and is reviewed in a pull request alongside the plan output. After merge, the pipeline runs plan and apply against a remote state backend with encryption, and the Temporal Cloud API applies the change to the account. A scheduled plan then compares the account with the code. Check the trust boundaries: the pipeline secrets store holds the credentials that can change the account, and the state backend holds the record of what Terraform manages.

Change path from pull request to Temporal Cloud account, with trust boundaries marked as subgraphs.

Temporal Cloud Terraform drift from console changes and how to catch it

Terraform only manages what it knows about, so any change made in the Temporal Cloud console can leave the code and the account out of step. The cards below name the out-of-band changes that cause this, the signal that usually reveals each one, and the control that keeps it from building up unnoticed.

Namespace settings edited in the console

A retention period, namespace region or capacity setting changed in the console will not appear in the code, so the next plan may propose to revert it or may show nothing at all if the attribute is not tracked. Check whether the namespace resource in your configuration sets every attribute your team cares about, since unmanaged attributes can drift silently. The signal is a non-empty plan on a scheduled run. The control is to restrict console write access to a small break-glass group and route all namespace changes through a reviewed pull request.

OpenTofu repository

Users added or removed by hand

An engineer invited through the console, or a departing user removed there without a code change, leaves the account and the state disagreeing about who has access. Removed users may still appear in code, and added users may hold roles that no review approved. The signal is a plan that proposes to recreate or delete a user, or an audit log entry for a user action with no matching commit. The control is to manage user membership only in code, and to compare the console user list against state during each scheduled plan.

Service accounts and API keys created outside code

A service account or API key created by hand is a credential that no pipeline owns, cannot be rotated on a schedule, and may outlive the workload it was meant for. Because keys are often shown only once, teams sometimes copy them into a secret store without recording where they came from. The signal is an audit log entry for key creation with no matching resource in state. The control is to create service accounts and keys through code, store generated secrets in a vault, and alert on any key the state does not know about.

Group and role assignments changed directly

Role bindings edited in the console can grant a user or service account more namespace access than the reviewed configuration allows. These changes are easy to miss because they do not change the resource names that a plan usually highlights. The signal is a role assignment in the audit log that has no corresponding change in version control. The control is to define every role binding in code, review changes to bindings as security changes, and check the scheduled plan output for any binding that differs from the configured set.

Provider upgraded without plan review

A new version of the Temporal Cloud provider, or of OpenTofu itself, can change how an attribute is read or defaulted, so a plan may show changes that no one made. Upgrading without reading the plan output can hide these as normal noise. The signal is a plan that changes many resources after a version bump with no edits to the configuration. The control is to pin provider versions in the lock file, upgrade in a separate change, and require a reviewed plan showing no unexpected changes before the upgrade is merged.

State that no longer matches after an import

Importing existing namespaces, users or keys into state is often the first step when adopting Terraform for a live account, and a wrong import or a partial one leaves state that describes a different resource than the account holds. Configuration written from memory of the console can also disagree with the imported values. The signal is a failed apply or a plan that wants to replace an imported resource. The control is to compare each imported resource against the account before the first apply, run a plan with no changes expected, and keep the import in a reviewed change.

What belongs in Terraform code and what stays out of state

Put the objects that are repeatable and reviewable into code, and keep the decisions that carry business or risk ownership with people. In the Temporal Cloud provider, the strongest candidates are namespace definitions and their settings, user and service account definitions, role assignments and the definitions of API keys. Each of these is a configuration that should be identical across environments, versioned, and changed through a pull request. The decisions that should stay with people include who approves creating a production namespace, who may grant the Admin or Owner role, which identity provider groups map to which roles, and when a namespace's retention or capacity settings change. Code can record the outcome of those decisions, but a named approver should own the decision and the review record. Confirm in the provider documentation which namespace and capacity attributes are managed by the provider and which are only settable in the console, because a field the provider does not manage will drift without anyone noticing.

Secrets are the control most often mishandled in this setup. An API key resource produces a secret value when it is created, and that value can be written into the state file, which Terraform and OpenTofu use to track what they manage. Treat state as a credential store: encrypt it, restrict read access to the small group that runs applies, and keep it out of source control and CI logs. Mark outputs that carry key material as sensitive so they are redacted from plan and apply output, and confirm how the provider itself marks and stores these values, because marking an output as sensitive does not by itself keep the value out of the state file. Store the secret in a dedicated secrets manager as soon as it is created, and have workers read it from there rather than from a Terraform output.

OpenTofu documents state and plan file encryption at rest for local storage and remote backends, with key providers that include PBKDF2, AWS KMS, GCP KMS, OpenBao and Azure Vault. This supports the control above, because an encrypted state file is much less useful to someone who copies the bucket or the disk. The choice of key provider is an organizational decision rather than a technical default: it depends on where your cloud keys already live, who holds key administration rights, how keys are rotated, and whether your auditors expect key material to be held in a KMS you already monitor. The PBKDF2 option derives its key from a passphrase, so the passphrase becomes the thing to protect. Ask your security team to choose the provider before the first apply, and document who can decrypt state, because changing it later means migrating existing state.

Setting up Temporal Cloud Terraform management in a pipeline

This sequence moves a Temporal Cloud account from console-managed to code-managed. Each step ends with a check you can rerun, from a pinned OpenTofu release and encrypted state to a clean plan and a scheduled drift check. The result is a pipeline that changes namespaces, users and API keys only through reviewed plans.

  1. Create the pipeline service account and credentials

    A platform engineer creates a dedicated service account in Temporal Cloud for the pipeline, with only the roles needed to manage the namespaces, users and keys in scope. Generate its API key, store it in your CI secret manager, and name the key after the pipeline so audit trails are clear. Confirm current account role names and key lifetime options in the Temporal Cloud documentation before you assign roles. Done means a test read with the new key succeeds from the CI runner, and the same key is denied any action outside its roles.

  2. Pin the provider and engine versions

    The platform team selects an OpenTofu release and records it in the repository, for example v1.13.1, which was released on October 1, 2026. Pin the Temporal Cloud provider to an exact version in the required providers block, and confirm in the OpenTofu registry that the version exists and is maintained. Commit the dependency lock file so every CI run uses the same provider builds. Done means the CI log prints the pinned engine version and the lock file is committed without local edits.

  3. Configure encrypted remote state with locked access

    The platform team configures a remote state backend in storage you control, with access limited to the pipeline role and the engineers who review plans. Enable OpenTofu state encryption so state and plan files are encrypted before they are written, and choose a key provider your security team has approved, such as AWS KMS, GCP KMS, OpenBao or Azure Vault. Confirm the exact configuration keys against the OpenTofu state encryption documentation for your version. Done means initialization succeeds, a state lock is taken and released during a test run, and the stored state file is unreadable without the key.

  4. Write the first namespace and role definitions

    An engineer writes a small first configuration that defines one namespace, the identity group or service account mapped to it, and its role assignments. Keep the Temporal Cloud API key out of the code and pass it through a CI variable or a secret reference. Start with a single namespace so the review stays small and the team learns the resource model before expanding. Done means formatting and validation pass locally and in CI, and the configuration contains no literal credentials.

  5. Run a plan and review it against the live account

    An engineer runs a plan against the live Temporal Cloud account and saves the output as a plan file. The reviewer compares every proposed add, change or destroy with what the account actually contains, paying particular attention to namespace retention and role assignments. Store the saved plan as a pipeline artifact so the approved file is the one applied later. Done means the reviewer signs off on the plan artifact, and any unexpected change has been explained or removed from the configuration.

  6. Import existing namespaces, users and keys

    Resources created earlier in the console are brought under management with import blocks or the import command, one resource at a time. Import each namespace, user and service account reference, then run a plan and correct the configuration until it matches the live values. Where a configuration shares outputs with another through the terraform_remote_state data source, plan the split carefully, since the OpenTofu migration guidance flags that pattern for extra care. Done means the plan reports no changes for the imported resources.

  7. Apply the approved plan from CI

    A pipeline job applies only the saved plan file that a reviewer approved, and it does not run a fresh plan at apply time. Protect the apply job with an approval gate and limit who can trigger it. After the apply, the job writes the apply log and the new state version to the pipeline record. Done means the apply completes, and a follow-up plan in the same pipeline reports no changes.

  8. Schedule a recurring drift check

    The platform team adds a scheduled pipeline job that runs a plan on a fixed cadence with the same pinned version and backend. The job must fail when the plan contains changes, and it should notify the owning team so console edits are found and reverted in code. Confirm how your OpenTofu version reports changes through its exit code before you rely on it. Done means a deliberate test change made in the console causes the scheduled run to fail, and the job passes again after the change is reverted or codified.

How to bring existing Temporal Cloud resources under code

If the account has no namespaces, users or API keys yet, the simplest path is to declare them in code before anyone creates them in the console. Nothing exists that the configuration must adopt, so the first apply creates every object and the state file becomes the record of what was built. The main risk is informal: an administrator makes a quick console change during the first weeks, and the next plan shows a difference nobody can explain.

  • Agree a console freeze: Decide who may change namespaces, users and keys by hand from day one, and write that rule down before the first apply.
  • Set up remote state: Store state in a backend with locking and access control, since it holds the record of every object the configuration manages.
  • Review the first plan: Read the plan line by line with the account owner, because it becomes the baseline for every later change.
  • Keep credentials out of code: Pass API key material through a secrets store and keep variable files free of credentials.

Before applying, confirm in the provider documentation which resources exist, how each one is named, and which attributes cannot be changed after creation.

Securing the pipeline, state and keys around Temporal Cloud Terraform

Terraform manages the Temporal Cloud control plane, so the pipeline that applies it, the state that records it and the credential that authorizes it all become sensitive. The cards below cover the controls that keep those three parts together, and each one points to a check you can run before production changes go live.

Restrict and review production applies

Limit which people and runners can run terraform apply against production Temporal Cloud. Require a reviewed plan before every apply, and make the plan the exact artifact that gets applied, not a fresh plan generated at apply time. Namespace deletion and changes to capacity or authorization settings deserve the closest review, because a plan that looks small can still remove a production namespace. Confirm with your team which plan changes need a second approver.

Protect and rotate the pipeline credential

The pipeline holds a Temporal Cloud API key with rights to change namespaces, users and other keys, so treat it as a high-value secret. Store it in your secrets manager rather than in repository variables that many jobs can read, scope it to the service account the pipeline needs, and set a rotation schedule with an owner. Confirm how your Temporal Cloud account lets you create, rotate and revoke these keys before you design the rotation runbook.

Encrypt state and limit reads

Terraform state records resource details, including names, IDs and some attribute values, so it should be treated as sensitive data. Store remote state in an encrypted backend with access limited to the pipeline and the few engineers who maintain the configuration. OpenTofu can also encrypt state and plan files at rest with a key provider such as AWS KMS or GCP KMS, which you should evaluate against your key management rules. Check who can read the state bucket and its version history.

Retain plans and apply logs

Keep the saved plan file and the apply log for every production change, linked to the commit and the approver. These records answer the question of what was intended and what ran, which the Temporal Cloud audit logs alone do not fully reconstruct. Decide how long your organization keeps them, where they are stored, and who can delete them. Plan artifacts can contain sensitive values, so storage controls should match those of the state itself.

Separate dev and production credentials

Use separate Temporal Cloud accounts or clearly separated namespaces, separate API keys and separate state files for development and production. A pipeline run for a test change should be unable to touch production namespaces even if its configuration contains a mistake. Confirm with Temporal how account boundaries and key scopes apply to your plan before you commit to a layout.

Limit console writes to break-glass accounts

Changes made in the Temporal Cloud console are invisible to Terraform until a plan detects them, and they are a common source of drift. Restrict routine write access in the console to a small set of break-glass accounts that are used only for emergencies, and require that any emergency change is copied back into code afterward. Review who holds console admin rights on a schedule, and reconcile the console state against the plan regularly.

What to confirm before committing to this design

Start by confirming which Temporal Cloud objects the provider manages in your environment. Namespaces, users, service accounts and API keys are the objects this design targets, but coverage varies by provider release, so check the provider documentation for each resource you plan to codify and list anything it cannot manage, such as settings you must keep in the console. Also confirm how the provider handles sensitive values. API key secrets and certificate material can end up in state, so decide where state lives, who can read it, and whether state encryption is configured before any secret passes through a plan. OpenTofu encrypts state and plan files with supported key providers, but you must enable and test that setting yourself.

Next, decide which engine runs the code. OpenTofu's FAQ aims for feature parity with Terraform but states that compatibility with future Terraform releases is not guaranteed, so do not assume a configuration that works on one will work on the other. Confirm the OpenTofu version you will pin, its support status in your own standards, and whether the Temporal Cloud provider you need is published and maintained for that engine. Ask the provider maintainers for their release and deprecation policy, and record how long each major provider version is supported. Pin both the engine and the provider version in lock files, and test upgrades in a non-production Temporal Cloud account before touching production namespaces.

Then plan for operational limits. Large applies that create many users, service accounts or namespaces can hit Temporal Cloud API rate limits, so confirm the documented limits with Temporal and design the apply in batches with retries. Decide in advance how deletions are handled: removing a namespace resource from code can destroy a namespace that holds workflow history, so require prevent_destroy lifecycle guards, separate state for namespaces, and a manual approval step for any plan that deletes one. Finally, confirm that your Temporal Cloud plan includes the identity features the code depends on. SAML SSO is listed on the pricing page for pay-as-you-go plans, but SCIM is a paid feature, so verify your entitlement with Temporal before you build provisioning around it.

Questions teams ask before managing Temporal Cloud with Terraform

What drives the effort of a Temporal Cloud Terraform setup?

The effort is driven by how much of your Temporal Cloud configuration already exists and was created by hand. The main components are an inventory of current namespaces, users, service accounts, API keys and access settings; the pipeline and state design that will own them; the import work that brings existing objects under code without recreating them; and the review process that approves each change. A small account with a few namespaces and a stable team needs much less of each component than an organization with many namespaces, several business units and frequent console changes. Ask any partner to break its quote into these four components and to state which of them is one-time work and which recurs as the account changes.

How long does it take to bring Temporal Cloud under Terraform?

The duration depends on the same drivers as the effort: the size of the existing inventory, how many objects must be imported rather than created, how many teams must agree on ownership, and how well the pipeline platform is already set up. Before work starts, ask for a written schedule that lists the inventory, import, pipeline and review stages separately, and confirm which dependencies sit with your team, such as access approvals or identity provider decisions. No duration is given here because the drivers vary widely between accounts.

What must our team provide before Terraform work begins?

Four inputs are needed before the work can start:

  • Account administrator access in Temporal Cloud, with enough rights to read current objects and to apply changes through an automation identity.
  • Identity provider decisions, including how users and groups map to account and namespace roles, and whether provisioning will come from SAML single sign-on and SCIM or be managed in code.
  • A pipeline platform where plans are reviewed and applies run, with secrets storage for the credentials the provider uses.
  • A named owner for the Terraform state, who approves changes, handles state recovery and decides when access is revoked.
Can an internal platform team manage Temporal Cloud with Terraform on its own?

Often yes, provided the team has working knowledge of Terraform or OpenTofu modules, version control workflows, secrets management and Temporal Cloud's access model. The team also needs someone who understands namespace design and the implications of changing a namespace's roles, retention or regions, because a mistake in code can be applied to production as easily as a correct change. Skills that are commonly missing are import planning for existing resources and a review habit that treats plan output as the record of what will change. Assess these skills honestly against your current staff before deciding whether to build internally, bring in a partner for the first phase, or combine both.

Can OpenTofu replace Terraform for managing Temporal Cloud?

OpenTofu is described on its website as a drop-in replacement for Terraform that preserves existing workflows and configurations, and it is licensed under the Mozilla Public License 2.0. Compatibility is not guaranteed for future Terraform releases, because the OpenTofu FAQ says its aim is feature parity while its community decides which features to adopt. Before switching, back up state and code, install OpenTofu, initialize and verify the configuration, and test with a small change, as the migration overview describes. Confirm that the Temporal Cloud provider you plan to use is supported with the OpenTofu version you choose, and review any use of the terraform_remote_state data source, which the migration guide flags for extra care.

How do we stop console changes from drifting away from Terraform?

Drift is prevented by making code the only path for changes and by checking for differences on a schedule. Restrict console write access to break-glass roles, route all namespace, user, service account and API key changes through reviewed pull requests, and run a scheduled plan that alerts the owner when live objects differ from state. Record who made each change and review audit records for control plane activity. Agree on a documented process for emergency changes, including how they are backported into code, so that exceptions do not become the norm.

How should we protect the Terraform state and credentials?

Treat the state file as sensitive, because it can hold identifiers and configuration for accounts, users and keys. Store state in a remote backend with access limited to the pipeline and the named owner, enable locking so two applies cannot run at once, and keep credentials in a secrets manager rather than in code. OpenTofu can encrypt state and plan files at rest for local storage and remote backends, with key providers such as AWS KMS, GCP KMS and OpenBao, and the state encryption documentation explains the setup. Confirm which key provider your organization approves and who holds recovery access before go-live.

How DeployOpen scopes and delivers Temporal Cloud Terraform management

DeployOpen plans, builds and documents Temporal Cloud management as code for teams that want namespaces, users, service accounts and API keys defined in version-controlled Terraform. The work runs inside the client's own repositories, state storage and review process, with a written scope agreed before any change is made to the account.

How we scope

  • Engagements are fixed-scope, with scope and deliverables agreed in writing before work starts.
  • We inventory existing namespaces, users, service accounts, API keys and console-made changes that the Terraform configuration must reproduce.
  • The written scope names which resources move into code, which stay manual and who approves each change to the account.

How we build

  • We build the provider configuration, module layout and remote state setup in the client's repositories and state backend.
  • We import existing Temporal Cloud resources into state and verify that a plan shows no unexpected changes before anything is applied.
  • We test the configuration with a small planned change and a review workflow, then document how drift is detected and corrected.

How we hand over

  • You receive the Terraform code, module documentation, state layout and a runbook for applying changes and handling credentials.
  • We walk your platform and security teams through the review process, including how console edits are restricted or reconciled.
  • Handover covers the rotation steps for API keys and the process for onboarding and offboarding users in the code.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers, including updates when the provider or Terraform tooling changes.
  • We can review drift reports and pull requests against the agreed module design on a retainer basis.
  • Ask any quote to name the support hours, upgrade scope and who keeps access to the state backend after handover.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.