pulumi-esc
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePulumi ESC (Environments, Secrets, and Configuration)
Pulumi ESC(环境、密钥与配置)
Pulumi ESC is a centralized service for managing environments, secrets, and configuration across cloud infrastructure and applications.
Pulumi ESC是一款用于跨云基础设施和应用集中管理环境、密钥与配置的服务。
What is ESC?
什么是ESC?
ESC enables teams to:
- Centralize secrets and configuration in one secure location
- Compose environments by importing and layering configuration
- Generate dynamic credentials via OIDC for AWS, Azure, GCP
- Integrate external secret stores (AWS Secrets Manager, Azure Key Vault, Vault, 1Password)
- Version and audit all configuration changes
- Control access with fine-grained RBAC
ESC支持团队:
- 集中管理密钥与配置,将其存储在一个安全位置
- 组合环境,通过导入和分层配置实现
- 通过OIDC生成动态凭证,支持AWS、Azure、GCP
- 集成外部密钥存储(AWS Secrets Manager、Azure Key Vault、Vault、1Password)
- 版本控制与审计所有配置变更
- 通过细粒度RBAC控制访问权限
Essential CLI Commands
核心CLI命令
bash
undefinedbash
undefinedCreate a new environment
创建新环境
pulumi env init <org>/<project-name>/<environment-name>
pulumi env init <org>/<project-name>/<environment-name>
Edit environment (opens in editor)
编辑环境(在编辑器中打开)
pulumi env edit <org>/<project-name>/<environment-name>
pulumi env edit <org>/<project-name>/<environment-name>
Set values
设置值
pulumi env set <org>/<project-name>/<environment-name> <key> <value>
pulumi env set <org>/<project-name>/<environment-name> <key> <value> --secret
pulumi env set <org>/<project-name>/<environment-name> <key> <value>
pulumi env set <org>/<project-name>/<environment-name> <key> <value> --secret
View definition (secrets hidden)
查看定义(密钥会被隐藏)
pulumi env get <org>/<project-name>/<environment-name>
pulumi env get <org>/<project-name>/<environment-name>
Open and resolve (reveals secrets)
打开并解析(显示密钥)
pulumi env open <org>/<project-name>/<environment-name>
pulumi env open <org>/<project-name>/<environment-name>
Run command with environment
在环境中运行命令
pulumi env run <org>/<project-name>/<environment-name> -- <command>
pulumi env run <org>/<project-name>/<environment-name> -- <command>
Link to Pulumi stack
关联到Pulumi栈
pulumi config env add <project-name>/<environment-name>
undefinedpulumi config env add <project-name>/<environment-name>
undefinedKey Concepts
核心概念
Command Distinctions
命令区别
- : Shows static definition, secrets appear as
pulumi env get[secret] - : Resolves and reveals all values including secrets and dynamic credentials
pulumi env open - : Executes commands with environment variables loaded
pulumi env run - : Only takes the <project-name>/<environment-name> portion
pulumi config env add
- :显示静态定义,密钥会显示为
pulumi env get[secret] - :解析并显示所有值,包括密钥和动态凭证
pulumi env open - :加载环境变量后执行命令
pulumi env run - :仅需传入<project-name>/<environment-name>部分
pulumi config env add
Environment Structure
环境结构
Environments are YAML documents with reserved top-level keys:
- : Import and compose other environments
imports - : Define configuration and secrets
values
Reserved sub-keys under :
values- : Map values to shell environment variables
environmentVariables - : Configure Pulumi stack settings
pulumiConfig - : Generate files with environment data
files
环境是包含保留顶级键的YAML文档:
- :导入并组合其他环境
imports - :定义配置与密钥
values
values- :将值映射为Shell环境变量
environmentVariables - :配置Pulumi栈设置
pulumiConfig - :使用环境数据生成文件
files
Basic Example
基础示例
yaml
imports:
- common/base-config
values:
environment: production
region: us-west-2
dbPassword:
fn::secret: super-secure-password
environmentVariables:
AWS_REGION: ${region}
DB_PASSWORD: ${dbPassword}
pulumiConfig:
aws:region: ${region}
app:dbPassword: ${dbPassword}yaml
imports:
- common/base-config
values:
environment: production
region: us-west-2
dbPassword:
fn::secret: super-secure-password
environmentVariables:
AWS_REGION: ${region}
DB_PASSWORD: ${dbPassword}
pulumiConfig:
aws:region: ${region}
app:dbPassword: ${dbPassword}Working with the User
与用户协作的方式
For Simple Questions
处理简单问题
If the user asks basic questions like "How do I create an environment?" or "What's the difference between get and open?", answer directly using the information above.
如果用户询问基础问题,比如“如何创建环境?”或“get和open命令有什么区别?”,直接使用上述信息作答。
For Detailed Documentation
提供详细文档
When users need more information, use the web-fetch tool to get content from the official Pulumi ESC documentation:
- Complete YAML syntax and functions → https://www.pulumi.com/docs/esc/environments/syntax/
- Provider integrations (AWS, Azure, GCP, Vault, 1Password):
- AWS: https://www.pulumi.com/docs/esc/integrations/dynamic-login-credentials/aws-login/
- Azure: https://www.pulumi.com/docs/esc/integrations/dynamic-login-credentials/azure-login/
- GCP: https://www.pulumi.com/docs/esc/integrations/dynamic-login-credentials/gcp-login/
- Short-term credential (OIDC) providers: https://www.pulumi.com/docs/esc/integrations/dynamic-login-credentials/
- Dynamic secret providers: https://www.pulumi.com/docs/esc/integrations/dynamic-secrets/
- Getting started guide → https://www.pulumi.com/docs/esc/get-started/
- CLI reference → https://www.pulumi.com/docs/esc/cli/commands/
- Prefer using the subcommands over
pulumi envCLI.esc
- Prefer using the
Use the web-fetch tool with specific prompts to extract relevant information from these docs.
当用户需要更多信息时,使用网页抓取工具从Pulumi ESC官方文档获取内容:
- 完整YAML语法与函数 → https://www.pulumi.com/docs/esc/environments/syntax/
- 提供商集成(AWS、Azure、GCP、Vault、1Password):
- AWS: https://www.pulumi.com/docs/esc/integrations/dynamic-login-credentials/aws-login/
- Azure: https://www.pulumi.com/docs/esc/integrations/dynamic-login-credentials/azure-login/
- GCP: https://www.pulumi.com/docs/esc/integrations/dynamic-login-credentials/gcp-login/
- 短期凭证(OIDC)提供商:https://www.pulumi.com/docs/esc/integrations/dynamic-login-credentials/
- 动态密钥提供商:https://www.pulumi.com/docs/esc/integrations/dynamic-secrets/
- 快速入门指南 → https://www.pulumi.com/docs/esc/get-started/
- CLI参考 → https://www.pulumi.com/docs/esc/cli/commands/
- 优先使用子命令而非
pulumi envCLI。esc
- 优先使用
使用网页抓取工具并传入特定提示,从这些文档中提取相关信息。
For Complex Tasks
处理复杂任务
When helping users:
- Understand the goal: Are they setting up new environments, migrating from stack config, or debugging?
- Check existing setup: Use commands to list environments or read definitions
pulumi env - Fetch relevant documentation: Use the web-fetch to get specific examples or syntax from the official docs
- Provide step-by-step guidance: Walk through the process with specific commands
- Validate: Help them test with or
pulumi env geta. Only usepulumi previewwhen the full resolved values are needed, but use cautiously as it reveals secrets.pulumi env open
协助用户时:
- 明确目标:用户是要搭建新环境、从栈配置迁移还是调试问题?
- 检查现有设置:使用命令列出环境或读取定义
pulumi env - 获取相关文档:使用网页抓取工具从官方文档获取特定示例或语法
- 提供分步指导:通过具体命令引导用户完成流程
- 验证:帮助用户使用或
pulumi env get进行测试 a. 仅当需要完整解析值时才使用pulumi preview,但需谨慎操作,因为它会暴露密钥。pulumi env open
Example: Helping with AWS OIDC Setup
示例:协助配置AWS OIDC
text
User: "How do I set up AWS OIDC credentials in ESC?"
1. Use the web-fetch tool to get AWS OIDC documentation from "https://www.pulumi.com/docs/esc/integrations/dynamic-login-credentials/aws-login/"
2. Provide the user with the configuration
3. Ask the user if they have a pre-defined role or need one created for them
4. Set up as much of the environment as possible, then guide them through any steps that you can't do for them
5. Help them test with `pulumi env get` or `pulumi env open` if necessarytext
用户:“如何在ESC中配置AWS OIDC凭证?”
1. 使用网页抓取工具从“https://www.pulumi.com/docs/esc/integrations/dynamic-login-credentials/aws-login/”获取AWS OIDC文档
2. 为用户提供配置内容
3. 询问用户是否已有预定义角色,还是需要创建新角色
4. 尽可能完成环境配置,然后引导用户完成无法代劳的步骤
5. 必要时帮助用户使用`pulumi env get`或`pulumi env open`进行测试Common Workflows
常见工作流
Creating an Environment
创建环境
bash
pulumi env init my-org/my-project/dev-configbash
pulumi env init my-org/my-project/dev-configEdit environment (accepts new definition from a file, better for agents, more difficult for users)
编辑环境(支持从文件加载新定义,适合Agent使用,对用户而言难度较高)
pulumi env edit --file /tmp/example.yml my-org/my-project/dev-config
undefinedpulumi env edit --file /tmp/example.yml my-org/my-project/dev-config
undefinedLinking to Stack
关联到栈
bash
pulumi config env add my-project/dev-config
pulumi config # Verify environment values are accessiblebash
pulumi config env add my-project/dev-config
pulumi config # 验证环境值是否可访问API Access (Rare)
API访问(罕见场景)
Always prefer CLI commands. Only use the API when absolutely necessary (e.g., bulk operations, automation).
Available API endpoints include:
- - List environments
GET /api/esc/environments/{orgName} - - Read environment definition
GET /api/esc/environments/{orgName}/{projectName}/{envName} - - List available providers
GET /api/esc/providers?orgName={orgName}
Use tool to make requests when needed.
call_pulumi_cloud_api()优先使用CLI命令。仅在绝对必要时才使用API(例如批量操作、自动化)。
可用API端点包括:
- - 列出环境
GET /api/esc/environments/{orgName} - - 读取环境定义
GET /api/esc/environments/{orgName}/{projectName}/{envName} - - 列出可用提供商
GET /api/esc/providers?orgName={orgName}
必要时使用工具发起请求。
call_pulumi_cloud_api()Best Practices
最佳实践
- Always use for sensitive values
fn::secret - Prefer OIDC over static keys
- Use descriptive names like not
<org>/my-app/production-aws<org>/app/prod - Layer environments: base → cloud-provider → stack-specific
- Verify that shows expected values after linking an environment to a stack
pulumi config - Prefer using for commands needing environment variables
pulumi env run - Only use when absolutely necessary, as it reveals secrets
pulumi env open
- 敏感值始终使用标记
fn::secret - 优先使用OIDC而非静态密钥
- 使用描述性名称,例如而非
<org>/my-app/production-aws<org>/app/prod - 分层环境:基础层 → 云提供商层 → 栈特定层
- 关联环境到栈后,验证是否显示预期值
pulumi config - 运行需要环境变量的命令时,优先使用
pulumi env run - 仅在绝对必要时使用,因为它会暴露密钥
pulumi env open
Quick Troubleshooting
快速故障排除
- "Environment not found": Check permissions with
pulumi env ls -o <org> - "Secret decryption failed": Use not
pulumi env openpulumi env get - "Stack can't read values": Verify to ensure the stack is listed.
pulumi config env ls- Ensure the environment is referenced only by the project-name/environment-name format.
- Get the specific environment definition with .
pulumi env get <org>/<project-name>/<environment-name> - Verify the key exists and is nested under the
pulumiConfigkey.values
- “环境未找到”:使用检查权限
pulumi env ls -o <org> - “密钥解密失败”:使用而非
pulumi env openpulumi env get - “栈无法读取值”:验证确保栈已列出。
pulumi config env ls- 确保环境仅以project-name/environment-name格式引用。
- 使用获取具体环境定义。
pulumi env get <org>/<project-name>/<environment-name> - 验证键存在且嵌套在
pulumiConfig键下。values