Skip to content

Commit 7d88212

Browse files
committed
Quickstart using Terraform
1 parent 6158da0 commit 7d88212

File tree

2 files changed

+39
-10
lines changed

2 files changed

+39
-10
lines changed

articles/cdn/create-profile-endpoint-terraform.md

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
22
title: 'Quickstart: Create an Azure CDN profile and endpoint using Terraform'
3+
titleSuffix: Azure Content Delivery Network
34
description: 'In this article, you create an Azure CDN profile and endpoint using Terraform'
45
services: cdn
56
ms.service: azure-cdn
67
ms.topic: quickstart
7-
ms.date: 3/28/2023
8+
ms.date: 4/12/2023
89
ms.custom: devx-track-terraform
910
author: TomArcherMsft
1011
ms.author: tarcher
@@ -22,7 +23,7 @@ In this article, you learn how to:
2223
> [!div class="checklist"]
2324
> * 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)
2425
> * 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 a random string for the CDN endpoint name using [random_string](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string)
2627
> * Create an Azure CDN profile using [azurerm_cdn_profile](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cdn_profile)
2728
> * Create an Azure CDN endpoint using [azurerm_cdn_endpoint](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cdn_endpoint)
2829
@@ -35,27 +36,27 @@ In this article, you learn how to:
3536
## Implement the Terraform code
3637

3738
> [!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+
> The sample code for this article is located in the [Azure Terraform GitHub repo](https://github.com/Azure/terraform/tree/master/quickstart/101-cdn-with-custom-origin). 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-cdn-with-custom-origin/TestRecord.md).
3940
>
4041
> See more [articles and sample code showing how to use Terraform to manage Azure resources](/azure/terraform)
4142
4243
1. Create a directory in which to test and run the sample Terraform code and make it the current directory.
4344

4445
1. Create a file named `main.tf` and insert the following code:
4546

46-
[!code-terraform[master](~/terraform_samples/quickstart/101-azure-cdn/main.tf)]
47+
[!code-terraform[master](~/terraform_samples/quickstart/101-cdn-with-custom-origin/main.tf)]
4748

4849
1. Create a file named `outputs.tf` and insert the following code:
4950

50-
[!code-terraform[master](~/terraform_samples/quickstart/101-azure-cdn/outputs.tf)]
51+
[!code-terraform[master](~/terraform_samples/quickstart/101-cdn-with-custom-origin/outputs.tf)]
5152

5253
1. Create a file named `providers.tf` and insert the following code:
5354

54-
[!code-terraform[master](~/terraform_samples/quickstart/101-azure-cdn/providers.tf)]
55+
[!code-terraform[master](~/terraform_samples/quickstart/101-cdn-with-custom-origin/providers.tf)]
5556

5657
1. Create a file named `variables.tf` and insert the following code:
5758

58-
[!code-terraform[master](~/terraform_samples/quickstart/101-azure-cdn/variables.tf)]
59+
[!code-terraform[master](~/terraform_samples/quickstart/101-cdn-with-custom-origin/variables.tf)]
5960

6061
## Initialize Terraform
6162

@@ -94,13 +95,39 @@ In this article, you learn how to:
9495
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.
9596

9697
```azurecli
97-
az cdn endpoint show --name $cdn_endpoint_endpoint_name \
98+
az cdn endpoint show --resource-group $resource_group_name \
9899
--profile-name $cdn_profile_name \
99-
--resource-group $resource_group_name
100-
```
100+
--name $cdn_endpoint_endpoint_name
101+
```
101102

102103
#### [Azure PowerShell](#tab/azure-powershell)
103104

105+
1. Get the Azure resource group name in which the Azure CDN profile and endpoint were created.
106+
107+
```console
108+
$resource_group_name=$(terraform output -raw resource_group_name)
109+
```
110+
111+
1. Get the CDN profile name.
112+
113+
```console
114+
$cdn_profile_name=$(terraform output -raw cdn_profile_name)
115+
```
116+
117+
1. Get the CDN endpoint name.
118+
119+
```console
120+
$cdn_endpoint_endpoint_name=$(terraform output -raw cdn_endpoint_endpoint_name)
121+
```
122+
123+
1. Run [Get-AzCdnEndpoint](/powershell/module/az.cdn/get-azcdnendpoint) to show details of the custom domain you created in this article.
124+
125+
```console
126+
Get-AzCdnEndpoint -ResourceGroupName $resource_group_name `
127+
-ProfileName $cdn_profile_name `
128+
-Name $cdn_endpoint_endpoint_name
129+
```
130+
104131
---
105132

106133
## Clean up resources

articles/frontdoor/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
- name: Create profile and endpoint - ARM Template
7171
displayName: Resource Manager
7272
href: ../cdn/create-profile-endpoint-template.md?toc=/azure/frontdoor/TOC.json
73+
- name: Create profile and endpoint - Terraform
74+
href: ../cdn/create-profile-endpoint-terraform.md?toc=/azure/frontdoor/TOC.json
7375
- name: Tutorials
7476
items:
7577
- name: Front Door

0 commit comments

Comments
 (0)