ssm-run-cli 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ssm_run_cli-0.1.0/PKG-INFO +218 -0
- ssm_run_cli-0.1.0/README.md +194 -0
- ssm_run_cli-0.1.0/pyproject.toml +40 -0
- ssm_run_cli-0.1.0/setup.cfg +4 -0
- ssm_run_cli-0.1.0/src/ssm_run_cli/__init__.py +1 -0
- ssm_run_cli-0.1.0/src/ssm_run_cli/cli.py +985 -0
- ssm_run_cli-0.1.0/src/ssm_run_cli.egg-info/PKG-INFO +218 -0
- ssm_run_cli-0.1.0/src/ssm_run_cli.egg-info/SOURCES.txt +10 -0
- ssm_run_cli-0.1.0/src/ssm_run_cli.egg-info/dependency_links.txt +1 -0
- ssm_run_cli-0.1.0/src/ssm_run_cli.egg-info/entry_points.txt +2 -0
- ssm_run_cli-0.1.0/src/ssm_run_cli.egg-info/requires.txt +1 -0
- ssm_run_cli-0.1.0/src/ssm_run_cli.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ssm-run-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Run commands/scripts on EC2 via AWS SSM Run Command
|
|
5
|
+
Project-URL: Homepage, https://wwwin-github.cisco.com/skumble/ssm-cli
|
|
6
|
+
Project-URL: Repository, https://wwwin-github.cisco.com/skumble/ssm-cli
|
|
7
|
+
Project-URL: Issues, https://wwwin-github.cisco.com/skumble/ssm-cli/issues
|
|
8
|
+
Keywords: aws,ssm,ec2,run-command,cli
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: System Administrators
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: License :: Other/Proprietary License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: System :: Systems Administration
|
|
20
|
+
Classifier: Topic :: Utilities
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
Requires-Dist: boto3>=1.28
|
|
24
|
+
|
|
25
|
+
# ssm-run
|
|
26
|
+
|
|
27
|
+
Run shell commands or scripts on EC2 instances via AWS Systems Manager (SSM) Run Command.
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
- Resolve targets by:
|
|
32
|
+
- EC2 instance ID (`i-...`)
|
|
33
|
+
- Name tag / hostname / FQDN
|
|
34
|
+
- Private/Public IPv4
|
|
35
|
+
- Target expansion:
|
|
36
|
+
- `myserver{600..605}`
|
|
37
|
+
- Run:
|
|
38
|
+
- Inline command (`-- "uptime"`)
|
|
39
|
+
- Local script file (`--file ./cmd.sh`)
|
|
40
|
+
- SSM online filtering (with opt-out)
|
|
41
|
+
- Parallel result collection for faster output fetch
|
|
42
|
+
- Optional S3-backed full output (`--s3-bucket`) to avoid API truncation
|
|
43
|
+
- Debug mode to inspect exact remote command (`--debug-command`)
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
### From PyPI
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install ssm-run
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Upgrade
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install --upgrade ssm-run
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### From source (repo)
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
git clone https://wwwin-github.cisco.com/skumble/ssm-cli.git
|
|
63
|
+
cd ssm-cli
|
|
64
|
+
pip install .
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Requirements
|
|
68
|
+
|
|
69
|
+
- Python 3.9+
|
|
70
|
+
- AWS credentials configured (profile/role/SSO)
|
|
71
|
+
- IAM permissions for:
|
|
72
|
+
- `ec2:DescribeInstances`
|
|
73
|
+
- `ssm:DescribeInstanceInformation`
|
|
74
|
+
- `ssm:SendCommand`
|
|
75
|
+
- `ssm:ListCommandInvocations`
|
|
76
|
+
- `ssm:GetCommandInvocation`
|
|
77
|
+
- If using `--s3-bucket`:
|
|
78
|
+
- instance role needs `s3:PutObject`
|
|
79
|
+
- caller credentials need `s3:GetObject`
|
|
80
|
+
|
|
81
|
+
## CLI Usage
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
ssm-run [OPTIONS] <target> [<target> ...] -- "<command>"
|
|
85
|
+
ssm-run [OPTIONS] <target> [<target> ...] --file ./script.sh
|
|
86
|
+
ssm-run [OPTIONS] -f hosts.txt -- "<command>"
|
|
87
|
+
ssm-run [OPTIONS] -f hosts.txt --file ./script.sh
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Options
|
|
91
|
+
|
|
92
|
+
- `-r, --region <region>` AWS region (supports shortcuts: `use1`, `euw1`, `aps1`)
|
|
93
|
+
- `-f, --hosts-file <file>` Read targets from file (one per line, `#` comments allowed)
|
|
94
|
+
- `--file <script.sh>` Run local script file instead of inline command
|
|
95
|
+
- `--batch-size <1..50>` Instances per `SendCommand` call
|
|
96
|
+
- `--timeout-seconds <sec>` Global wait timeout
|
|
97
|
+
- `--poll-interval <sec>` Poll interval
|
|
98
|
+
- `--no-online-filter` Skip SSM online filtering
|
|
99
|
+
- `--only-failed` Print output only for failed instances
|
|
100
|
+
- `--s3-bucket <bucket>` Store/fetch full output from S3
|
|
101
|
+
- `--s3-prefix <prefix>` Optional S3 key prefix
|
|
102
|
+
- `--debug-command` Print decoded command and exit
|
|
103
|
+
- `--max-workers <n>` Parallel workers for output fetching
|
|
104
|
+
- `-h, --help` Help
|
|
105
|
+
|
|
106
|
+
## Examples
|
|
107
|
+
|
|
108
|
+
### 1. Simple inline command
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
ssm-run --region euw1 myserver{600..605} -- 'uptime'
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### 2. From hosts file
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
ssm-run -r use1 -f hosts.txt -- 'df -h'
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### 3. Complex command using script file (recommended)
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
echo 'sudo grep -m1 "HUMIDITY" /mnt/logs/webex-api-streams.log' > cmd.sh
|
|
124
|
+
ssm-run --region euw1 myserver{600..605} --file cmd.sh
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 4. Long-running command with higher timeout
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
ssm-run --region euw1 --timeout-seconds 300 myserver{600..605} --file cmd.sh
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 5. Avoid output truncation using S3
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
ssm-run --region euw1 --s3-bucket my-ssm-logs myserver{600..605} --file cmd.sh
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### 6. Validate what would run (no execution)
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
ssm-run --region euw1 --debug-command myserver601 -- 'uptime'
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Notes on Quoting
|
|
146
|
+
|
|
147
|
+
For commands with JSON, nested quotes, pipes, or shell special characters, prefer `--file` instead of inline `-- "<command>"`.
|
|
148
|
+
This avoids local shell quoting issues before the command reaches the instance.
|
|
149
|
+
|
|
150
|
+
## Exit Behavior
|
|
151
|
+
|
|
152
|
+
- Returns non-zero on major failures (for example: AWS API errors, no valid targets).
|
|
153
|
+
- Prints per-instance status and summary with success/failed/skipped/timeout counts.
|
|
154
|
+
|
|
155
|
+
## Development
|
|
156
|
+
|
|
157
|
+
Build wheel/sdist:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
python -m pip install --upgrade build
|
|
161
|
+
python -m build
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Install local build:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
python -m pip install --force-reinstall dist/*.whl
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Publishing (maintainers)
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
python -m pip install --upgrade twine
|
|
174
|
+
python -m twine check dist/*
|
|
175
|
+
python -m twine upload dist/*
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Versioning and Release Notes
|
|
179
|
+
|
|
180
|
+
- Versioning follows Semantic Versioning (`MAJOR.MINOR.PATCH`).
|
|
181
|
+
- Update version in `pyproject.toml` before each release.
|
|
182
|
+
- Add release notes in `CHANGELOG.md`.
|
|
183
|
+
|
|
184
|
+
### First Public Release Checklist
|
|
185
|
+
|
|
186
|
+
1. Confirm package name availability on PyPI (`ssm-run`).
|
|
187
|
+
2. Verify metadata in `pyproject.toml` (name/version/urls/classifiers).
|
|
188
|
+
3. Build artifacts:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
python -m pip install --upgrade build
|
|
192
|
+
python -m build
|
|
193
|
+
python -m twine check dist/*
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
4. Test local install from built wheel:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
python -m pip install --force-reinstall dist/*.whl
|
|
200
|
+
ssm-run --help
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
5. Publish:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
python -m twine upload dist/*
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
6. Tag release in git (example):
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
git tag -a v0.1.0 -m "Release v0.1.0"
|
|
213
|
+
git push origin v0.1.0
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## License
|
|
217
|
+
|
|
218
|
+
Add your project license here (for example: MIT, Apache-2.0, or internal Cisco license).
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# ssm-run
|
|
2
|
+
|
|
3
|
+
Run shell commands or scripts on EC2 instances via AWS Systems Manager (SSM) Run Command.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Resolve targets by:
|
|
8
|
+
- EC2 instance ID (`i-...`)
|
|
9
|
+
- Name tag / hostname / FQDN
|
|
10
|
+
- Private/Public IPv4
|
|
11
|
+
- Target expansion:
|
|
12
|
+
- `myserver{600..605}`
|
|
13
|
+
- Run:
|
|
14
|
+
- Inline command (`-- "uptime"`)
|
|
15
|
+
- Local script file (`--file ./cmd.sh`)
|
|
16
|
+
- SSM online filtering (with opt-out)
|
|
17
|
+
- Parallel result collection for faster output fetch
|
|
18
|
+
- Optional S3-backed full output (`--s3-bucket`) to avoid API truncation
|
|
19
|
+
- Debug mode to inspect exact remote command (`--debug-command`)
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
### From PyPI
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install ssm-run
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Upgrade
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install --upgrade ssm-run
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### From source (repo)
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
git clone https://wwwin-github.cisco.com/skumble/ssm-cli.git
|
|
39
|
+
cd ssm-cli
|
|
40
|
+
pip install .
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Requirements
|
|
44
|
+
|
|
45
|
+
- Python 3.9+
|
|
46
|
+
- AWS credentials configured (profile/role/SSO)
|
|
47
|
+
- IAM permissions for:
|
|
48
|
+
- `ec2:DescribeInstances`
|
|
49
|
+
- `ssm:DescribeInstanceInformation`
|
|
50
|
+
- `ssm:SendCommand`
|
|
51
|
+
- `ssm:ListCommandInvocations`
|
|
52
|
+
- `ssm:GetCommandInvocation`
|
|
53
|
+
- If using `--s3-bucket`:
|
|
54
|
+
- instance role needs `s3:PutObject`
|
|
55
|
+
- caller credentials need `s3:GetObject`
|
|
56
|
+
|
|
57
|
+
## CLI Usage
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
ssm-run [OPTIONS] <target> [<target> ...] -- "<command>"
|
|
61
|
+
ssm-run [OPTIONS] <target> [<target> ...] --file ./script.sh
|
|
62
|
+
ssm-run [OPTIONS] -f hosts.txt -- "<command>"
|
|
63
|
+
ssm-run [OPTIONS] -f hosts.txt --file ./script.sh
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Options
|
|
67
|
+
|
|
68
|
+
- `-r, --region <region>` AWS region (supports shortcuts: `use1`, `euw1`, `aps1`)
|
|
69
|
+
- `-f, --hosts-file <file>` Read targets from file (one per line, `#` comments allowed)
|
|
70
|
+
- `--file <script.sh>` Run local script file instead of inline command
|
|
71
|
+
- `--batch-size <1..50>` Instances per `SendCommand` call
|
|
72
|
+
- `--timeout-seconds <sec>` Global wait timeout
|
|
73
|
+
- `--poll-interval <sec>` Poll interval
|
|
74
|
+
- `--no-online-filter` Skip SSM online filtering
|
|
75
|
+
- `--only-failed` Print output only for failed instances
|
|
76
|
+
- `--s3-bucket <bucket>` Store/fetch full output from S3
|
|
77
|
+
- `--s3-prefix <prefix>` Optional S3 key prefix
|
|
78
|
+
- `--debug-command` Print decoded command and exit
|
|
79
|
+
- `--max-workers <n>` Parallel workers for output fetching
|
|
80
|
+
- `-h, --help` Help
|
|
81
|
+
|
|
82
|
+
## Examples
|
|
83
|
+
|
|
84
|
+
### 1. Simple inline command
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
ssm-run --region euw1 myserver{600..605} -- 'uptime'
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 2. From hosts file
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
ssm-run -r use1 -f hosts.txt -- 'df -h'
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 3. Complex command using script file (recommended)
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
echo 'sudo grep -m1 "HUMIDITY" /mnt/logs/webex-api-streams.log' > cmd.sh
|
|
100
|
+
ssm-run --region euw1 myserver{600..605} --file cmd.sh
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 4. Long-running command with higher timeout
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
ssm-run --region euw1 --timeout-seconds 300 myserver{600..605} --file cmd.sh
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 5. Avoid output truncation using S3
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
ssm-run --region euw1 --s3-bucket my-ssm-logs myserver{600..605} --file cmd.sh
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### 6. Validate what would run (no execution)
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
ssm-run --region euw1 --debug-command myserver601 -- 'uptime'
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Notes on Quoting
|
|
122
|
+
|
|
123
|
+
For commands with JSON, nested quotes, pipes, or shell special characters, prefer `--file` instead of inline `-- "<command>"`.
|
|
124
|
+
This avoids local shell quoting issues before the command reaches the instance.
|
|
125
|
+
|
|
126
|
+
## Exit Behavior
|
|
127
|
+
|
|
128
|
+
- Returns non-zero on major failures (for example: AWS API errors, no valid targets).
|
|
129
|
+
- Prints per-instance status and summary with success/failed/skipped/timeout counts.
|
|
130
|
+
|
|
131
|
+
## Development
|
|
132
|
+
|
|
133
|
+
Build wheel/sdist:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
python -m pip install --upgrade build
|
|
137
|
+
python -m build
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Install local build:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
python -m pip install --force-reinstall dist/*.whl
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Publishing (maintainers)
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
python -m pip install --upgrade twine
|
|
150
|
+
python -m twine check dist/*
|
|
151
|
+
python -m twine upload dist/*
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Versioning and Release Notes
|
|
155
|
+
|
|
156
|
+
- Versioning follows Semantic Versioning (`MAJOR.MINOR.PATCH`).
|
|
157
|
+
- Update version in `pyproject.toml` before each release.
|
|
158
|
+
- Add release notes in `CHANGELOG.md`.
|
|
159
|
+
|
|
160
|
+
### First Public Release Checklist
|
|
161
|
+
|
|
162
|
+
1. Confirm package name availability on PyPI (`ssm-run`).
|
|
163
|
+
2. Verify metadata in `pyproject.toml` (name/version/urls/classifiers).
|
|
164
|
+
3. Build artifacts:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
python -m pip install --upgrade build
|
|
168
|
+
python -m build
|
|
169
|
+
python -m twine check dist/*
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
4. Test local install from built wheel:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
python -m pip install --force-reinstall dist/*.whl
|
|
176
|
+
ssm-run --help
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
5. Publish:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
python -m twine upload dist/*
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
6. Tag release in git (example):
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
git tag -a v0.1.0 -m "Release v0.1.0"
|
|
189
|
+
git push origin v0.1.0
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## License
|
|
193
|
+
|
|
194
|
+
Add your project license here (for example: MIT, Apache-2.0, or internal Cisco license).
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=69", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ssm-run-cli"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Run commands/scripts on EC2 via AWS SSM Run Command"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
dependencies = ["boto3>=1.28"]
|
|
12
|
+
keywords = ["aws", "ssm", "ec2", "run-command", "cli"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 4 - Beta",
|
|
15
|
+
"Intended Audience :: System Administrators",
|
|
16
|
+
"Environment :: Console",
|
|
17
|
+
"License :: Other/Proprietary License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
20
|
+
"Programming Language :: Python :: 3.9",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Topic :: System :: Systems Administration",
|
|
25
|
+
"Topic :: Utilities",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Homepage = "https://wwwin-github.cisco.com/skumble/ssm-cli"
|
|
30
|
+
Repository = "https://wwwin-github.cisco.com/skumble/ssm-cli"
|
|
31
|
+
Issues = "https://wwwin-github.cisco.com/skumble/ssm-cli/issues"
|
|
32
|
+
|
|
33
|
+
[project.scripts]
|
|
34
|
+
ssm-run = "ssm_run_cli.cli:main"
|
|
35
|
+
|
|
36
|
+
[tool.setuptools]
|
|
37
|
+
package-dir = {"" = "src"}
|
|
38
|
+
|
|
39
|
+
[tool.setuptools.packages.find]
|
|
40
|
+
where = ["src"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|