pulumi-modify-existing

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Pulumi: Modify Existing Files

Pulumi:修改现有文件

Always modify, never create

始终修改,切勿创建

Infrastructure changes belong in the existing entrypoint for the stack (typically
__main__.py
). Do not create additional Pulumi files unless the stack already follows a multi-file pattern that makes a new file the right fit.
基础设施变更应在栈的现有入口文件中进行(通常为
__main__.py
)。除非栈已采用多文件模式且新增文件是合适的选择,否则请勿创建额外的Pulumi文件。

Preserve existing functionality

保留现有功能

When editing a Pulumi stack entrypoint, the following must never be silently removed:
  • assumeRole
    / cross-account role configuration
    — removing this breaks production deployments that depend on cross-account access.
  • Existing resource exports (
    pulumi.export(...)
    ).
  • Stack references to other stacks.
Before finalizing changes, scan the diff to confirm nothing was deleted unintentionally.
编辑Pulumi栈入口文件时,以下内容绝对不能被悄悄移除:
  • assumeRole
    / 跨账户角色配置
    ——移除此项会破坏依赖跨账户访问的生产部署。
  • 现有资源导出(
    pulumi.export(...)
    )。
  • 对其他栈的栈引用。
在最终确定变更前,扫描差异以确认没有无意中删除任何内容。

Validate changes before declaring done

完成前验证变更

After modifying any Pulumi code, run a preview to confirm the plan is correct:
bash
pulumi preview --stack <stack-name>
Review the output carefully:
  • Unexpected resource replacements or deletions are bugs, not acceptable side effects.
  • "0 changes" is only correct if you genuinely expected no changes.
修改任何Pulumi代码后,运行预览以确认计划正确:
bash
pulumi preview --stack <stack-name>
仔细检查输出:
  • 意外的资源替换删除属于错误,并非可接受的副作用。
  • 只有当你确实预期没有变更时,“0 changes”才是正确的结果。