layout | page_title | description |
---|---|---|
azuredevops |
AzureDevops: azuredevops_serviceendpoint_azurecr |
Manages a Azure Container Registry service endpoint within Azure DevOps organization. |
Manages a Azure Container Registry service endpoint within Azure DevOps.
resource "azuredevops_project" "example" {
name = "Example Project"
visibility = "private"
version_control = "Git"
work_item_template = "Agile"
description = "Managed by Terraform"
}
# azure container registry service connection
resource "azuredevops_serviceendpoint_azurecr" "example" {
project_id = azuredevops_project.example.id
service_endpoint_name = "Example AzureCR"
resource_group = "example-rg"
azurecr_spn_tenantid = "00000000-0000-0000-0000-000000000000"
azurecr_name = "ExampleAcr"
azurecr_subscription_id = "00000000-0000-0000-0000-000000000000"
azurecr_subscription_name = "subscription name"
}
resource "azuredevops_project" "example" {
name = "Example Project"
visibility = "private"
version_control = "Git"
work_item_template = "Agile"
description = "Managed by Terraform"
}
resource "azurerm_resource_group" "identity" {
name = "identity"
location = "UK South"
}
resource "azurerm_user_assigned_identity" "example" {
location = azurerm_resource_group.identity.location
name = "example-identity"
resource_group_name = azurerm_resource_group.identity.name
}
# azure container registry service connection
resource "azuredevops_serviceendpoint_azurecr" "example" {
project_id = azuredevops_project.example.id
resource_group = "Example AzureCR ResourceGroup"
service_endpoint_name = "Example AzureCR"
service_endpoint_authentication_scheme = "WorkloadIdentityFederation"
azurecr_spn_tenantid = "00000000-0000-0000-0000-000000000000"
azurecr_name = "ExampleAcr"
azurecr_subscription_id = "00000000-0000-0000-0000-000000000000"
azurecr_subscription_name = "subscription name"
credentials {
serviceprincipalid = azurerm_user_assigned_identity.example.client_id
}
}
resource "azurerm_federated_identity_credential" "example" {
name = "example-federated-credential"
resource_group_name = azurerm_resource_group.identity.name
parent_id = azurerm_user_assigned_identity.example.id
audience = ["api://AzureADTokenExchange"]
issuer = azuredevops_serviceendpoint_azurecr.example.workload_identity_federation_issuer
subject = azuredevops_serviceendpoint_azurecr.example.workload_identity_federation_subject
}
The following arguments are supported:
-
project_id
- (Required) The ID of the project. -
service_endpoint_name
- (Required) The name you will use to refer to this service connection in task inputs. -
resource_group
- (Required) The resource group to which the container registry belongs. -
azurecr_spn_tenantid
- (Required) The tenant id of the service principal. -
service_endpoint_authentication_scheme
- (Optional) Specifies the type of azurerm endpoint, eitherWorkloadIdentityFederation
,ManagedServiceIdentity
orServicePrincipal
. Defaults toServicePrincipal
for backwards compatibility.ManagedServiceIdentity
has not yet been implemented for this resource. -
azurecr_name
- (Required) The Azure container registry name. -
azurecr_subscription_id
- (Required) The subscription id of the Azure targets. -
azurecr_subscription_name
- (Required) The subscription name of the Azure targets.
-
description
- (Optional) The Service Endpoint description. Defaults toManaged by Terraform
. -
credentials
- (Optional) Acredentials
block as defined below.
A credentials
block supports the following:
serviceprincipalid
- (Required) The ID of the Service Principal Application.
The following attributes are exported:
id
- The ID of the service endpoint.project_id
- The ID of the project.service_endpoint_name
- The Service Endpoint name.service_principal_id
- The Application(Client) ID of the Service Principal.workload_identity_federation_issuer
- The issuer ifservice_endpoint_authentication_scheme
is set toWorkloadIdentityFederation
. This looks likehttps://vstoken.dev.azure.com/00000000-0000-0000-0000-000000000000
, where the GUID is the Organization ID of your Azure DevOps Organisation.workload_identity_federation_subject
- The subject ifservice_endpoint_authentication_scheme
is set toWorkloadIdentityFederation
. This looks likesc://<organisation>/<project>/<service-connection-name>
.
The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 2 minutes) Used when creating the Azure Container Registry Service Endpoint.read
- (Defaults to 1 minute) Used when retrieving the Azure Container Registry Service Endpoint.update
- (Defaults to 2 minutes) Used when updating the Azure Container Registry Service Endpoint.delete
- (Defaults to 2 minutes) Used when deleting the Azure Container Registry Service Endpoint.
Azure DevOps Azure Container Registry Service Endpoint can be imported using projectID/serviceEndpointID or projectName/serviceEndpointID
terraform import azuredevops_serviceendpoint_azurecr.example 00000000-0000-0000-0000-000000000000/00000000-0000-0000-0000-000000000000