Azure Container Registry
This page shows how to write Terraform and Azure Resource Manager for Container Registry and write them securely.
azurerm_container_registry (Terraform)
The Registry in Container can be configured in Terraform with the resource name azurerm_container_registry. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_container_registry" "my_registry" {
name = "containerRegistry1"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
sku = "Premium"
admin_enabled = false
resource "azurerm_container_registry" "my_registry" {
name = "containerRegistry1"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
sku = "Premium"
admin_enabled = false
resource "azurerm_container_registry" "registry" {
count = var.georeplication_locations == [] ? 1 : 0
name = var.name
resource_group_name = azurerm_resource_group.group.name
location = azurerm_resource_group.group.location
resource "azurerm_container_registry" "acr_dev_ablunch2_aztech_kc" {
name = "acrdevablunch2aztechkc"
resource_group_name = data.azurerm_resource_group.rg_dev_lunch2_aztech_kc.name
location = var.location
sku = "Standard"
admin_enabled = true
resource "azurerm_container_registry" "acr" {
name = "containerRregistryScalableMicroservice"
resource_group_name = azurerm_resource_group.scalable_microservice.name
location = azurerm_resource_group.scalable_microservice.location
sku = "standard"
}
resource "azurerm_container_registry" "acr" {
name = join("", [var.project_name, "acr"])
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
sku = "Basic"
admin_enabled = true
resource "azurerm_container_registry" "acr" {
name = var.container_registry_name
resource_group_name = var.product_resource_group_name
location = var.location
sku = var.container_registry_sku
resource "azurerm_container_registry" "main" {
location = var.az_location
name = replace(local.delphai_name, "-", "")
resource_group_name = azurerm_resource_group.main.name
admin_enabled = true
sku = "Premium"
resource "azurerm_container_registry" "acr" {
name = local.acr_name
resource_group_name = azurerm_resource_group.spoke.name
location = azurerm_resource_group.spoke.location
sku = "Premium"
admin_enabled = false
resource "azurerm_container_registry" "acr" {
name = var.name
resource_group_name = var.resource_group_name
location = var.location
sku = var.sku
admin_enabled = var.admin_enabled
Parameters
-
admin_enabledoptional - bool -
admin_passwordoptional computed - string -
admin_usernameoptional computed - string -
georeplication_locationsoptional - set of string -
idoptional computed - string -
locationrequired - string -
login_serveroptional computed - string -
namerequired - string -
network_rule_setoptional computed - list of object-
default_action- string -
ip_rule- set of object -
virtual_network- set of object
-
-
public_network_access_enabledoptional - bool -
quarantine_policy_enabledoptional - bool -
resource_group_namerequired - string -
retention_policyoptional computed - list of object -
skuoptional - string -
storage_account_idoptional - string -
tagsoptional - map from string to string -
trust_policyoptional computed - list of object-
enabled- bool
-
-
timeoutssingle block
Explanation in Terraform Registry
Manages an Azure Container Registry.
Note: All arguments including the access key will be stored in the raw state as plain-text. Read more about sensitive data in state.
Tips: Best Practices for The Other Azure Container Resources
In addition to the azurerm_kubernetes_cluster, Azure Container has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
azurerm_kubernetes_cluster
Ensure to enable logging for AKS
It is better to enable AKS logging to Azure Monitoring. This provides useful information regarding access and usage.
Microsoft.ContainerRegistry/registries (Azure Resource Manager)
The registries in Microsoft.ContainerRegistry can be configured in Azure Resource Manager with the resource name Microsoft.ContainerRegistry/registries. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
{
"contentVersion": "1.0.0.0",
"parameters": {
"workbookDisplayName": {
"type": "string",
{
"contentVersion": "1.0.0.0",
"parameters": {
"workbookDisplayName": {
"type": "string",
{
"contentVersion": "1.0.0.0",
"parameters": {
"workbookDisplayName": {
"type": "string",
{
"contentVersion": "1.0.0.0",
"parameters": {
"workbookDisplayName": {
"type": "string",
Parameters
apiVersionrequired - stringidentityoptionalprincipalIdoptional - stringThe principal ID of resource identity.
tenantIdoptional - stringThe tenant ID of resource.
typeoptional - stringThe identity type.
userAssignedIdentitiesoptional - undefinedThe list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
locationrequired - stringThe location of the resource. This cannot be changed after the resource is created.
namerequired - stringThe name of the container registry.
propertiesrequiredadminUserEnabledoptional - booleanThe value that indicates whether the admin user is enabled.
dataEndpointEnabledoptional - booleanEnable a single data endpoint per region for serving data.
encryptionoptionalkeyVaultPropertiesoptionalidentityoptional - stringThe client id of the identity which will be used to access key vault.
keyIdentifieroptional - stringKey vault uri to access the encryption key.
statusoptional - stringIndicates whether or not the encryption is enabled for container registry.
networkRuleBypassOptionsoptional - stringWhether to allow trusted Azure services to access a network restricted registry.
networkRuleSetoptionaldefaultActionrequired - stringThe default action of allow or deny when no other rules match.
ipRulesoptional arrayactionoptional - stringThe action of IP ACL rule.
valuerequired - stringSpecifies the IP or IP range in CIDR format. Only IPV4 address is allowed.
policiesoptionalexportPolicyoptionalstatusoptional - stringThe value that indicates whether the policy is enabled or not.
quarantinePolicyoptionalstatusoptional - stringThe value that indicates whether the policy is enabled or not.
retentionPolicyoptionaldaysoptional - integerThe number of days to retain an untagged manifest after which it gets purged.
statusoptional - stringThe value that indicates whether the policy is enabled or not.
trustPolicyoptionalstatusoptional - stringThe value that indicates whether the policy is enabled or not.
typeoptional - stringThe type of trust policy.
publicNetworkAccessoptional - stringWhether or not public network access is allowed for the container registry.
zoneRedundancyoptional - stringWhether or not zone redundancy is enabled for this container registry.
skurequirednamerequired - stringThe SKU name of the container registry. Required for registry creation.
tagsoptional - stringThe tags of the resource.
typerequired - string
Frequently asked questions
What is Azure Container Registry?
Azure Container Registry is a resource for Container of Microsoft Azure. Settings can be wrote in Terraform.
Where can I find the example code for the Azure Container Registry?
For Terraform, the gilyas/infracost, infracost/infracost and DanielMabbett/terraform-azurerm-container-registry source code examples are useful. See the Terraform Example section for further details.
For Azure Resource Manager, the scautomation/Azure-Inventory-Workbook, rb-cloud-guru/Azure_Dashboard and VJchand-star/Azure source code examples are useful. See the Azure Resource Manager Example section for further details.