Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat : Add ip_rules variable for az-acr tf module #37

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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