【问题标题】:How do I specify a plan file when doing terraform plan output to show the contents of a plan file?在进行 terraform plan 输出以显示计划文件的内容时,如何指定计划文件?
【发布时间】:2022-01-18 23:49:26
【问题描述】:

我的计划文件以特定名称保存。我试过了 terraform plan planfilename.plan -out=tfplan 并显示包含计划文件名的其他变体

【问题讨论】:

    标签: terraform


    【解决方案1】:
    terraform plan -out=tfplan
    

    标志“-out”用于指定输出文件名。所以在这种情况下,您的输出文件是“tfplan”。如果您想指定多个输出文件,无论出于何种原因,您都可以做一些奇怪的事情,例如:

    terraform plan -out=tfplan; cat tfplan > planefilename.plan
    

    【讨论】:

    • 我建议将 ; 更改为 &&,否则,如果 terraform 由于某种原因被破坏,该命令将创建一个空文件。
    【解决方案2】:

    要将计划保存到您可以使用的位置:

    terraform plan --out=<filename>
    

    要检查此计划,您可以使用show 命令:

    terraform show <filename>
    

    要应用此计划,您可以执行以下操作:

    terraform apply <filename>
    

    【讨论】:

    • 这里最好也提一下文件原因show是必要的,因为文件是二进制编码的,因此需要解码成有用的输出。
    猜你喜欢
    • 2019-10-13
    • 1970-01-01
    • 2020-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-22
    相关资源
    最近更新 更多