Reputation: 362
I am trying to create an SSM document that deals with parameters but I am getting
Here is my Parameter block :
"createfoo":{
"type": "Boolean",
"description": "Do you want to Create foo",
"default": false
}
Here is my runCommand block :
"mainSteps": [
{
"action": "aws:runPowerShellScript",
"name": "InstallGAIN",
"inputs":{
"runCommand": [
"[bool] $createfoo={{createfoo}}",
"if ($createfoo -eq $true) {",
"Write-Host \"Creating foo\"",
"}"
] } ]
Update-SSMDocument : Parameter "createfoo" is "BOOLEAN" type and can't be used as a substring parameter. At line:2 char:21
- $latestDocVersion = Update-SSMDocument
- CategoryInfo : InvalidOperation: (Amazon.PowerShe...MDocumentCmdlet:UpdateSSMDo
cumentCmdlet) [Update-SSMDocument], InvalidOperationException + FullyQualifiedErrorId : Amazon.SimpleSystemsManagement.Model.InvalidDocumentContentExcep
tion,Amazon.PowerShell.Cmdlets.SSM.UpdateSSMDocumentCmdlet
Following is the command that I run to update my doc
$content = Get-Content -Path "installFoo.ssm" | Out-String
$latestDocVersion = Update-SSMDocument `
-Content $content `
-Name "installFoo" `
-DocumentFormat "JSON" `
-DocumentVersion '$LATEST' `
| Select-Object -ExpandProperty LatestVersion
Update-SSMDocumentDefaultVersion `
-Name "installFoo" `
-DocumentVersion $latestDocVersion
Upvotes: 1
Views: 1297
Reputation: 362
I was able to do this by passing True/False value as string as suggested in comments by mklment0. Here is how paramater block looks like no :
"createfoo":{
"type": "String",
"description": "Do you want to Create foo",
"default": "false"
}
Also the runCommand
block :
"mainSteps": [
{
"action": "aws:runPowerShellScript",
"name": "InstallGAIN",
"inputs":{
"runCommand": [
"if ({{createFoo}} -eq 'true') {",
"Write-Host \"Creating foo\"",
"}"
] } ]
Upvotes: 0