我试图创建一个PowerShell脚本,其中包括创建AWS CloudFormation堆栈。我在使用aws cloudformation create-stack命令时遇到了麻烦,但它似乎没有提取参数。下面是摘录给我找麻烦:AWS:调用CreateStack操作时发生客户端错误(ValidationError):需要ParameterKey ...的ParameterValue
$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" }
},
我试过以下,其中没有一个似乎帮助:
- 用一个静态值
- 改变从数参数类型替换$版本为String
- 试图通过JSON格式
上任何一个没有骰子,同样的参数列表错误。这就像它只是因为某些原因不接受参数。有任何想法吗?
- 安东尼感谢输入,这让我在正确的方向。该命令工作,但要求我使用-TemplateURL设置为上传到S3位置的模板,如下所示:'New-CFNStack -StackName“cloud-$ version” -TemplateURL“https://s3.amazonaws.com/。 ../my.template“ -Parameters @($ p1)' – Jayoaichen