AWS EC2 SSM的实用程序
ssmrun的Python项目详细描述
AWS EC2 SSM的实用程序
- 运行命令
- 列出并显示调用
安装
通过PIP安装
$ pip install ssmrun
用法
在Linux节点上快速运行系统命令:
# Target nodes by name $ ssm cmd <target> <system_command> # Target nodes in an auto scaling group $ ssm cmd -A <target> <system_command> # Target nodes created with a CloudFormation stack (including CFN ASGs) $ ssm cmd -S <target> <system_command>
运行ssm命令:
# Run on targets filtered by EC2 tag "Name" $ ssm run <docutment-name> <ec2-instances-name> # Run with SSM parameters $ ssm run <docutment-name> <ec2-instances-name> -P p1="v1" -P p2="v2"# Run and get status for each targeted instance $ ssm run <docutment-name> <ec2-instances-name> -s # Run and get command output for each targeted instance $ ssm run <docutment-name> <ec2-instances-name> -o # Run against instances in an auto scaling group $ ssm run <docutment-name> <asg-name> -k aws:autoscaling:groupName # Run against instances created via CloudFormation stack $ ssm run <docutment-name> <cfn-stack-name> -k aws:cloudformation:stack-name
列出并显示ssm命令调用:
# Show invocation $ ssm show <command-id> # Show invocation and targets status $ ssm show <command-id> -s # Show invocation and targets status and command output $ ssm show <command-id> -o # List command invocations $ ssm ls -n NUM # List command invocations and targets status $ ssm ls -s
列出并显示SSM文档:
# List documents $ ssm docs # List documents with details $ ssm docs -l # Get document content $ ssm get <doc-name>