Skip to content

Commit f60f7b3

Browse files
authored
feat: Add Velero kms keys policy (#44)
1 parent 6dd790f commit f60f7b3

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ No modules.
566566
| <a name="input_trust_policy_conditions"></a> [trust\_policy\_conditions](#input\_trust\_policy\_conditions) | A list of conditions to add to the role trust policy | <pre>list(object({<br/> test = string<br/> values = list(string)<br/> variable = string<br/> }))</pre> | `[]` | no |
567567
| <a name="input_trust_policy_statements"></a> [trust\_policy\_statements](#input\_trust\_policy\_statements) | A list of IAM policy [statements](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#statement) for the role trust policy | <pre>list(object({<br/> sid = optional(string)<br/> actions = optional(list(string))<br/> not_actions = optional(list(string))<br/> effect = optional(string)<br/> resources = optional(list(string))<br/> not_resources = optional(list(string))<br/> principals = optional(list(object({<br/> type = string<br/> identifiers = list(string)<br/> })))<br/> not_principals = optional(list(object({<br/> type = string<br/> identifiers = list(string)<br/> })))<br/> condition = optional(list(object({<br/> test = string<br/> values = list(string)<br/> variable = string<br/> })))<br/> }))</pre> | `null` | no |
568568
| <a name="input_use_name_prefix"></a> [use\_name\_prefix](#input\_use\_name\_prefix) | Determines whether the role name and policy name(s) are used as a prefix | `string` | `true` | no |
569+
| <a name="input_velero_kms_arns"></a> [velero\_kms\_arns](#input\_velero\_kms\_arns) | KMS key ARNs to allow Velero to manage encrypted s3 buckets | `list(string)` | `[]` | no |
569570
| <a name="input_velero_policy_name"></a> [velero\_policy\_name](#input\_velero\_policy\_name) | Custom name of the Velero IAM policy | `string` | `null` | no |
570571
| <a name="input_velero_s3_bucket_arns"></a> [velero\_s3\_bucket\_arns](#input\_velero\_s3\_bucket\_arns) | List of S3 Bucket ARNs that Velero needs access to list | `list(string)` | `[]` | no |
571572
| <a name="input_velero_s3_bucket_path_arns"></a> [velero\_s3\_bucket\_path\_arns](#input\_velero\_s3\_bucket\_path\_arns) | S3 path ARNs to allow Velero to manage items at the provided path(s). This is required if `attach_mountpoint_s3_csi_policy = true` | `list(string)` | `[]` | no |

examples/complete/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ module "velero_pod_identity" {
509509
attach_velero_policy = true
510510
velero_s3_bucket_arns = ["arn:aws:s3:::velero-backups"]
511511
velero_s3_bucket_path_arns = ["arn:aws:s3:::velero-backups/example/*"]
512+
velero_kms_arns = ["arn:aws:kms:*:*:key/1234abcd-12ab-34cd-56ef-1234567890ab"]
512513

513514
# Pod Identity Associations
514515
association_defaults = {

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,3 +555,9 @@ variable "velero_s3_bucket_path_arns" {
555555
type = list(string)
556556
default = []
557557
}
558+
559+
variable "velero_kms_arns" {
560+
description = "KMS key ARNs to allow Velero to manage encrypted s3 buckets"
561+
type = list(string)
562+
default = []
563+
}

velero.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@ data "aws_iam_policy_document" "velero" {
4444
]
4545
resources = coalescelist(var.velero_s3_bucket_arns, ["arn:${local.partition}:s3:::*"])
4646
}
47+
48+
dynamic "statement" {
49+
for_each = length(var.velero_kms_arns) > 0 ? [1] : []
50+
51+
content {
52+
actions = [
53+
"kms:Encrypt",
54+
"kms:Decrypt",
55+
"kms:ReEncrypt*",
56+
"kms:GenerateDataKey*",
57+
"kms:DescribeKey",
58+
]
59+
60+
resources = var.velero_kms_arns
61+
}
62+
}
4763
}
4864

4965
locals {

wrappers/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ module "wrapper" {
7777
trust_policy_conditions = try(each.value.trust_policy_conditions, var.defaults.trust_policy_conditions, [])
7878
trust_policy_statements = try(each.value.trust_policy_statements, var.defaults.trust_policy_statements, null)
7979
use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true)
80+
velero_kms_arns = try(each.value.velero_kms_arns, var.defaults.velero_kms_arns, [])
8081
velero_policy_name = try(each.value.velero_policy_name, var.defaults.velero_policy_name, null)
8182
velero_s3_bucket_arns = try(each.value.velero_s3_bucket_arns, var.defaults.velero_s3_bucket_arns, [])
8283
velero_s3_bucket_path_arns = try(each.value.velero_s3_bucket_path_arns, var.defaults.velero_s3_bucket_path_arns, [])

0 commit comments

Comments
 (0)