Skip to content

Commit

Permalink
Merge pull request #37 from using-system/features/acr-update
Browse files Browse the repository at this point in the history
feat : Add ip_rules variable for az-acr tf module
  • Loading branch information
using-system authored Mar 27, 2024
2 parents 6b4c4f3 + f2777d5 commit 7b12ed1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
Binary file modified terraform/modules/az-acr/README.md
Binary file not shown.
17 changes: 17 additions & 0 deletions terraform/modules/az-acr/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ resource "azurerm_container_registry" "acr" {
}
}

dynamic "network_rule_set" {
for_each = length(var.ip_rules) > 0 ? [1] : []

content {
default_action = "Deny"

dynamic "ip_rule" {
for_each = var.ip_rules

content {
action = "Allow"
ip_range = ip_rule.value
}
}
}
}

zone_redundancy_enabled = var.zone_redundancy_enabled

identity {
Expand Down
13 changes: 7 additions & 6 deletions terraform/modules/az-acr/tests/acr_secure.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ run "plan" {
command = plan

variables {
name = "usingsystemazacrtest1"
location = run.setup.resource_group_location
resource_group_name = run.setup.resource_group_name

tags = { Environment = "Test" }
name = "usingsystemazacrtest1"
location = run.setup.resource_group_location
resource_group_name = run.setup.resource_group_name
ip_rules = ["20.75.211.8/29", "20.99.157.152/29"]
tags = { Environment = "Test" }
}

assert {
Expand Down Expand Up @@ -126,7 +126,8 @@ run "apply" {
name = "usingsystemazacrtest1"
location = run.setup.resource_group_location
resource_group_name = run.setup.resource_group_name

ip_rules = ["20.75.211.8/29", "20.99.157.152/29"]

tags = { Environment = "Test" }
}

Expand Down
6 changes: 6 additions & 0 deletions terraform/modules/az-acr/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ variable "identity_ids" {
default = []
}

variable "ip_rules" {
description = "List of IP rules to allow on the acr."
type = list(string)
default = []
}

variable "tags" {
description = "Tags to associate with resources."
type = map(string)
Expand Down

0 comments on commit 7b12ed1

Please sign in to comment.