Skip to content

Pulumi Secret Stored as Plaintext in State

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about Pulumi Secret Stored as Plaintext in State. We cover key concepts, practical examples, and best practices.

Pulumi secret values are stored in plaintext in the state file despite using the --secret flag.

Wrong ❌

// Wrong: passing sensitive values without the secret flag
import * as pulumi from "@pulumi/pulumi";

const config = new pulumi.Config();
const dbPassword = config.require("dbPassword"); // plaintext config

new aws.rds.Instance("db", {
  password: dbPassword, // stored as plaintext in state
  // ...
});

Wrong Output

Previewing update:
  + aws:rds:Instance "db" {
      + password  : "my-plaintext-password"  # Visible in state!
      ...
    }
// Right: use secret configuration and secret outputs
import * as pulumi from "@pulumi/pulumi";

const config = new pulumi.Config();
const dbPassword = config.requireSecret("dbPassword"); // encrypted config
// Or set via: pulumi config set --secret dbPassword <value>

new aws.rds.Instance("db", {
  password: dbPassword.apply(p => p), // stays encrypted in state
  // ...
});

// Also mark outputs as secret
export const connectionString = pulumi.secret(
  pulumi.interpolate`postgres://user:${dbPassword}@host:5432/db`
);

Right Output

Previewing update:
  + aws:rds:Instance "db" {
      + password  : [secret]  # Encrypted in state
      ...
    }
Outputs:
    connectionString: [secret]

Prevention

  • Use config.requireSecret() instead of config.require() for sensitive configuration values.
  • Set secret values with: pulumi config set --secret .
  • Mark sensitive output values with pulumi.secret() to prevent leaks in the CLI output.
  • Enable automatic secret encryption in the backend by configuring the Pulumi Cloud or self-managed backend with encryption.
  • Audit state files periodically to ensure no plaintext secrets are exposed.

DodaTech applies similar defensive patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro infrastructure for production reliability.

Common Mistakes with secret encrypt

  1. Forgetting deriving (Show, Eq) on custom data types needed for debugging
  2. Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
  3. Using head and tail instead of pattern matching, causing runtime errors on empty lists

These mistakes appear frequently in real-world PULUMI code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

**Q: What is the most common cause of this pulumi error?**

A: Configuration drift between environments and version mismatches between the client and server are the top causes. Always verify both before deeper troubleshooting.

Q: Can this error affect production traffic?

A: Yes. Depending on whether the error occurs in the control plane or data plane, it can block all traffic or cause silent failures. Always test configuration changes in a staging environment first.

Q: How do I monitor for this error in production?

A: Set up log-based alerts for the error signature shown in the Wrong Output section. Prometheus, Grafana, and Datadog all support pattern matching on log entries.

Q: Is there a quick rollback procedure?

A: If you have the previous configuration version, revert and restart. For data-plane errors, replay affected records from the source of truth. Always version control your configuration.


This quick fix is part of the DodaTech infrastructure engineering series. Learn more at DodaTech tutorials.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro