Create an Azure Container Registry (ACR) With Terraform

In this blog post, we will continue with our Terraform learning and will learn how to create an Azure Container Registry (ACR) with Terraform.

Microsoft Azure Container Registry (ACR) service allows us to create a private Docker image registry in Azure.

The Terraform configuration will create the following:

  • Create an ACR registry
  • Set the pricing tier to basic
  • Enable Admin access
  • Output the security key for admin access to the screen when the creation process is completed

Terraform Configuration

Below is the configuration, To run it from a Windows 10 and macOS machine follow this guide.

  required_providers {
    azurerm = {
      source = "hashicorp/azurerm"
      version = ">= 2.26"

provider "azurerm" {
  features {}

resource "azurerm_resource_group" "rg" {
  name     = "rg-tf-acr"
  location = "westus"

resource "azurerm_container_registry" "acr" {
  name                     = "acrname"
  resource_group_name      =
  location                 = azurerm_resource_group.rg.location
  sku                      = "Basic"
  admin_enabled            = true

output "admin_password" {
  value       = azurerm_container_registry.acr.admin_password
  description = "The object ID of the user"