Skip to content

Commit

Permalink
Adding encryption_type to allow using kms without passing key id and …
Browse files Browse the repository at this point in the history
…adding ecr:ListImages for argocd-image-updater (#21)

* Adding encryption_type to allow using kms without passing key id and adding ecr:ListImages for argocd-image-updater

* terraform-docs: automated update action

---------

Co-authored-by: adenot <adenot@users.noreply.github.com>
  • Loading branch information
adenot and adenot authored Dec 11, 2024
1 parent 6c06ca0 commit 83830eb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ The following resources will be created:

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| encryption\_type | Encryption type, KMS or AES256. When kms\_key\_arn is passed, encryption\_type is always KMS | `string` | `"KMS"` | no |
| image\_tag\_mutability | The tag mutability setting for the repository. Must be one of: MUTABLE or IMMUTABLE. Defaults to MUTABLE. | `string` | `"MUTABLE"` | no |
| kms\_key\_arn | KMS Key ARN to use a CMK instead of default key | `string` | `""` | no |
| lifecycle\_policy | JSON formatted string ECR repository lifecycle policy. | `string` | `""` | no |
Expand Down
8 changes: 7 additions & 1 deletion _variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ variable "trust_accounts" {
description = "Accounts to trust and allow ECR fetch"
}

variable "encryption_type" {
type = string
description = "Encryption type, KMS or AES256. When kms_key_arn is passed, encryption_type is always KMS"
default = "KMS"
}

variable "kms_key_arn" {
type = string
description = "KMS Key ARN to use a CMK instead of default key"
Expand Down Expand Up @@ -35,4 +41,4 @@ variable "tags" {
description = "Map of tags that will be added to created resources. By default resources will be tagged with name and environment."
type = map(string)
default = {}
}
}
3 changes: 2 additions & 1 deletion ecr-policies.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ data "aws_iam_policy_document" "default" {
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"ecr:BatchCheckLayerAvailability",
"ecr:DescribeImageScanFindings"
"ecr:DescribeImageScanFindings",
"ecr:ListImages"
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion ecr-repositories.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resource "aws_ecr_repository" "default" {
image_tag_mutability = var.image_tag_mutability

encryption_configuration {
encryption_type = var.kms_key_arn != "" ? "KMS" : "AES256"
encryption_type = var.kms_key_arn != "" ? "KMS" : var.encryption_type
kms_key = var.kms_key_arn
}

Expand Down

0 comments on commit 83830eb

Please sign in to comment.