![](/img/trans.png)
[英]AWS SSM RunCommand - Issue with RunRemoteScript Document to run PowerShell script with parameters
[英]SSM runCommand document with conditional branching
我正在創建一個 aws ssm 文檔,在第一步中,我正在嘗試運行 shell 腳本。
- name: checkMembership
action: 'aws:runCommand'
inputs:
DocumentName: AWS-RunShellScript
InstanceIds:
- '{{InstanceIds}}'
Parameters:
commands:
- mkdir testFolder
我的問題是,如果在此處使用 powershell 腳本或 shell 腳本,我是否可以執行多行操作?
- name: checkMembership
action: 'aws:runCommand'
inputs:
DocumentName: AWS-RunShellScript
InstanceIds:
- '{{InstanceIds}}'
Parameters:
commands:
- if $foo
- then
- echo 'hello'
- else
- echo 'bye'
是的,您可以在命令中使用條件分支。
這是一個例子:
"runCommand": [
"#!/bin/bash",
"example_var=true",
" if [ \"$example_var\" = true ] ;",
" then",
" echo \"example_var is true\"",
" else",
" echo \"example_var is not true\"",
" fi"
]
我建議您查看 AWS 托管文檔。 那里有一些非常好的例子,你可以參考。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.