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

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use pulumi and teamcity together to automate cloud updates from code commits. TeamCity runs build steps that trigger Pulumi to create or update cloud resources. This setup turns manual cloud changes into a clean, repeatable workflow. Your team pushes code, and the build server checks and applies the changes. You get fast updates and a clear history of every single run. How pulumi and teamcity share keys and data TeamCity uses build agents to run your jobs and scripts. Each agent needs

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 teamcity together to automate cloud updates from code commits. TeamCity runs build steps that trigger Pulumi to create or update cloud resources.

This setup turns manual cloud changes into a clean, repeatable workflow. Your team pushes code, and the build server checks and applies the changes. You get fast updates and a clear history of every single run.

How pulumi and teamcity share keys and data

TeamCity uses build agents to run your jobs and scripts. Each agent needs two sets of keys to do its job well. First, the agent needs a token to log in to the Pulumi state backend. Second, it needs cloud provider keys to change servers, databases, and networks.

When a developer pushes code, TeamCity detects the change and starts a build. The build agent pulls the latest code from your version control system. Next, the agent logs in to the state backend to read the current state. Pulumi compares your new code against the live state of your cloud resources.

During a pull request, TeamCity runs a preview step to show planned changes. It sends this summary back to the build log for your team to review. After someone approves and merges the code, TeamCity triggers the update step. The build agent then writes the new changes to your cloud account and updates the state file.

Common failure modes and how to scope permissions

Many teams start by putting one big admin key into the TeamCity project settings. Every build agent and every subproject then shares that same broad key. This habit creates a big risk for your production cloud accounts. If one test build gets compromised, the attacker gets full control over everything.

Long-lived static tokens also cause trouble when people leave the team or roles change. Nobody wants to rotate a shared key because it might break ten different pipelines. Over time, teams lose track of which build job actually made a specific cloud change. Cloud audit logs only show the name of the single shared service account.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

To fix this, give each TeamCity project its own scoped role and separate state access. Create one read-only role for pull request previews that cannot change live resources. Create a second write role that only runs on the main branch after approval. Use short-lived federated tokens instead of saving static keys inside TeamCity parameters.

You should also lock down the network paths between your build agents and your cloud. Place your build agents in a private network segment with strict firewall rules. Allow agents to reach only the specific cloud APIs they need for their assigned stack. Keep production agents separate from test agents so test jobs never touch live data.

Keeping state files and build logs clean

Pulumi stores details about your cloud resources inside a central state file. Sometimes, outputs from your cloud resources contain sensitive strings like database passwords or keys. If you do not mark those outputs as secret, they show up in plain text. Anyone who can read the TeamCity build log can then see those raw values.

Always mark sensitive outputs as secrets in your code before you run a build. Pulumi will encrypt those values inside the state file and hide them in logs. Also, limit who can view build logs and artifacts inside your TeamCity server settings. Good log hygiene keeps your cloud keys safe while giving developers the feedback they need.

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

How should TeamCity handle Pulumi preview steps on pull requests?

Set up a separate TeamCity build template just for pull request branches. Give this job a read-only cloud role so it can check state without making live changes.

Where should we store the Pulumi state encryption key in TeamCity?

Use your cloud provider key management service instead of storing a plain passphrase in TeamCity. Grant the build agent role permission to use that cloud key during the run.

Why do two TeamCity builds fail when they run on the same stack at once?

Pulumi locks the state file during an update to prevent conflicts and corrupt data. Set a build queue limit in TeamCity so only one job runs per stack at a time.

The query runs. The emails stay hidden.