Skip to content

Commit b97072c

Browse files
committed
Initial commit
0 parents  commit b97072c

File tree

20 files changed

+1532
-0
lines changed

20 files changed

+1532
-0
lines changed

.github/workflows/release.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
goreleaser:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v1
14+
- name: Set up Go
15+
uses: actions/setup-go@v1
16+
with:
17+
go-version: 1.15.x
18+
- name: Get version tag
19+
id: get_version
20+
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
21+
- name: Set version
22+
run: sed -i s/VERSION/${{ steps.get_version.outputs.VERSION }}/ main.go
23+
- name: Run GoReleaser
24+
uses: goreleaser/goreleaser-action@v1
25+
with:
26+
version: latest
27+
args: release --rm-dist --skip-validate
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.env
2+
aws-ssm-document

.goreleaser.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
release:
2+
3+
builds:
4+
- id: aws-ssm-document
5+
main: main.go
6+
binary: aws-ssm-document
7+
goos:
8+
- windows
9+
- darwin
10+
- linux
11+
goarch:
12+
- amd64
13+
env:
14+
- CGO_ENABLED=0
15+
16+
archives:
17+
- builds:
18+
- aws-ssm-document
19+
replacements:
20+
darwin: Darwin
21+
linux: Linux
22+
windows: Windows
23+
amd64: x86_64
24+
format: tar.gz
25+
format_overrides:
26+
- goos: windows
27+
format: zip
28+
29+
checksum:
30+
name_template: 'checksums.txt'
31+
32+
changelog:
33+
sort: asc
34+
filters:
35+
exclude:
36+
- '^docs:'
37+
- '^test:'
38+
- '^examples:'
39+
40+
nfpms:
41+
- license: MIT
42+
maintainer: Fabio Gollinucci
43+
description: AWS SSM Document CLI
44+
homepage: https://github.com/daaru00/aws-ssm-document-cli
45+
suggests:
46+
- nodejs
47+
- python
48+
formats:
49+
- rpm
50+
- deb

