I'm trying to create a PowerShell script that among other things creates an AWS CloudFormation stack. I'm having trouble with the aws cloudformation create-stack command however, it doesn't seem to be picking up the parameters. Here is the snippet giving me trouble:
$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
The error I receive is:
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
I know the CloudFormation script is OK because I can execute it without issues via the AWS explorer. The parameters section looks like this:
"Parameters" : {
"BuildNumber" : { "Type" : "Number" }
},
I've tried the following, none of which seem to help:
- replacing $version with a static value
- changing the parameter type from Number to String
- trying to pass the parameter list in JSON format
No dice on any of these, same error. It's like it's just not accepting the parameters for some reason. Any ideas?