Skip to content

Commit 6f59a18

Browse files
committed
feat: Add KMS functionality
feat: Add KMS functionality
1 parent dcff901 commit 6f59a18

File tree

4 files changed

+36
-17
lines changed

4 files changed

+36
-17
lines changed

README.md

+10-8
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ benefits of a lifecycle policy, all with just a few simple commands. Try it out
5555

5656
| Name | Description | Type | Default | Required |
5757
|------|-------------|------|---------|:--------:|
58+
| <a name="input_encryption_type"></a> [encryption\_type](#input\_encryption\_type) | The encryption type to use for the repository. | `string` | `"AES256"` | no |
5859
| <a name="input_force_delete"></a> [force\_delete](#input\_force\_delete) | Delete the repository even if it contains images. | `bool` | `false` | no |
5960
| <a name="input_image_tag_mutability"></a> [image\_tag\_mutability](#input\_image\_tag\_mutability) | The tag mutability setting for the repository. | `string` | `"MUTABLE"` | no |
61+
| <a name="input_kms_key"></a> [kms\_key](#input\_kms\_key) | The ARN of the KMS key to use for encryption. | `string` | `null` | no |
6062
| <a name="input_lifecycle_rules"></a> [lifecycle\_rules](#input\_lifecycle\_rules) | Lifecycle policy rules for expiring images. | <pre>list(object({<br> description = optional(string)<br> tag_status = optional(string)<br> tag_prefix_list = optional(list(string))<br> count_type = string<br> count_unit = optional(string)<br> count_number = number<br> }))</pre> | <pre>[<br> {<br> "count_number": 30,<br> "count_type": "imageCountMoreThan",<br> "description": "Keep the last 30 tagged images",<br> "tag_prefix_list": [<br> "sha"<br> ],<br> "tag_status": "tagged"<br> },<br> {<br> "count_number": 10,<br> "count_type": "sinceImagePushed",<br> "count_unit": "days",<br> "description": "Expire untagged images older than 10 days",<br> "tag_status": "untagged"<br> }<br>]</pre> | no |
6163
| <a name="input_name"></a> [name](#input\_name) | Name of the ECR repository. | `string` | n/a | yes |
6264
| <a name="input_policy"></a> [policy](#input\_policy) | Repository policy document in JSON format. | `string` | `null` | no |
@@ -80,18 +82,18 @@ benefits of a lifecycle policy, all with just a few simple commands. Try it out
8082

8183
## Resources
8284

83-
- resource.aws_ecr_lifecycle_policy.main (main.tf#38)
85+
- resource.aws_ecr_lifecycle_policy.main (main.tf#43)
8486
- resource.aws_ecr_repository.main (main.tf#19)
85-
- resource.aws_ecr_repository_policy.main (main.tf#31)
86-
- data source.jq_query.main (main.tf#47)
87+
- resource.aws_ecr_repository_policy.main (main.tf#36)
88+
- data source.jq_query.main (main.tf#52)
8789

8890
# Examples
89-
### Full
90-
```hcl
91-
module "basic_example" {
92-
source = "../../"
91+
### Full
92+
```hcl
93+
module "basic_example" {
94+
source = "../.."
9395
9496
name = var.name
9597
}
96-
```
98+
```
9799
<!-- END_TF_DOCS -->

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

+5
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
}

variables.tf

+20-8
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@ 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
}
@@ -62,3 +62,15 @@ 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+
}

0 commit comments

Comments
 (0)