我正在尝试在 bash 中运行命令,其中部分命令被我在上一步中创建的变量替换,但是字符串替换不起作用。我已经用单引号、双引号等尝试了很多变体,但不能让它工作。
mainSteps:
- name: getIps
action: 'aws:invokeLambdaFunction'
timeoutSeconds: 1200
maxAttempts: 1
onFailure: Abort
inputs:
FunctionName: Automation-GetIPs
Payload: '{"asg": "Staging_web_ASG"}'
outputs:
- Name: asg_ips
Selector: $.Payload.IPs
Type: StringList
- name: updatelsync
action: 'aws:runCommand'
timeoutSeconds: 1200
inputs:
DocumentName: AWS-RunShellScript
InstanceIds:
- '{{ InstanceID }}'
Parameters:
commands:
- 'echo {{getIps.asg_ips}} > /root/asg_ips.test'
在上面的代码中。我在 step1 中设置了 asg_ips,其 OutputPayload 如下:
{"Payload":{"IPs": ["172.xx.x.xxx", "172.xx.x.xxx"]},"StatusCode":200}
但是对于第二步中的输入,它显示如下...
{"commands":["echo {{getIps.asg_ips}} > /root/asg_ips.test"]}
我需要让它显示这样的东西......
{"commands":["echo ["172.xx.x.xxx", "172.xx.x.xxx"] > /root/asg_ips.test"]}