【发布时间】:2021-08-07 03:08:21
【问题描述】:
我有一个 SSM 文档,用于运行 PowerShell 脚本,然后调用另一个 SSM 文档。我想将第一个 SSM 文档的输出传递到第二个文档。
{
"schemaVersion": "2.2",
"description": "This is to test copying a file from place a to b",
"parameters": {
"InputDir": {
"type": "String",
"description": "This is the input directory from where we are copying",
"default": "C:\\himanshu\\AWS_SSM_WORK"
},
"OutputDir": {
"type": "String",
"description": "This is the output directory where to we are copying",
"default": ""
}
},
"mainSteps": [
{
"action": "aws:runPowerShellScript",
"name": "testCopyFunction",
"inputs": {
"timeoutSeconds": "60",
"runCommand": [
"write-Output {{InputDir }}",
" $utility_path = '{{InputDir}}'",
"$var = @{",
" “name” = “himanshu” ",
" “surname” = “rai” ",
"}",
" if (Test-Path $utility_path) ",
" { Set-Location $utility_path ",
" Start-Process \"cmd.exe\" \" /k C:\\himanshu\\AWS_SSM_WORK\\start.bat \" ",
" $var.Add(\"state\",\"up\") ",
"}",
" else ",
" { Write-Error \"Base location of build is incorrectly set.\" ",
" exit 1",
" }",
"$var | ConvertTo-Json | Out-File \".\\name.json\" "
]
}
},
{
"action": "aws:runDocument",
"name": "egsl_him_second",
"inputs": {
"documentType": "SSMDocument",
"documentPath": "egsl_him_second",
"documentParameters": {
"InputDir": "C:\\himanshu\\AWS_SSM_WORK"
},
"finallyStep": true
}
}
]
}
在第二步中,我正在使用 aws:runDocument 调用另一个 SSM 文档。有什么办法,我可以在第二步中使用我在step1中创建的$var
【问题讨论】:
标签: amazon-web-services aws-ssm