Skip to content

Commit 4706acf

Browse files
authored
fix: Add new variable to control whether a repository policy is attached to the repository (#8)
1 parent 8189395 commit 4706acf

File tree

5 files changed

+10
-2
lines changed

5 files changed

+10
-2
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.72.1
3+
rev: v1.72.2
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_wrapper_module_for_each

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ No modules.
215215

216216
| Name | Description | Type | Default | Required |
217217
|------|-------------|------|---------|:--------:|
218+
| <a name="input_attach_repository_policy"></a> [attach\_repository\_policy](#input\_attach\_repository\_policy) | Determines whether a repository policy will be attached to the repository | `bool` | `true` | no |
218219
| <a name="input_create"></a> [create](#input\_create) | Determines whether resources will be created (affects all resources) | `bool` | `true` | no |
219220
| <a name="input_create_lifecycle_policy"></a> [create\_lifecycle\_policy](#input\_create\_lifecycle\_policy) | Determines whether a lifecycle policy will be created | `bool` | `true` | no |
220221
| <a name="input_create_registry_policy"></a> [create\_registry\_policy](#input\_create\_registry\_policy) | Determines whether a registry policy will be created | `bool` | `false` | no |

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ resource "aws_ecr_repository" "this" {
130130
################################################################################
131131

132132
resource "aws_ecr_repository_policy" "this" {
133-
count = local.create_private_repository && var.create_repository_policy ? 1 : 0
133+
count = local.create_private_repository && var.attach_repository_policy ? 1 : 0
134134

135135
repository = aws_ecr_repository.this[0].name
136136
policy = var.create_repository_policy ? data.aws_iam_policy_document.repository[0].json : var.repository_policy

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ variable "repository_policy" {
6666
# Repository Policy
6767
################################################################################
6868

69+
variable "attach_repository_policy" {
70+
description = "Determines whether a repository policy will be attached to the repository"
71+
type = bool
72+
default = true
73+
}
74+
6975
variable "create_repository_policy" {
7076
description = "Determines whether a repository policy will be created"
7177
type = bool

wrappers/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module "wrapper" {
1313
repository_kms_key = try(each.value.repository_kms_key, var.defaults.repository_kms_key, null)
1414
repository_image_scan_on_push = try(each.value.repository_image_scan_on_push, var.defaults.repository_image_scan_on_push, true)
1515
repository_policy = try(each.value.repository_policy, var.defaults.repository_policy, null)
16+
attach_repository_policy = try(each.value.attach_repository_policy, var.defaults.attach_repository_policy, true)
1617
create_repository_policy = try(each.value.create_repository_policy, var.defaults.create_repository_policy, true)
1718
repository_read_access_arns = try(each.value.repository_read_access_arns, var.defaults.repository_read_access_arns, [])
1819
repository_read_write_access_arns = try(each.value.repository_read_write_access_arns, var.defaults.repository_read_write_access_arns, [])

0 commit comments

Comments
 (0)