首页 > 解决方案 > 如何将 cloudformation 参数设置为 powershell 变量

问题描述

尝试根据 cloudformation 中的用户输入参数在我的 cloudformation 中简单地运行一些 powershell。

这有效

write-host ${CFParameter} >> C:\temp\log.txt

但这并不

$PSVariable = ${CFParameter}

write-host $PSVariable >> C:\temp\log.txt

第二个只返回一个空行,但第一个返回正确的信息

标签: powershellamazon-cloudformation

解决方案


如果您的 powershell 正在用户数据中使用,您可以使用 ref 函数来引用参数。我建议使用cloudkast,它是一个在线 cloudformation 模板生成器。它使生成 cloudformation 模板变得容易。


推荐阅读