Skip to content

Commit

Permalink
docs: modernize Homebrew/macOS instructions
Browse files Browse the repository at this point in the history
Signed-off-by: Ismayil Mirzali <ismayilmirzeli@gmail.com>
  • Loading branch information
Volatus committed Apr 20, 2023
1 parent 1963cf4 commit 14afe4e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions README.template.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,23 +188,23 @@ The Homebrew formula installs a launchd job which can be used to automatically
rotate your IAM keys daily. Unfortunately, Homebrew forumlae cannot
automatically start launchd jobs, so you must manually enable it:

```
```sh
brew services start aws-rotate-iam-keys
```

A default/global configuration file for the launchd job is installed to:

```
/usr/local/etc/aws-rotate-iam-keys
```sh
$(brew --prefix)/etc/aws-rotate-iam-keys
```

This default configuration rotates keys for your default AWS profile only.
To customise the configuration, for example to rotate multiple keys, create a
copy of this file named `.aws-rotate-iam-keys` in your home directory and edit
it, e.g.

```
cp /usr/local/etc/aws-rotate-iam-keys ~/.aws-rotate-iam-keys
```sh
cp $(brew --prefix)/etc/aws-rotate-iam-keys ~/.aws-rotate-iam-keys
nano ~/.aws-rotate-iam-keys
```

Expand All @@ -221,24 +221,24 @@ multiple lines to the configuration, e.g.
If you do customise the configuration, you can test that it works by restarting
the service:

```
```sh
brew services restart aws-rotate-iam-keys
```

That's it. Your keys should have been rotated, and will now be rotated every
day for you. You can use the AWS CLI to check that your access keys have been
rotated as expected, e.g.

```
```sh
aws iam list-access-keys --profile default
```

If it hasn't worked, check the MacOS system log for error entries matching
`aws-rotate-iam-keys`. If you can't find anything useful, the launchd job also
writes output to a file in the `/tmp` directory matching the job name, e.g.
writes output to a file in the `$(brew --prefix)/var/log` directory matching the job name, e.g.

```
/tmp/homebrew.mxcl.aws-rotate-iam-keys.log
```sh
cat /opt/homebrew/var/log/homebrew.mxcl.aws-rotate-iam-keys.log
```

### Other Linux
Expand Down Expand Up @@ -307,4 +307,4 @@ PowerShell script file: `MD5 ${WIN_MD5}`

## Changes to this file

${TEMPLATE_DISCLAIMER}
${TEMPLATE_DISCLAIMER}
2 changes: 1 addition & 1 deletion aws-rotate-iam-keys.template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def log_path
service do
run ["bash", "-c", "if ! curl -s www.google.com; then sleep 60; fi; cp /dev/null #{f.log_path} ; ( grep -E ^[[:space:]]*- ~/.aws-rotate-iam-keys || cat #{etc}/aws-rotate-iam-keys ) | while read line; do #{opt_bin}/aws-rotate-iam-keys $line; done"]
run_type :cron
run_at_load false
run_at_load true
cron "23 3 * * *"
environment_variables PATH: std_service_path_env
log_path f.log_path
Expand Down

0 comments on commit 14afe4e

Please sign in to comment.