pulumi-best-practices

Guide Pulumi programs with best practices for resources, components, secrets, and previews.

63|5|Updated Jan 20, 2026
One-click install
npx skills add https://github.com/pulumi/agent-skills --skill pulumi-best-practices
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pulumi-best-practices
Source: https://github.com/pulumi/agent-skills/tree/main/authoring/skills/pulumi-best-practices
Command: npx skills add https://github.com/pulumi/agent-skills --skill pulumi-best-practices

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers avoid common pitfalls and anti-patterns when writing Pulumi infrastructure as code, ensuring more reliable, maintainable, and predictable deployments.

Core Features & Use Cases

  • Resource Management: Guides on correctly creating resources, especially within apply() blocks and managing dependencies.
  • Code Organization: Best practices for using ComponentResources to group related infrastructure.
  • Security: Emphasizes encrypting secrets from the start and using aliases for safe refactoring.
  • Deployment Safety: Stresses the importance of pulumi preview before every deployment.
  • Use Case: When refactoring a Pulumi program, use this skill to ensure resources are not accidentally destroyed and recreated by applying aliases correctly.

Quick Start

Ask your AI assistant to review a Pulumi TypeScript code snippet for best practice violations.

Frequently Asked Questions about pulumi-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely refactor Pulumi infrastructure code without recreating resources?

To safely refactor Pulumi infrastructure code, use aliases to map renamed or restructured resources to their existing states. This prevents accidental destruction and recreation by preserving the original resource identity during code organization changes.

Why should I run pulumi preview before deploying my infrastructure as code?

Running pulumi preview before deploying infrastructure as code allows you to review expected resource changes before execution. This deployment safety step verifies dependency management and prevents unintended modifications, ensuring predictable and reliable cloud infrastructure updates.

What is the best way to organize related cloud infrastructure resources in Pulumi?

The best way to organize related cloud infrastructure resources in Pulumi is by using ComponentResources. This component authoring structure groups related resources together, improving code maintainability, simplifying dependency management, and creating reusable infrastructure modules.

How do I handle secrets management and encryption in Pulumi programs?

To handle secrets management in Pulumi programs, encrypt sensitive values from the very start using the built-in secrets handling features. This ensures that secret outputs are encrypted in transit and at rest, preventing plaintext exposure in your cloud infrastructure state files.

How does Output handling work when creating resources inside apply() blocks in Pulumi?

When creating resources inside apply() blocks in Pulumi, proper Output handling is crucial for managing dependencies. The best practice is to avoid creating resources directly inside apply() to prevent dependency tracking issues, ensuring reliable and predictable cloud infrastructure deployments.