Skip to content

Commit 6158da0

Browse files
committed
Interim checkin
1 parent d90fedc commit 6158da0

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
title: 'Quickstart: Create an Azure CDN profile and endpoint using Terraform'
3+
description: 'In this article, you create an Azure CDN profile and endpoint using Terraform'
4+
services: cdn
5+
ms.service: azure-cdn
6+
ms.topic: quickstart
7+
ms.date: 3/28/2023
8+
ms.custom: devx-track-terraform
9+
author: TomArcherMsft
10+
ms.author: tarcher
11+
ms.service: cdn
12+
---
13+
14+
# Quickstart: Create an Azure CDN profile and endpoint using Terraform
15+
16+
This article shows how to use Terraform to create an [Azure CDN profile and endpoint](/azure/cdn/cdn-overview) using [Terraform](/azure/developer/terraform/quickstart-configure).
17+
18+
[!INCLUDE [Terraform abstract](~/azure-dev-docs-pr/articles/terraform/includes/abstract.md)]
19+
20+
In this article, you learn how to:
21+
22+
> [!div class="checklist"]
23+
> * Create a random pet name for the Azure resource group name using [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet)
24+
> * Create an Azure resource group using [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group)
25+
> * Create a random string using [random_string](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string)
26+
> * Create an Azure CDN profile using [azurerm_cdn_profile](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cdn_profile)
27+
> * Create an Azure CDN endpoint using [azurerm_cdn_endpoint](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cdn_endpoint)
28+
29+
[!INCLUDE [AI attribution](../../includes/ai-generated-attribution.md)]
30+
31+
## Prerequisites
32+
33+
- [Install and configure Terraform](/azure/developer/terraform/quickstart-configure)
34+
35+
## Implement the Terraform code
36+
37+
> [!NOTE]
38+
> The sample code for this article is located in the [Azure Terraform GitHub repo](https://github.com/Azure/terraform/tree/master/quickstart/101-azure-cdn). You can view the log file containing the [test results from current and previous versions of Terraform](https://github.com/Azure/terraform/blob/master/quickstart/101-azure-cdn/TestRecord.md).
39+
>
40+
> See more [articles and sample code showing how to use Terraform to manage Azure resources](/azure/terraform)
41+
42+
1. Create a directory in which to test and run the sample Terraform code and make it the current directory.
43+
44+
1. Create a file named `main.tf` and insert the following code:
45+
46+
[!code-terraform[master](~/terraform_samples/quickstart/101-azure-cdn/main.tf)]
47+
48+
1. Create a file named `outputs.tf` and insert the following code:
49+
50+
[!code-terraform[master](~/terraform_samples/quickstart/101-azure-cdn/outputs.tf)]
51+
52+
1. Create a file named `providers.tf` and insert the following code:
53+
54+
[!code-terraform[master](~/terraform_samples/quickstart/101-azure-cdn/providers.tf)]
55+
56+
1. Create a file named `variables.tf` and insert the following code:
57+
58+
[!code-terraform[master](~/terraform_samples/quickstart/101-azure-cdn/variables.tf)]
59+
60+
## Initialize Terraform
61+
62+
[!INCLUDE [terraform-init.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-init.md)]
63+
64+
## Create a Terraform execution plan
65+
66+
[!INCLUDE [terraform-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan.md)]
67+
68+
## Apply a Terraform execution plan
69+
70+
[!INCLUDE [terraform-apply-plan.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-apply-plan.md)]
71+
72+
## Verify the results
73+
74+
#### [Azure CLI](#tab/azure-cli)
75+
76+
1. Get the Azure resource group name in which the Azure CDN profile and endpoint were created.
77+
78+
```console
79+
resource_group_name=$(terraform output -raw resource_group_name)
80+
```
81+
82+
1. Get the CDN profile name.
83+
84+
```console
85+
cdn_profile_name=$(terraform output -raw cdn_profile_name)
86+
```
87+
88+
1. Get the CDN endpoint name.
89+
90+
```console
91+
cdn_endpoint_endpoint_name=$(terraform output -raw cdn_endpoint_endpoint_name)
92+
```
93+
94+
1. Run [az cdn custom-domain show](/cli/azure/cdn/custom-domain#az-cdn-custom-domain-show) to show details of the custom domain you created in this article.
95+
96+
```azurecli
97+
az cdn endpoint show --name $cdn_endpoint_endpoint_name \
98+
--profile-name $cdn_profile_name \
99+
--resource-group $resource_group_name
100+
```
101+
102+
#### [Azure PowerShell](#tab/azure-powershell)
103+
104+
---
105+
106+
## Clean up resources
107+
108+
[!INCLUDE [terraform-plan-destroy.md](~/azure-dev-docs-pr/articles/terraform/includes/terraform-plan-destroy.md)]
109+
110+
## Troubleshoot Terraform on Azure
111+
112+
[Troubleshoot common problems when using Terraform on Azure](/azure/developer/terraform/troubleshoot)
113+
114+
## Next steps
115+
116+
> [!div class="nextstepaction"]
117+
> [Create an Azure CDN profile and endpoint using the Azure portal](/azure/cdn/cdn-create-endpoint)

0 commit comments

Comments
 (0)