Skip to content

Commit 938c4f1

Browse files
committed
ADE - Updates for private repo support - Terraform
1 parent abc8421 commit 938c4f1

File tree

4 files changed

+67
-6
lines changed

4 files changed

+67
-6
lines changed

articles/deployment-environments/how-to-configure-extensibility-terraform-container-image.md

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ ms.service: azure-deployment-environments
66
ms.custom: devx-track-azurecli, devx-track-terraform
77
author: RoseHJM
88
ms.author: rosemalcolm
9-
ms.date: 04/15/2024
9+
ms.date: 08/02/2024
1010
ms.topic: how-to
1111
#customer intent: As a developer, I want to learn how to build and utilize custom images within my environment definitions for deployment environments.
1212
---
1313

1414
# Configure a container image to execute deployments with Terraform
1515

16-
In this article, you learn how to build custom Terraform container images to deploy your environment definitions in Azure Deployment Environments (ADE). You learn how to configure a custom image to provision infrastructure using the Terraform Infrastructure-as-Code (IaC) framework.
16+
In this article, you learn how to build custom Terraform container images to deploy your [environment definitions](configure-environment-definition.md) in Azure Deployment Environments (ADE). You learn how to configure a custom image to provision infrastructure using the Terraform Infrastructure-as-Code (IaC) framework.
1717

1818
An environment definition comprises at least two files: a template file, like *main.tf*, and a manifest file named *environment.yaml*. You use a container to deploy environment definition that uses Terraform.
1919

20-
The ADE extensibility model enables you to create custom container images to use with your environment definitions. By using the extensibility model, you can create your own custom container images, and store them in a container registry like DockerHub. You can then reference these images in your environment definitions to deploy your environments.
20+
The ADE extensibility model enables you to create custom container images to use with your environment definitions. By using the extensibility model, you can create your own custom container images, and store them in a container registry like Azure Container Registry (ACR) or DockerHub. You can then reference these images in your environment definitions to deploy your environments.
2121

2222
## Prerequisites
2323

@@ -158,7 +158,9 @@ echo "{\"outputs\": $tfOutputs}" > $ADE_OUTPUTS
158158
```
159159
## Make the custom image accessible to ADE
160160

161-
You must build your Docker image and push it to your container registry to make it available for use in ADE. You can build your image using the Docker CLI, or by using a script provided by ADE.
161+
You must build your Docker image and push it to your container registry to make it available for use in ADE.
162+
163+
You can build your image using the Docker CLI, or by using a script provided by ADE.
162164

163165
Select the appropriate tab to learn more about each approach.
164166

@@ -178,9 +180,16 @@ docker build . -t {YOUR_REGISTRY}.azurecr.io/customImage:1.0.0
178180

179181
## Push the Docker image to a registry
180182

181-
In order to use custom images, you need to set up a publicly accessible image registry with anonymous image pull enabled. This way, Azure Deployment Environments can access your custom image to execute in our container.
183+
In order to use custom images, you need to store them in a registry like Azure Container Registry (ACR) or Docker Hub.
184+
185+
To use a custom image stored in a public registry, you need to enable anonymous image pull. This way, Azure Deployment Environments can access your custom image to execute in our container.
186+
187+
> [!Caution]
188+
> Enabling anonymous (unauthenticated) pull access makes all registry content publicly available for read (pull) actions.
189+
190+
To use a custom image stored in ACR, you need to ensure that ADE has appropriate permissions to access your image. Anonymous pull access is disabled by default in ACR.
182191

183-
Azure Container Registry is an Azure offering that stores container images and similar artifacts.
192+
#### Use a public registry with anonymous pull
184193

185194
To create a registry, which can be done through the Azure CLI, the Azure portal, PowerShell commands, and more, follow one of the [quickstarts](/azure/container-registry/container-registry-get-started-azure-cli).
186195

@@ -199,6 +208,58 @@ When you're ready to push your image to your registry, run the following command
199208
docker push {YOUR_REGISTRY}.azurecr.io/{YOUR_IMAGE_LOCATION}:{YOUR_TAG}
200209
```
201210

211+
#### Use ACR with secured access
212+
213+
By default, access to pull or push content from an Azure Container Registry is only available to authenticated users. You can further secure access to ACR by limiting access from certain networks and assigning specific roles.
214+
215+
##### Limit network access
216+
217+
To secure network access to your ACR, you can limit access to your own networks, or disable public network access entirely. If you limit network access, you must enable the firewall exception *Allow trusted Microsoft services to access this container registry*.
218+
219+
To disable access from public networks:
220+
221+
1. [Create an ACR instance](/azure/container-registry/container-registry-get-started-portal?tabs=azure-cli) or use an existing one.
222+
1. In the Azure portal, go to the ACR that you want to configure.
223+
1. On the left menu, under **Settings**, select **Networking**.
224+
1. On the Networking page, on the **Public access** tab, under **Public network access**, select **Disabled**.
225+
226+
:::image type="content" source="media/how-to-configure-extensibility-terraform-container-image/container-registry-network-settings.png" alt-text="Screenshot of the Azure portal, showing the ACR network settings, with Public access and Disabled highlighted.":::
227+
228+
1. Under **Firewall exception**, check that **Allow trusted Microsoft services to access this container registry** is selected, and then select **Save**.
229+
230+
:::image type="content" source="media/how-to-configure-extensibility-terraform-container-image/container-registry-network-disable-public.png" alt-text="Screenshot of the ACR network settings, with Allow trusted Microsoft services to access this container registry and Save highlighted.":::
231+
232+
##### Assign the AcrPull role
233+
234+
Creating environments by using container images uses the ADE infrastructure, including projects and environment types. Each project has one or more project environment types, which need read access to the container image that defines the environment to be deployed. To access the images within your ACR securely, assign the AcrPull role to each project environment type.
235+
236+
To assign the AcrPull role to the Project Environment Type:
237+
238+
1. In the Azure portal, go to the ACR that you want to configure.
239+
1. On the left menu, select **Access Control (IAM)**.
240+
1. Select **Add** > **Add role assignment**.
241+
1. Assign the following role. For detailed steps, see [Assign Azure roles using the Azure portal](../role-based-access-control/role-assignments-portal.yml).
242+
243+
| Setting | Value |
244+
| --- | --- |
245+
| **Role** | Select **AcrPull**. |
246+
| **Assign access to** | Select **User, group, or service principal**. |
247+
| **Members** | Enter the name of the project environment type that needs to access the image in the container. |
248+
249+
The project environment type displays like the following example:
250+
251+
:::image type="content" source="media/how-to-configure-extensibility-terraform-container-image/container-registry-access-control-pet.png" alt-text="Screenshot of the Select members pane, showing a list of project environment types with part of the name highlighted.":::
252+
253+
In this configuration, ADE uses the Managed Identity for the PET, whether system assigned or user assigned.
254+
255+
> [!Tip]
256+
> This role assignment has to be made for every project environment type. It can be automated through the Azure CLI.
257+
When you're ready to push your image to your registry, run the following command:
258+
259+
```docker
260+
docker push {YOUR_REGISTRY}.azurecr.io/{YOUR_IMAGE_LOCATION}:{YOUR_TAG}
261+
```
262+
202263
## [Build a container image with a script](#tab/build-a-container-image-with-a-script/)
203264

204265
[!INCLUDE [custom-image-script](includes/custom-image-script.md)]
Loading
Loading
Loading

0 commit comments

Comments
 (0)