terraform/website/source/docs/providers/azurerm/r/container_registry.html.mar...

2.7 KiB

layout page_title sidebar_current description
azurerm Azure Resource Manager: azurerm_container_registry docs-azurerm-resource-container-registry Create as an Azure Container Registry instance.

azurerm_container_registry

Create as an Azure Container Registry instance.

Example Usage

resource "azurerm_resource_group" "test" {
  name     = "resourceGroup1"
  location = "West US"
}

resource "azurerm_storage_account" "test" {
  name                = "storageAccount1"
  resource_group_name = "${azurerm_resource_group.test.name}"
  location            = "${azurerm_resource_group.test.location}"
  account_type        = "Standard_GRS"
}

resource "azurerm_container_registry" "test" {
  name                = "containerRegistry1"
  resource_group_name = "${azurerm_resource_group.test.name}"
  location            = "${azurerm_resource_group.test.location}"
  admin_enabled       = true

  storage_account {
    name       = "${azurerm_storage_account.test.name}"
    access_key = "${azurerm_storage_account.test.primary_access_key}"
  }
}

Argument Reference

The following arguments are supported:

  • name - (Required) Specifies the name of the Container Registry. Changing this forces a new resource to be created.

  • resource_group_name - (Required) The name of the resource group in which to create the Container Registry.

  • location - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

  • admin_enabled - (Optional) Specifies whether the admin user is enabled. Defaults to false.

  • storage_account - (Required) A Storage Account block as documented below - which must be located in the same data center as the Container Registry.

  • tags - (Optional) A mapping of tags to assign to the resource.

storage_account supports the following:

  • name - (Required) The name of the storage account, which must be in the same physical location as the Container Registry.
  • access_key - (Required) The access key to the storage account.

Attributes Reference

The following attributes are exported:

  • id - The Container Registry ID.

  • login_server - The URL that can be used to log into the container registry.

  • admin_username - The Username associated with the Container Registry Admin account - if the admin account is enabled.

  • admin_password - The Password associated with the Container Registry Admin account - if the admin account is enabled.

Import

Container Registries can be imported using the resource id, e.g.

terraform import azurerm_container_registry.test /subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/mygroup1/providers/Microsoft.ContainerRegistry/registries/myregistry1