Skip to content

Commit 922201d

Browse files
committed
fix(CO-740): Encrypt ECR
1 parent dcff901 commit 922201d

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

examples/basic-example/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module "basic_example" {
2-
source = "../../"
2+
source = "../.."
33

44
name = var.name
55
}

main.tf

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ resource "aws_ecr_repository" "main" {
2121
image_tag_mutability = var.image_tag_mutability
2222
force_delete = var.force_delete
2323

24+
encryption_configuration {
25+
encryption_type = var.encryption_type
26+
kms_key = var.kms_key
27+
}
28+
2429
image_scanning_configuration {
2530
scan_on_push = var.scan_on_push
2631
}
@@ -46,7 +51,7 @@ resource "aws_ecr_lifecycle_policy" "main" {
4651
# to remove any null values from the JSON before sending it to AWS.
4752
data "jq_query" "main" {
4853
query = "del(..|nulls)"
49-
data = jsonencode({
54+
data = jsonencode({
5055
rules = [
5156
for index, rule in var.lifecycle_rules : {
5257
rulePriority = index + 1

variables.tf

+23-9
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,33 @@ variable "tags" {
1111
}
1212

1313
## REPOSITORY
14+
variable "encryption_type" {
15+
description = "The encryption type to use for the repository."
16+
default = "AES256"
17+
type = string
18+
}
19+
1420
variable "image_tag_mutability" {
1521
description = "The tag mutability setting for the repository."
1622
default = "MUTABLE"
1723
type = string
1824
}
1925

20-
variable "scan_on_push" {
21-
description = "Indicates whether images are scanned after being pushed to the repository."
22-
default = true
23-
type = bool
24-
}
25-
2626
variable "force_delete" {
2727
description = "Delete the repository even if it contains images."
2828
default = false
2929
type = bool
3030
}
3131

32-
variable "policy" {
33-
description = "Repository policy document in JSON format."
32+
variable "kms_key" {
33+
description = "The ARN of the KMS key to use for encryption."
3434
default = null
3535
type = string
3636
}
3737

3838
variable "lifecycle_rules" {
3939
description = "Lifecycle policy rules for expiring images."
40-
default = [
40+
default = [
4141
{
4242
description = "Keep the last 30 tagged images"
4343
tag_status = "tagged"
@@ -62,3 +62,17 @@ variable "lifecycle_rules" {
6262
count_number = number
6363
}))
6464
}
65+
66+
variable "policy" {
67+
description = "Repository policy document in JSON format."
68+
default = null
69+
type = string
70+
}
71+
72+
variable "scan_on_push" {
73+
description = "Indicates whether images are scanned after being pushed to the repository."
74+
default = true
75+
type = bool
76+
}
77+
78+

0 commit comments

Comments
 (0)