Skip to content

Retoxx-dev/terraform-azurerm-container-registry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-azurerm-container-registry

Create a docker container registry in Azure

This Terraform module deploys a container registry in Azure with optional diagnostic settings.

-> NOTE: This module can create User Assigned Identity for your cluster, to create one, just specify identity variable.

Usage

Container Registry with public access disabled

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "this" {
  name     = "rg-terraform-northeu-001"
  location = "northeurope"
}

module "acr" {
  source              = "Retoxx-dev/container-registry/azurerm"
  version             = "1.0.0"
  resource_group_name = azurerm_resource_group.this.name
  location            = azurerm_resource_group.this.location

  name                          = "<container-registry-name>"
  sku                           = "Basic"
  admin_enabled                 = false
  public_network_access_enabled = false
}

Container Registry with georeplication

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "this" {
  name     = "rg-terraform-northeu-001"
  location = "northeurope"
}

module "acr" {
  source              = "Retoxx-dev/container-registry/azurerm"
  version             = "1.0.0"
  resource_group_name = azurerm_resource_group.this.name
  location            = azurerm_resource_group.this.location

  name                          = "<container-registry-name>"
  sku                           = "Basic"
  admin_enabled                 = false
  public_network_access_enabled = false

  georeplications = [
    {
      location                  = "westeurope"
      regional_endpoint_enabled = true
      zone_redundancy_enabled   = true
    }
  ]
}

Requirements

Name Version
terraform >= 1.3.1
azurerm >=3.33

Providers

Name Version
azurerm >=3.33

Modules

No modules.

Resources

Name Type
azurerm_container_registry.this resource
azurerm_monitor_diagnostic_setting.this resource
azurerm_user_assigned_identity.this resource

Inputs

Name Description Type Default Required
admin_enabled (Optional) Specifies whether the admin user is enabled. Defaults to false. bool false no
anonymous_pull_enabled (Optional) Whether allows anonymous (unauthenticated) pull access to this Container Registry? This is only supported on resources with the Standard or Premium SKU. bool null no
data_endpoint_enabled (Optional) Whether to enable dedicated data endpoints for this Container Registry? This is only supported on resources with the Premium SKU. bool null no
diagnostic_settings (Optional) A diagnostic_settings block.
object({
name = string
eventhub_name = optional(string, null)
eventhub_authorization_rule_id = optional(string, null)
log_analytics_workspace_id = optional(string, null)
storage_account_id = optional(string, null)
log_analytics_destination_type = optional(string, null)
partner_solution_id = optional(string, null)

enabled_log = optional(object({
category = optional(string, null)
category_group = optional(string, null)

retention_policy = optional(object({
enabled = optional(bool, null)
days = optional(number, null)
}), null)
}), null)

metrics = optional(object({
category = optional(string, null)
enabled = optional(bool, null)
retention_policy = optional(object({
enabled = optional(bool, null)
days = optional(number, null)
}), null)
}), null)
})
null no
encryption (Optional) Specifies the encryption configuration for the resource.
object({
enabled = optional(bool, null)
key_vault_key_id = string
identity_client_id = string
})
null no
export_policy_enabled (Optional) Boolean value that indicates whether export policy is enabled. Defaults to true. In order to set it to false, make sure the public_network_access_enabled is also set to false. bool true no
georeplications (Optional) Specifies the georeplication configuration for the resource.
list(object({
location = string
regional_endpoint_enabled = optional(bool, null)
zone_redundancy_enabled = optional(bool, null)
tags = optional(map(string), {})
}))
null no
identity (Optional) Specifies the identity configuration for the resource.
object({
type = string
name = string
identity_ids = optional(list(string), [])
tags = optional(map(string), null)
})
null no
location (Required) The location in which to create the Kubernetes Cluster. string n/a yes
name (Required) Specifies the name of the Container Registry. Only Alphanumeric characters allowed. Changing this forces a new resource to be created. string n/a yes
network_rule_bypass_option (Optional) Whether to allow trusted Azure services to access a network restricted Container Registry? Possible values are None and AzureServices. Defaults to AzureServices. string null no
network_rule_sets (Optional) Specifies the network rule set configuration for the resource.
list(object({
default_action = optional(string, "Allow")
ip_rules = optional(list(object({
action = string
ip_range = string
})), [])
virtual_networks = optional(list(object({
action = string
subnet_id = string
})), [])
}))
null no
public_network_access_enabled (Optional) Whether public network access is allowed for the container registry. Defaults to true. bool true no
quarantine_policy_enabled (Optional) Boolean value that indicates whether quarantine policy is enabled. bool null no
resource_group_name (Required) The name of the resource group in which to create the Kubernetes Cluster. string n/a yes
retention_policy (Optional) Specifies the retention policy configuration for the resource.
object({
days = optional(number, 7)
enabled = optional(bool, null)
})
null no
sku (Required) The SKU name of the container registry. Possible values are Basic, Standard and Premium. string n/a yes
tags (Optional) A mapping of tags to assign to the resource. map(string) null no
trust_policy (Optional) Specifies the trust policy configuration for the resource.
object({
enabled = optional(bool, false)
})
null no
zone_redundancy_enabled (Optional) Whether zone redundancy is enabled for this Container Registry? Changing this forces a new resource to be created. Defaults to false. bool false no

Outputs

Name Description
admin_password The admin password of the Container Registry.
admin_username The admin username of the Container Registry.
id The ID of the Container Registry.
identity_principal_id The principal ID of the Container Registry.
identity_tenant_id The tenant ID of the Container Registry.
login_server The login_server of the Container Registry.