The Simplest Way to Make AWS Secrets Manager and Pulumi Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use aws secrets manager and pulumi to provision cloud resources with encrypted credentials. Pulumi reads or creates secrets in AWS during deployments and passes references to apps. This workflow keeps plain text passwords out of your code repo. Your deployment tool sets up the secret vault and links it to your compute workloads. Then your running apps fetch the values they need from AWS at boot time. How aws secrets manager and pulumi share data and roles The link between aws secrets m

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 aws secrets manager and pulumi to provision cloud resources with encrypted credentials. Pulumi reads or creates secrets in AWS during deployments and passes references to apps.

This workflow keeps plain text passwords out of your code repo. Your deployment tool sets up the secret vault and links it to your compute workloads. Then your running apps fetch the values they need from AWS at boot time.

How aws secrets manager and pulumi share data and roles

The link between aws secrets manager and pulumi starts with cloud identity roles. When you start a deployment run, Pulumi uses an AWS role to make API calls. This role needs permission to create, read, update, or delete secret items in AWS.

Data flows in one of two ways during a stack update. First, your stack code can generate a new random password and write it to AWS. Second, your stack can read an existing secret value from AWS to configure a service.

In both cases, Pulumi tracks resource attributes inside its own state backend. If you fetch a secret value during a run, that value enters the deployment memory. You must mark that output as a secret so the state backend encrypts it.

A safer pattern avoids reading the raw secret string during the deployment run. Instead, pass the AWS secret ARN to your compute task or serverless function. The app then reads the secret straight from AWS when it starts up.

Common failure modes and how to scope permissions

Many teams hit security snags when they wire these two tools together. The biggest mistake is using a shared admin role for all deployment runs. If a shared deployment token leaks, an attacker can read every secret in your cloud.

Another common failure happens inside the deployment state file. If an engineer forgets to mark a fetched value as secret, it saves in plain text. Anyone with read access to the stack state can then view the raw database password.

AWS Secrets Manager + Pulumi Policy as Code: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Unlogged reads also create blind spots for security teams during an audit. When five stacks share one service account, cloud logs cannot show who read a secret. You only see the shared bot name in your AWS CloudTrail event history.

You can fix these issues by scoping IAM roles to each specific stack and stage. Give the dev stack role access only to secrets with a dev path prefix. Do the same for production roles so dev runs never touch prod secrets.

Next, stop passing raw secret values through your stack state whenever you can. Let your deployment tool create the empty secret container and IAM policies in AWS. Have a separate rotation job or admin process populate the sensitive payload later.

How to manage secret rotation and state drift

Secret rotation often breaks deployment runs when teams store raw values in stack state. AWS can rotate database passwords on a set schedule using built-in serverless functions. When AWS changes the password, the deployment state still holds the old value.

On the next deployment run, the tool sees a difference between state and cloud. It might overwrite the new rotated password with the old one from its state file. This action breaks database logins for your live apps right away.

To prevent drift, tell your stack code to ignore changes to the secret string value. Your code should manage the secret container, kms key link, and rotation rules only. Leave the actual secret payload outside the deployment tool lifecycle so rotation works well.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Does Pulumi store AWS secrets in its state file?

Yes, if your code reads a secret value or writes a string into the secret resource. Always mark secret outputs to encrypt them, or pass only the ARN to avoid storing values.

How do we stop deployment runs from overwriting rotated secrets?

Set your resource options to ignore changes on the secret value field after initial creation. Better yet, create the secret container in code and let AWS rotation functions manage the value.

Should developers use personal AWS keys to run stack updates?

No, personal keys often hold broad permissions and stay active for way too long. Use short-lived roles tied to your identity provider or CI runner for every stack update.

The query runs. The emails stay hidden.