Skip to content

Commit bc1ea49

Browse files
authored
Merge pull request #256 from cloud-gov/overhaul
adding in the needed rules and cleaning up the debug info from the code
2 parents aae82dd + fd53184 commit bc1ea49

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

bosh/opsfiles/rules.yml

+25-4
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,35 @@
4242
value:
4343
name: aws-iam-check-keys
4444
rules:
45-
- alert: AWSIAMCheckKeys
46-
expr: stale_key_num > 0
45+
- alert: OperatorsStaleKeyWarning
46+
expr: last_rotated_days{user_type="Operator"} >= 75 and last_rotated_days{user_type="Operator"} < 90
4747
labels:
4848
service: aws-iam
4949
severity: warning
5050
annotations:
51-
summary: AWS IAM user {{$labels.user}} has stale IAM Key(s)
52-
description: Look up the procedures for rotating the access keys
51+
summary: IAM key for {$labels.user} will be expired within the next 15 days
52+
description: "For Operators if the expiration is within 15 days\n"
53+
- alert: PlatformApplicationStaleKeyWarning
54+
expr: last_rotated_days{user_type="Platform"} >= 80 and last_rotated_days{user_type="Platform"} < 165 or last_rotated_days{user_type="Application"} >= 80 and last_rotated_days{user_type="Application"} < 165
55+
labels:
56+
severity: warning
57+
annotations:
58+
summary: IAM key for Platform or Application {$labels.user} will be expired within the next 15 days
59+
description: "For Platform or Applications if the expiration is within 85 days\n"
60+
- alert: OperatorsStaleKeyViolation
61+
expr: last_rotated_days{user_type="Operator"} >= 90
62+
labels:
63+
severity: critical
64+
annotations:
65+
summary: IAM key for {$labels.user} is now expired
66+
description: "For Operators if the key is expired\n"
67+
- alert: PlatformApplicationStaleKeyViolation
68+
expr: last_rotated_days{user_type="Platform"} >= 165 or last_rotated_days{user_type="Application"} >= 165
69+
labels:
70+
severity: critical
71+
annotations:
72+
summary: IAM key for {$labels.user} is now expired
73+
description: "For Platform or Applications if the key is expired\n"
5374

5475
# CloudWatch logs alerts
5576
- type: replace

ci/aws-iam-check-keys/find_stale_keys.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ def del_key(key_dict: dict):
289289
are stale
290290
"""
291291
gateway = f'{env.str("GATEWAY_HOST")}:{env.int("GATEWAY_PORT", 9091)}'
292-
print(f'gateway in del_key is: {gateway}')
293292
del key_dict["days_since_rotation"]
294293
del key_dict["last_rotated"]
295294
del key_dict["key_num"]
@@ -304,13 +303,9 @@ def send_key(key_dict: dict, severity: str):
304303
Send the key(s) to the pushgateway client to let it determine if they
305304
are stale
306305
"""
307-
gateway = f"{env.str('GATEWAY_HOST')}:9091"
308-
#print(gateway_test)
309-
#gateway = f"{env.str('GATEWAY_HOST')}:{env.int('GATEWAY_PORT', 9091)}"
310-
print(f"gateway in send_key: {gateway}")
306+
gateway = f"{env.str('GATEWAY_HOST')}:{env.int('GATEWAY_PORT', 9091)}"
311307
registry = CollectorRegistry()
312308
days_since_rotation = key_dict["days_since_rotation"]
313-
# user_type = key_dict["user_type"]
314309
del key_dict["days_since_rotation"]
315310

316311
key_info = Gauge(

0 commit comments

Comments
 (0)