围绕AWS SSM发送命令的包装器,它可以可选地等待执行成功。
aws-ssm-invoke的Python项目详细描述
awssm send命令的包装器,可以选择等待 执行成功。
用法
可以通过执行aws-ssm-invoke-h找到该工具的用法。
$ aws-ssm-invoke -h usage: aws-ssm-invoke [-h] [--comment COMMENT] (--instance-ids [INSTANCE_IDS [INSTANCE_IDS ...]] | --tags [TAGS [TAGS ...]]) [--wait] [--show-output] command positional arguments: command The command to execute on all matching EC2 instances optional xarguments: -h, --help show this help message and exit --comment COMMENT --instance-ids [INSTANCE_IDS [INSTANCE_IDS ...]] Instance ID's to execute on --tags [TAGS [TAGS ...]] Key=Value pairs to execute on --wait When supplied will poll the SSM command until it is complete. --show-output When supplied will show the output from each execution
示例
等待
使用--wait标记轮询命令状态,直到完成和 显示状态
$ aws-ssm-invoke uptime --tags Name=database --wait Executed command'uptime' - 486a3994-db41-4817-b741-f374cffec294 (Pending) - tag:Name =['database'] - Pending (Pending)[0 total, 0 complete, 0 error] - Success (NoInstancesInTag)[0 total, 0 complete, 0 error]
显示输出
要查看的某些命令的输出,请指定 --show-output标志。
$ aws-ssm-invoke uptime --tags Name=database --wait --show-output Executed command'uptime' - 0b8deb73-2677-47a6-9167-a0889929d542 (Pending) - tag:Business:Application =['ecommerce'] - Pending (Pending)[0 total, 0 complete, 0 error] - Success (Success)[1 total, 1 complete, 0 error] Command output - [Success] i-0ddf60260170be3c7 (ip-172-31-9-100.ap-southeast-2.compute.internal)11:01:23 up 2 days, 5:41, 0 users, load average: 0.00, 0.01, 0.05