Managing infrastructure at scale requires balancing developer velocity with strict security. Pinterest's RPP demonstrates how to implement least privilege and dual controls in a multi-repo Terraform environment, providing a blueprint for secure, compliant cloud automation.
Ammar Ekbote | Senior Software Engineer
Chan Kim | Senior Software Engineer
Managing Infrastructure as Code (IaC) across a massive organization comes with a unique set of security and logistical challenges, particularly when operating within a distributed, multi-repository architecture. At Pinterest, we designed the Resource Provisioner Pipeline (RPP), our specialized, proprietary Terraform execution engine to safely manage both critical and non-critical infrastructure changes.
In this post, we will look under the hood of the first iteration of the RPP system. We will explore how it established compliance and provides robust security guardrails for our global AWS operations by utilizing dual controls, centralized GitHub Actions execution, and a secure role-chaining mechanism. If your engineering team is looking to add strict guardrails to a GitHub workflow-driven Terraform setup, our architecture might serve as a helpful blueprint.
RPP delivers a secure, standardized CI/CD workflow for deploying and managing Pinterest’s foundational AWS infrastructure. Today, the system manages hundreds of Terraform workspaces that collectively govern tens of thousands of resources. This includes:
Pinterest’s Terraform code is currently distributed across multiple repositories, each owned and maintained by a completely different team. While we have an ongoing initiative to consolidate these into a unified mono-repository, RPP acts as a vital bridge that securely supports this legacy multi-repo structure.
To maintain absolute control over infrastructure states, RPP enforces a centralized execution model for all code changes:

Allowing a CI/CD system broad permissions to execute cloud changes is a massive security risk. To uphold the principle of least privilege, RPP implements a strict workspace-path-role mapping process using secure role-chaining as shown below.

Let’s break down the entire workflow step by step.
The system begins by assuming a centralized identity known as the RPPActionsRoleRPPActionsRole. To ensure complete call authenticity, this role can only be assumed from specific, pre-authorized GitHub workflows. This restriction is strictly enforced at the cloud provider layer through GitHub OpenID Connect (OIDC) token validation.

Once running within the context of the RPPActionsRole, the pipeline checks out a central source-of-truth configuration file to look up the exact properties of the workspace being altered. This file maps the workspace to its allowed repository name, directory path, team name, and execution role:
The following block illustrates how a team’s workspace maps to the root module code path. This mapping serves to ensure that only the associated code paths are permitted to execute against that specific workspace.
team-abc = {
email = "teamabc@pinterest.com"
description = "team ABC"
workspaces = [
{
name = "workspace1"
description = "dev configurations"
working_directory = "terraform/config-dev" <--- repository path hosting root module code for workspace1
github_repo = "pinterest/repo1"
},
{
name = "workspace2"
description = "prod configurations"
working_directory = "terraform/config-prod" <--- repository path hosting root module code for workspace2
github_repo = "pinterest/repo1"
}
]
agent_iam_roles = [
"arn:aws:iam::<account-id>:role/RPP-ExecutionRole-TeamABC",
]
}The pipeline includes a critical workspace validation check to ensure that the code path strictly references the explicit S3 state backend blocks and KMS keys mapped to that workspace.
For example, the root module code for workspace1 is located in pinterest/repo1/terraform/config-dev and the backend block is a function of the workspace name. If a developer mistakenly copies code or alters the backend block to point to workspace2 while executing inside workspace1’s directory, the validation logic catches the discrepancy and instantly fails the build.
terraform {
backend "s3" {
bucket = "pinterest-tf-team-abc"
key = "workspace-state/rpp-workspace1/terraform.tfstate"
region = "us-east-1"
kms_key_id = "alias/pinterest-tf-team-abc"
}
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.73.0"
}
random = {
source = "hashicorp/random"
version = ">=3.4.3"
}
}
}The workspace validation logic would, in this scenario, guarantee the integrity of the utilized backend block.
If validation passes, the RPPActionsRole assumes the designated, down-scoped team_iam_role. By linking specific code paths to specific workspaces and roles, we ensure that changes are made in the right environment with the absolute minimal IAM permissions required.
With the localized team_iam_role assumed, the deployment process moves forward with fine-grained precision:
Beyond access management, the PR-driven workflow gives us a powerful platform to introduce advanced reliability and security practices:
By consolidating our deployment logic into centralized composite execution steps, Pinterest achieves significant operational advantages:
By requiring dual controls, isolating execution environments, and using OIDC-driven role chaining, RPP provides a reliable framework for executing enterprise-scale infrastructure updates safely.
This is only the beginning of our IaC evolution. In upcoming blog posts, we share insights into a next-generation RPP engine designed for even more robust deployments. Stay tuned!
Securing Infrastructure at Scale: Introducing Pinterest’s Resource Provisioner Pipeline (RPP) was originally published in Pinterest Engineering Blog on Medium, where people are continuing the conversation by highlighting and responding to this story.
Continue reading on the original blog to support the author
Read full articleManaging schema drift in distributed CDC pipelines is error-prone and causes downtime. Pinterest's framework automates propagation across Flink, Spark, and Iceberg, ensuring data consistency and pipeline reliability while reducing manual intervention through a PR-based, auditable workflow.
This case study demonstrates how high-level ML workloads can cause low-level kernel starvation, leading to network driver resets. It is a critical lesson in debugging performance bottlenecks that span the entire stack from distributed frameworks to cloud infrastructure drivers.
This architecture demonstrates how to scale AI agent capabilities securely in an enterprise environment. By standardizing tool access via MCP and a central registry, Pinterest enables safe, automated engineering workflows while maintaining strict governance and security controls.
Managing resources at scale requires more than just hard limits. Piqama provides a unified framework for capacity and rate-limiting, enabling automated rightsizing and budget alignment. This reduces manual overhead while improving resource efficiency and system reliability across platforms.