README.md

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
## About this project
2+
3+
Right now the only methods available to deploy AWS SSM Documents are:
4+
- Using CloudFormation template that can deploy SSM document but cannot set a fixed name otherwise the deploy will fail.
5+
- Using the web console (until the page is reloaded) but a little bit uncomfortable
6+
7+
This is a third method that allows you to version the code, deploy and manage documents.
8+
9+
PS: Also tried [Serverless Components](https://github.com/daaru00/serverless-plugin-ssm-document) but starts having issue with deployments.
10+
11+
## Install CLI
12+
13+
Download last archive package version from [releases page](https://github.com/daaru00/aws-ssm-document-cli/releases):
14+
15+
* Windows: aws-ssm-document_VERSION_Windows_x86_64.zip
16+
* Mac: aws-ssm-document_VERSION_Darwin_x86_64.tar.gz
17+
* Linux: aws-ssm-document_VERSION_Linux_x86_64.tar.gz
18+
19+
Unpack it and copy `aws-ssm-document` into one of your executable paths, for example, for Mac and Linux users:
20+
```bash
21+
tar -czvf aws-ssm-document_*.tar.gz
22+
sudo mv aws-ssm-document /usr/local/bin/aws-ssm-document
23+
rm aws-ssm-document_*.tar.gz
24+
```
25+
26+
### For Linux Users
27+
28+
You can also install CLI from deb or rpm package downloading from releases page:
29+
30+
* aws-ssm-document_1.0.0_linux_amd64.deb
31+
* aws-ssm-document_1.0.0_linux_amd64.rpm
32+
33+
### For Mac Users
34+
35+
Unlock CLI executable file going to "System Preference > Security and Privacy > General" and click on button "open anyway".
36+
37+
## Commands
38+
39+
Usage:
40+
```bash
41+
./aws-ssm-document [global options] command [command options] [path...]
42+
```
43+
44+
- **deploy**: Deploy SSM Documents
45+
- **remove**: Remove SSM Documents
46+
47+
## Environment configuration file
48+
49+
This CLI also load environment variable from `.env` file in current working directory:
50+
```
51+
AWS_PROFILE=my-profile
52+
AWS_REGION=us-east-1
53+
```
54+
55+
Setting `SSM_DOCUMENT_ENV` environment variable is it possible to load different env file:
56+
```bash
57+
export SSM_DOCUMENT_ENV=""
58+
aws-ssm-document deploy # will load .env file
59+
```
60+
```bash
61+
export SSM_DOCUMENT_ENV="prod"
62+
aws-ssm-document deploy # will load .env.prod file
63+
```
64+
```bash
65+
export SSM_DOCUMENT_ENV="STAGE"
66+
aws-ssm-document deploy # will load .env.STAGE file
67+
```
68+
69+
## Document configuration file
70+
71+
This CLI will search for `document.yml` configurations files, recursively, in search path (provided via first argument of any commands) for configurations file and deploy/remove documents in parallels. The document configuration file looks like this:
72+
```yaml
73+
name: MyDocument
74+
description: My document description
75+
accountIds:
76+
- 123456789
77+
file: ./script.sh
78+
parameters:
79+
ParameterName:
80+
type: String
81+
description: "Parameter description"
82+
Command:
83+
type: String
84+
description: "Command to execute"
85+
default: "default-value"
86+
tags:
87+
Project: my-project
88+
Environment: my-env
89+
Type: command
90+
```
91+
92+
### Interpolation
93+
94+
In configuration file it is possible to interpolate environment variables using `${var}` or `$var` syntax:
95+
```yaml
96+
name: MyDocument
97+
file: ./script.sh
98+
tags:
99+
Project: "${APP_NAME}"
100+
Environment: "${ENV}"
101+
```
102+
103+
### Search path
104+
105+
Any command accept file or directory paths as arguments, any document configuration file that match will be loaded an added to list.
106+
107+
If a directory is provided the CLI will search recursively for files `document.yml` (configurable via `--config-config-file`)
108+
and try to parse them using YAML parser (configurable via `--config-config-parser`), for example:
109+
```bash
110+
aws-ssm-document deploy ./documents
111+
```
112+
113+
Search path and config file name can be set via environment variable (or `.env` file):
114+
```
115+
SSM_DOCUMENT_PATH=./documents/
116+
SSM_DOCUMENT_CONFIG_FILE=*.yml
117+
```
118+
119+
If a file is provided the CLI will be try to parse using YAML parser (configurable via `--config-config-parser`), for example:
120+
```bash
121+
aws-ssm-document deploy examples/simple/document.yml
122+
```
123+
124+
Search path can be multiple, every argument respect the rules mentioned above:
125+
```bash
126+
aws-ssm-document deploy examples/simple/document.yml examples/parameters/document.yml examples/script/document.yml
127+
# load 3 documents from provided files
128+
129+
aws-ssm-document deploy examples/ other-examples/script/document.yml
130+
# load all documents in examples directory and a single one from other-examples
131+
132+
aws-ssm-document deploy examples/ other-examples/
133+
# load all documents from examples and other-examples directories (all)
134+
```
135+
136+
Also a file glob pattern can be used as search paths:
137+
```bash
138+
aws-ssm-document deploy examples/**/document.yml
139+
# load 2 documents, one in nodejs directory and the other in the python one
140+
```
141+
142+
Here an example of project configuration with single document:
143+
```bash
144+
.
145+
└── my-command
146+
   ├── document.yml
147+
   └── script.sh
148+
```
149+
150+
Here an example of project configuration with multiple documents:
151+
```bash
152+
.
153+
└── documents
154+
├── command1
155+
│   ├── document.yml
156+
│   └── script.sh
157+
├── command2
158+
│   ├── document.yml
159+
│   └── script.sh
160+
└── command3
161+
├── document.yml
162+
└── script.sh
163+
```
164+
165+
Configuration file name can be changed via `--config-file` parameter:
166+
```bash
167+
aws-ssm-document deploy --config-file="ssm.yml" /commands/
168+
.
169+
└── commands
170+
├── command1
171+
│   ├── ssm.yml
172+
│   └── script.sh
173+
├── command2
174+
│   ├── ssm.yml
175+
│   └── script.sh
176+
└── command3
177+
├── ssm.yml
178+
└── script.sh
179+
```
180+
both exact match and wildcard pattern can be used:
181+
```bash
182+
aws-ssm-document deploy --config-file="*.yml" /commands/
183+
.
184+
└── commands
185+
├── command1.yml
186+
├── command2.yml
187+
├── command3.yml
188+
└── script.sh # export single script
189+
```
190+
191+
## Deploy documents
192+
193+
To deploy documents run the `deploy` command:
194+
```bash
195+
aws-ssm-document deploy
196+
```
197+
198+
## Remove documents
199+
200+
To remove (only) documents run the `remove` command:
201+
```bash
202+
aws-ssm-document remove
203+
```

0 commit comments

Comments
 (0)