Get Azure Container Registry (ACR) Information With Terraform

In this blog post, I will show you how to get the username, password and server address of an Azure Container Register (ACR) with Terraform code.

Data Sources

Besides creating resources in Azure, Terraform can read the configuration data of existing resources in Azure without modifying them.

To retrieve data from resources Terraform is using a Data Source confirmation object to query existing resources. In the following example, I’m using Terraform to get the username, server and password of the registry.

Configuration

To complete the configuration, all you need to do is provide the ACR name and the resource group it resides (Line 15) and Terraform will output all the details. The full configuration is available in our GitHub repository below.

https://github.com/ntweeklycom/code/blob/main/terraform/2.Get_ACR_Info/data.tf


Posted

in

,

by