3
3
This is a Golang program to assist with the reporting of Service Account key
4
4
ages, and rotating said keys once they pass a specific age threshold.
5
5
6
+ The tool can update keys held in the following locations:
7
+
8
+ * GitHub
9
+ * CircleCI
10
+ * K8S (GKE only)
11
+
12
+ The tool is packaged as an executable file for native invocation, and as a zip
13
+ file for deployment as an AWS Lambda.
14
+
6
15
## Install
7
16
8
17
### From Binary Releases
9
18
10
- Darwin, Linux and Windows Binaries can be downloaded from the [ Releases] ( https://github.com/ovotech/cloud-key-rotator/releases ) page.
19
+ Darwin, Linux and Windows Binaries can be downloaded from the
20
+ [ Releases] ( https://github.com/ovotech/cloud-key-rotator/releases ) page.
11
21
12
22
Try it out:
13
23
14
24
```
15
25
$ cloud-key-rotator -h
16
26
```
17
27
18
- ### Docker image
19
-
20
- An alpine based Docker image is available [ here] ( https://hub.docker.com/r/ovotech/cloud-key-rotator ) .
28
+ ### Docker Image
21
29
30
+ An Alpine-based Docker image is available [ here] ( https://hub.docker.com/r/ovotech/cloud-key-rotator ) .
22
31
23
32
## Getting Started
24
33
@@ -28,25 +37,32 @@ An alpine based Docker image is available [here](https://hub.docker.com/r/ovotec
28
37
to update with new keys, from config.
29
38
30
39
Check out [ examples] ( examples ) for example config files. [ Viper] ( https://github.com/spf13/viper )
31
- is used as the Config framework, so config can be stored as JSON, TOML, YAML, or
32
- HCL. To work, the file just needs to be called "config" (before whatever
40
+ is used as the config framework, so config can be stored as JSON, TOML, YAML or
41
+ HCL.
42
+
43
+ For native invocation, the file needs to be called "config" (before whatever
33
44
extension you're using), and be present either in ` /etc/cloud-key-rotator/ ` or
34
- in the same directory the binary runs in.
45
+ in the same directory the binary runs in. For AWS Lambda invocation, the config needs
46
+ to be set as a plaintext secret in the AWS Secrets Manager, using a default key name
47
+ of "ckr-config".
35
48
36
49
### Authentication/Authorisation
37
50
38
51
You'll need to provide ` cloud-key-rotator ` with the means of authenticating into
39
52
any key provider that it'll be updating.
40
53
41
54
Authorisation is handled by the Default Credential Provider Chains for both
42
- [ GCP] ( https://cloud.google.com/docs/authentication/production#auth-cloud-implicit-go ) and [ AWS] ( https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html#credentials-default ) .
55
+ [ GCP] ( https://cloud.google.com/docs/authentication/production#auth-cloud-implicit-go ) and
56
+ [ AWS] ( https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html#credentials-default ) .
43
57
44
58
### Mode Of Operation
45
59
46
- ` cloud-key-rotator ` can operate in 2 different modes. Rotation mode, in which
47
- keys are rotated, and non-rotation mode, which only posts the ages of the keys to
48
- the Datadog metric API. You can specify which mode to operate in by using the
49
- ` RotationMode ` boolean field in config.
60
+ ` cloud-key-rotator ` can operate in two different modes:
61
+
62
+ 1 . Rotation mode - in which keys are rotated; and
63
+ 2 . Non-rotation mode - which only posts the ages of keys to the Datadog Metric API.
64
+
65
+ The boolean field ` RotationMode ` config controls the mode of operation.
50
66
51
67
### Age Thresholds
52
68
@@ -55,47 +71,43 @@ You can set the age threshold to whatever you want in the config, using the
55
71
per-service-account-basis with the ` RotationAgeThresholdMins ` field. Key ages
56
72
are always measured in minutes.
57
73
58
- ` cloud-key-rotator ` won't attempt to rotate a key until it's passed the age
74
+ ` cloud-key-rotator ` will not attempt to rotate a key until it's passed the age
59
75
threshold you've set (either default or the key-specific). This allows you to
60
- run it as frequently as you want without worrying about keys being rotated too
61
- much .
76
+ run it the tool frequently as you want without worrying about keys being rotated
77
+ too excessively .
62
78
63
79
### Key Locations
64
80
65
- Key locations is the term used for the places that keys are stored, that
66
- ultimately get updated with new keys that are generated.
81
+ " Key locations" is the term used for the places where keys are stored, which will
82
+ ultimately be updated with the new keys that are generated.
67
83
68
84
Currently, the following locations are supported:
69
85
70
- - EnvVars CircleCI
71
- - Secrets in GKE
72
- - Files (encrypted via [ mantle] ( https://github.com/ovotech/mantle ) which
86
+ * EnvVars CircleCI
87
+ * Secrets in GKE
88
+ * Files (encrypted via [ mantle] ( https://github.com/ovotech/mantle ) which
73
89
integrates with KMS) in GitHub
74
90
75
91
## Rotation Process
76
92
77
- By design, the rotation process is sensitive; it attempts to verify its actions
78
- as much as possible, and aborts immediately if it sees any errors. The idea
79
- behind this approach is that it should be quick to re-run the tool (with new
80
- keys being created) once issues have been resolved. Cloud Providers usually
81
- limit the number of keys you can have attached to a Service Account at any one
82
- time, so worth bearing this in mind when re-running manually after seeing errors.
93
+ The tool attempts to verify its actions as much as possible and aborts
94
+ immediately if it encounters an error. By design, the tool does ** not** attempt to
95
+ handle errors gracefully and continue, since this can lead to a "split-brain effect",
96
+ with keys out-of-sync in various locations.
83
97
84
- The alternative to this, is for ` cloud-key-rotator ` to attempt to gracefully
85
- handle errors, and for someone to manually patch things up afterwards. This
86
- approach could lead to split-brain effect of key sources (places where the keys
87
- are used) and confusion around what needs to be done before the old key can be
88
- deleted. After all sources are using the new key, the same thing may happen on
89
- the next key rotation, which doesn't lend itself well to automation.
98
+ It should be quick to re-run the tool (with new keys being created) once issues
99
+ have been resolved. Note that cloud providers usually limit the number of
100
+ keys you can have attached to a Service Account at any one time, so it is
101
+ worth bearing this in mind when re-running manually after seeing errors.
90
102
91
- Only the first key of a Service Account is handled by ` cloud-key-rotator ` . If it
92
- handled more than one key, it could lead to complications when updating single
93
- sources multiple times.
103
+ Only the first key of a Service Account is handled by ` cloud-key-rotator ` . If
104
+ it handled more than one key, it could lead to complications when updating
105
+ single sources multiple times.
94
106
95
107
## Key Sources
96
108
97
109
The ` AccountKeyLocations ` section of config holds details of the places where the keys
98
- are stored. E .g.:
110
+ are stored, e .g.:
99
111
100
112
``` JSON
101
113
"AccountKeyLocations" : [{
@@ -124,18 +136,18 @@ are stored. E.g.:
124
136
125
137
` cloud-key-rotator ` has integrations into GitHub and CircleCI, which allows it
126
138
not only to update those sources with the new key, but also to verify that a
127
- deployment has been successful after committing to a GitHub repo . If that
139
+ deployment has been successful after committing to a GitHub repository . If that
128
140
verification isn't required, you can disable it using the ` VerifyCircleCISuccess `
129
141
boolean.
130
142
131
- For any GitHub key source that's configured , the whole process will be aborted
132
- if there's no ` KmsKey ` value set. Unencrypted keys shouldn't ever be committed
143
+ For any GitHub key location , the whole process will be aborted
144
+ if there is no ` KmsKey ` value set. Unencrypted keys should ** never ** be committed
133
145
to a Git repository.
134
146
135
147
## GPG Commit Signing
136
148
137
149
Commits to GitHub repositories are required to be GPG signed. In order to
138
- achieve this, you just need to provide 4 things:
150
+ achieve this, you need to provide 4 things:
139
151
140
152
* ` Username ` of the GitHub user commits will be made on behalf of, set in config
141
153
* ` Email ` address of GitHub user, set in config
@@ -180,18 +192,19 @@ Service Account's email address.
180
192
181
193
## Rotation Flow
182
194
183
- - Reduce keys to those of service accounts deemed to be valid (e.g. strip out
195
+ 1 . Reduce keys to those of service accounts deemed to be valid (e.g. strip out
184
196
user accounts if in rotation-mode)
185
- - Filter keys to those deemed to be eligible (e.g. according to filtering rules
197
+ 2 . Filter keys to those deemed to be eligible (e.g. according to filtering rules
186
198
configured by the user)
187
- - For each eligible key:
188
- - Create new key
189
- - Update key locations
190
- - Verify update has worked (where possible)
191
- - Delete old key
199
+ 3 . For each eligible key:
200
+
201
+ * Create new key
202
+ * Update key locations
203
+ * Verify update has worked (where possible)
204
+ * Delete old key
192
205
193
206
## Contributions
194
207
195
- Contributions are more than welcome. It should be straight forward plugging in
196
- new integrations of new key providers and/or locations, so for that,
208
+ Contributions are more than welcome. It should be straightforward plugging in
209
+ integrations of new key providers and/or locations, so for that,
197
210
or anything else, please branch or fork and raise a PR.
0 commit comments