【发布时间】:2014-03-08 03:01:40
【问题描述】:
我正在尝试创建一个 PowerShell 脚本,其中包括创建 AWS CloudFormation 堆栈。我在使用 aws cloudformation create-stack 命令时遇到问题,但是,它似乎没有获取参数。这是给我带来麻烦的sn-p:
$version = Read-Host 'What version is this?'
aws cloudformation create-stack --stack-name Cloud-$version --template-body C:\awsdeploy\MyCloud.template --parameters ParameterKey=BuildNumber,ParameterValue=$version
我收到的错误是:
aws :
At C:\awsdeploy\Deploy.ps1:11 char:1
+ aws cloudformation create-stack --stack-name Cloud-$version --template-bo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
A client error (ValidationError) occurred when calling the CreateStack operation: ParameterValue for ParameterKey BuildNumber is required
我知道 CloudFormation 脚本没问题,因为我可以通过 AWS 资源管理器毫无问题地执行它。参数部分如下所示:
"Parameters" : {
"BuildNumber" : { "Type" : "Number" }
},
我尝试了以下方法,但似乎都没有帮助:
- 用静态值替换 $version
- 将参数类型从数字更改为字符串
- 试图以 JSON 格式传递参数列表
其中任何一个都没有骰子,同样的错误。就像它出于某种原因不接受参数一样。有什么想法吗?
【问题讨论】:
标签: powershell amazon-web-services aws-powershell