You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -107,11 +109,13 @@ The behavior can be configured by environment variables.
107
109
|------|------------ |
108
110
| ENABLE_AUTO_EXPIRE | Must be set to `true` for key disable action |
109
111
| EXPIRATION_AGE | Age of key creation (in days) to disable a AWS key |
112
+
| EXPIRE_NOTIFICATION_TITLE | Title of the notification message for keys expiring due to creation age|
113
+
| EXPIRE_NOTIFICATION_TEXT | Instructions on key rotation |
110
114
| WARNING_AGE | Age of key creation (in days) to send notifications, must be lower than EXPIRATION_AGE |
111
115
| INACTIVITY_AGE | OPTIONAL, defaults to EXPIRATION_AGE, Age of last key usage (in days) to disable AWS key, must be lower than or equal to EXPIRATION_AGE |
112
116
| INACTIVITY_WARNING_AGE | REQUIRED IF INACTIVITY_AGE is set, otherwise defaults to WARNING, Age of last key usage (in days) to send notifications, must be lower than INACTIVITY_AGE |
113
-
|MSG_TITLE| Title of the notification message |
114
-
|MSG_TEXT| Instructions on key rotation|
117
+
|INACTIVE_NOTIFICATION_TITLE| Title of the notification message for keys expiring due to inactivity|
118
+
|INACTIVE_NOTIFICATION_TEXT| Instructions on key usage to prevent expiration due to inactivity|
115
119
| SLACK_URL | Incoming webhook to send notifications to |
116
120
| SNS_TOPIC | Topic to send a SNS formatted message to |
cd /path/to/trussworks/terraform-aws-iam-sleuth/sleuth
186
+
```
187
+
188
+
1. Export the relevant variables:
189
+
190
+
To test the warnings for creation date expiration, considering a key that was made today, use:
191
+
192
+
```shell
193
+
export DEBUG=true
194
+
export SLACK_URL=test
195
+
export EXPIRATION_AGE=90
196
+
export WARNING_AGE=0
197
+
```
198
+
199
+
To test the warnings for inactivity expiration, considering a key that was made today, use:
200
+
201
+
```shell
202
+
export DEBUG=true
203
+
export SLACK_URL=test
204
+
export EXPIRATION_AGE=90
205
+
export WARNING_AGE=1
206
+
export INACTIVITY_AGE=30
207
+
export INACTIVITY_WARNING_AGE=0
208
+
```
209
+
210
+
NOTE: Creation age expiration takes precedent over activity age, so setting both `WARNING_AGE=0` and `INACTIVITY_WARNING_AGE=0` will cause only the creation date expiration warning to appear.
211
+
212
+
1. Run the app
213
+
214
+
```shell
215
+
aws-vault exec trussworks-ci -- python handler.py
216
+
```
217
+
218
+
- Example DEBUG output for creation age, notice the 'old' status:
219
+
220
+
| UserName | Slack ID | Key ID | AutoExpire | Status | Age in Days | Last Access Age |
- By exporting the SLACK_URL=test in addition to DEBUG=true, you can also view the slack message output:
233
+
234
+
```shell
235
+
slack message: {'attachments': [{'title': 'AWS IAM Key Inactivity Report', 'text': ''}, {'title': 'IAM users with access keys expiring due to inactivity. \n Please login to AWS to prevent key from being disabled', 'color': '#ffff00', 'fields': [{'title': 'Users', 'value': "sleuth-test2's key expires in 30 days due to inactivity."}]}]}
# finally, if nothing requires us to alert on this key, set to good
67
74
elifself.creation_age<rotate_age:
68
75
self.audit_state='good'
69
76
@@ -120,7 +127,7 @@ def audit():
120
127
121
128
# Check for optional env vars
122
129
if (os.environ.get('INACTIVITY_AGE') andnotos.environ.get('INACTIVITY_WARNING_AGE')) or (os.environ.get('INACTIVITY_WARNING_AGE') andnotos.environ.get('INACTIVITY_AGE')):
123
-
raiseRuntimeError('Must set env var INACTIVITY_WARNING_AGE and INACTIVITY_AGE')
130
+
raiseRuntimeError('Must set env var INACTIVITY_WARNING_AGE and INACTIVITY_AGE together')
0 commit comments