Skip to content

Commit 5e61e5c

Browse files
author
iru
authored
doc: rotation guidelines for k8s example aws_iam_access_key (#73)
* chore: modify lifecycle to reduce possible disruption * doc: iam-user key rotation guidelines
1 parent b10f63c commit 5e61e5c

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

modules/infrastructure/permissions/iam-user/README.md

+31-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,37 @@
11
# Permissions :: Single-Account user credentials
22

33
Creates an IAM user and adds permissions for required modules.
4-
<br/>Will use the `deploy_threat_detection` and `deploy_image_scanning` flags
4+
<br/>Will use the `deploy_threat_detection` and `deploy_image_scanning` flags to pin down specific feature-permissions.
5+
6+
7+
## Access Key Rotation
8+
This module creates a user, and its `aws_iam_access_key` in order Kubernetes-based examples to be able to work with its
9+
core component [`cloud-connector` helm chart](https://charts.sysdig.com/charts/cloud-connector/)
10+
11+
As AWS Best practices suggest, this **key SHOULD be rotated before 90 days**, but it's not in Sysdig Terraform module's
12+
responsibility to do so.
13+
14+
Here some guidelines though:
15+
16+
- Up till day, nor AWS nor Terraform do offer an official automatic key rotation.
17+
- There are several workarounds [[1]](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html#Using_RotateAccessKey) [[2]](https://aws-rotate-iam-keys.com/) [[3]](https://github.com/GSA/aws-access-key-rotation-lambda), but all require some way of detecting the closeness of this date, and a workload to force the key generation.
18+
- What we suggest, is to
19+
1. Create a detection system to know when the access key is nearing the 90 day mark (ex.: cloudwatch daily checkup, cron task , ...)
20+
2. Optionally, [Terraform Refresh](https://learn.hashicorp.com/tutorials/terraform/refresh) your terraform state beforehand, to avoid confussion with 3rd step
21+
```shell
22+
$ terraform apply -refresh-only
23+
```
24+
3. [Terraform Taint/Replace](https://www.terraform.io/cli/commands/taint) the `aws_iam_access_key` so that a new key is created and propagated to the [`cloud-connector` helm chart](https://charts.sysdig.com/charts/cloud-connector/).
25+
<br/>This will ask a confirmation, after showing the plan, where the access_key will be replaced and the helm chart updated
26+
```shell
27+
$ terraform state list | grep aws_iam_access_key
28+
module.cloudvision_aws_single_account_k8s.module.iam_user.aws_iam_access_key.this
29+
30+
$ terraform apply -replace="module.cloudvision_aws_single_account_k8s.module.iam_user.aws_iam_access_key.this"
31+
```
32+
33+
Note: Contact us if this authentication system does not match your requirement.
34+
535

636
<!-- BEGIN_TF_DOCS -->
737
## Requirements

modules/infrastructure/permissions/iam-user/main.tf

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ resource "aws_iam_user" "this" {
66

77
resource "aws_iam_access_key" "this" {
88
user = aws_iam_user.this.name
9+
lifecycle {
10+
create_before_destroy = true
11+
}
912
}
1013

1114

0 commit comments

Comments
 (0)