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

Providers

Name Version
azurerm 3.82.0
Name Version
azurerm 3.76.0

Modules

No modules.

Inputs

Name Description Type Default Required
admin_enabled Determines if the admin user is enabled bool false no
enable_lock_on_acr Determines if the lock on acr is enabled bool true no
georeplication_locations List of locations for the georeplication list(string) [] no
identity_ids A list of identities associated with the acr. list(string) [] no
identity_type The type of identity used for the acr. string "SystemAssigned" no
location Azure Region Location any n/a yes
name Name of the acr any n/a yes
network_rule_bypass_option Determines if the network rule bypass option is enabled string "None" no
public_network_access_enabled Determines if the public network access is enabled bool false no
quarantine_policy_enabled Determines if the quarantine policy is enabled bool true no
resource_group_name Resource group name of the acr any n/a yes
retention_policy_days Number of days to retain an untagged manifest after which it gets purged number 7 no
retention_policy_enabled Determines if the retention policy is enabled bool true no
sku The SKU name of the container registry. string "Premium" no
tags Tags to associate with resources. map(string) n/a yes
trust_policy_enabled Determines if the trust policy is enabled bool true no
zone_redundancy_enabled Determines if the zone redundancy is enabled bool true no
Name Description Type Default Required
admin_enabled Determines if the admin user is enabled bool false no
enable_lock_on_acr Determines if the lock on acr is enabled bool true no
georeplication_locations List of locations for the georeplication list(string) [] no
identity_ids A list of identities associated with the acr. list(string) [] no
identity_type The type of identity used for the acr. string "SystemAssigned" no
ip_rules List of IP rules to allow on the acr. list(string) [] no
location Azure Region Location any n/a yes
name Name of the acr any n/a yes
network_rule_bypass_option Determines if the network rule bypass option is enabled string "None" no
public_network_access_enabled Determines if the public network access is enabled bool false no
quarantine_policy_enabled Determines if the quarantine policy is enabled bool true no
resource_group_name Resource group name of the acr any n/a yes
retention_policy_days Number of days to retain an untagged manifest after which it gets purged number 7 no
retention_policy_enabled Determines if the retention policy is enabled bool true no
sku The SKU name of the container registry. string "Premium" no
tags Tags to associate with resources. map(string) n/a yes
trust_policy_enabled Determines if the trust policy is enabled bool true no
zone_redundancy_enabled Determines if the zone redundancy is enabled bool true no

Outputs

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