Skip to content

Commit 70802c1

Browse files
authored
Merge pull request #89231 from TomArcherMsft/terraform-code-fences
Terraform - Change code fencing
2 parents 368ce2c + 6646fae commit 70802c1

24 files changed

+136
-130
lines changed

articles/terraform/index.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ metadata:
1111
ms.topic: landing-page
1212
author: TomArcherMsft
1313
ms.author: tarcher
14-
ms.date: 09/12/2019
14+
ms.date: 09/20/2019
1515

1616
landingContent:
1717
# Card

articles/terraform/terrafom-quickstart.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services: terraform
55
author: neilpeterson
66
ms.service: azure
77
ms.topic: quickstart
8-
ms.date: 02/04/2019
8+
ms.date: 09/20/2019
99
ms.author: nepeters
1010
---
1111

@@ -19,7 +19,7 @@ In this section, you will create the configuration for an Azure Cosmos DB instan
1919

2020
Select **try it now** to open up Azure cloud shell. Once open, enter in `code .` to open the cloud shell code editor.
2121

22-
```azurecli-interactive
22+
```bash
2323
code .
2424
```
2525

@@ -29,7 +29,7 @@ This configuration models an Azure resource group, a random integer, and an Azur
2929

3030
Save the file as `main.tf` when done. This operation can be done using the ellipses in the upper right-hand portion of the code editor.
3131

32-
```azurecli-interactive
32+
```hcl
3333
resource "azurerm_resource_group" "vote-resource-group" {
3434
name = "vote-resource-group"
3535
location = "westus"
@@ -62,21 +62,21 @@ resource "azurerm_cosmosdb_account" "vote-cosmos-db" {
6262

6363
The [terraform init](https://www.terraform.io/docs/commands/init.html) command initializes the working directory. Run `terraform init` in the cloud shell terminal to prepare for the deployment of the new configuration.
6464

65-
```azurecli-interactive
65+
```bash
6666
terraform init
6767
```
6868

6969
The [terraform plan](https://www.terraform.io/docs/commands/plan.html) command can be used to validate that the configuration is properly formatted and to visualize what resources will be created, updated, or destroyed. The results can be stored in a file and used at a later time to apply the configuration.
7070

7171
Run `terraform plan` to test the new Terraform configuration.
7272

73-
```azurecli-interactive
73+
```bash
7474
terraform plan --out plan.out
7575
```
7676

7777
Apply the configuration using [terraform apply](https://www.terraform.io/docs/commands/apply.html) and specifying the name of the plan file. This command deploys the resources in your Azure subscription.
7878

79-
```azurecli-interactive
79+
```bash
8080
terraform apply plan.out
8181
```
8282

@@ -93,7 +93,7 @@ Two environment variables are set, `COSMOS_DB_ENDPOINT` and `COSMOS_DB_MASTERKEY
9393

9494
The configuration also includes an output block, which returns the fully qualified domain name (FQDN) of the container instance.
9595

96-
```azurecli-interactive
96+
```hcl
9797
resource "azurerm_container_group" "vote-aci" {
9898
name = "vote-aci"
9999
location = "${azurerm_resource_group.vote-resource-group.location}"
@@ -129,13 +129,13 @@ output "dns" {
129129

130130
Run `terraform plan` to create the updated plan and visualize the changes to be made. You should see that an Azure Container Instance resource has been added to the configuration.
131131

132-
```azurecli-interactive
132+
```bash
133133
terraform plan --out plan.out
134134
```
135135

136136
Finally, run `terraform apply` to apply the configuration.
137137

138-
```azurecli-interactive
138+
```bash
139139
terraform apply plan.out
140140
```
141141

@@ -151,7 +151,7 @@ Navigate to the FQDN of the container instance. If everything was correctly conf
151151

152152
When done, the Azure resources and resource group can be removed using the [terraform destroy](https://www.terraform.io/docs/commands/destroy.html) command.
153153

154-
```azurecli-interactive
154+
```bash
155155
terraform destroy -auto-approve
156156
```
157157

articles/terraform/terraform-backend.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services: terraform
55
author: tomarchermsft
66
ms.service: azure
77
ms.topic: article
8-
ms.date: 09/13/2018
8+
ms.date: 09/20/2019
99
ms.author: tarcher
1010
---
1111

@@ -23,7 +23,7 @@ Terraform includes the concept of a state backend, which is remote storage for T
2323

2424
Before using Azure Storage as a backend, a storage account must be created. The storage account can be created with the Azure portal, PowerShell, the Azure CLI, or Terraform itself. Use the following sample to configure the storage account with the Azure CLI.
2525

26-
```azurecli-interactive
26+
```azurecli
2727
#!/bin/bash
2828
2929
RESOURCE_GROUP_NAME=tstate
@@ -62,21 +62,21 @@ Each of these values can be specified in the Terraform configuration file or on
6262

6363
Create an environment variable named `ARM_ACCESS_KEY` with the value of the Azure Storage access key.
6464

65-
```console
65+
```bash
6666
export ARM_ACCESS_KEY=<storage access key>
6767
```
6868

6969
To further protect the Azure Storage account access key, store it in Azure Key Vault. The environment variable can then be set using a command similar to the following. For more information on Azure Key Vault, see the [Azure Key Vault documentation][azure-key-vault].
7070

71-
```console
71+
```bash
7272
export ARM_ACCESS_KEY=$(az keyvault secret show --name terraform-backend-key --vault-name myKeyVault --query value -o tsv)
7373
```
7474

7575
To configure Terraform to use the backend, include a *backend* configuration with a type of *azurerm* inside of the Terraform configuration. Add the *storage_account_name*, *container_name*, and *key* values to the configuration block.
7676

7777
The following example configures a Terraform backend and creates an Azure resource group. Replace the values with values from your environment.
7878

79-
```json
79+
```hcl
8080
terraform {
8181
backend "azurerm" {
8282
storage_account_name = "tstate09762"

articles/terraform/terraform-cloud-shell.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ author: tomarchermsft
88
manager: jeconnoc
99
ms.author: tarcher
1010
ms.topic: tutorial
11-
ms.date: 10/19/2017
11+
ms.date: 09/20/2019
1212
---
1313

1414
# Terraform Cloud Shell development
@@ -28,7 +28,7 @@ Terraform is installed and immediately available in Cloud Shell. Terraform scrip
2828

2929
Azure Terraform modules require credentials to access and make changes to the resources in your Azure subscription. When working in the Cloud Shell, add the following code to your scripts to use Azure Terraform modules in the Cloud Shell:
3030

31-
```tf
31+
```hcl
3232
# Configure the Microsoft Azure Provider
3333
provider "azurerm" {
3434
}

articles/terraform/terraform-create-k8s-cluster-with-aks-applicationgateway-ingress.md

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ author: tomarcher
88
manager: jeconnoc
99
ms.author: tarcher
1010
ms.topic: tutorial
11-
ms.date: 1/10/2019
11+
ms.date: 09/20/2019
1212
---
1313

1414
# Create a Kubernetes cluster with Application Gateway ingress controller using Azure Kubernetes Service and Terraform
@@ -33,7 +33,7 @@ In this tutorial, you learn how to perform the following tasks in creating a [Ku
3333
- **Azure service principal**: Follow the directions in the section of the **Create the service principal** section in the article, [Create an Azure service principal with Azure CLI](/cli/azure/create-an-azure-service-principal-azure-cli?view=azure-cli-latest). Take note of the values for the appId, displayName, and password.
3434
- Note the Object ID of the Service Principal by running the following command
3535

36-
```bash
36+
```azurecli
3737
az ad sp list --display-name <displayName>
3838
```
3939
@@ -77,7 +77,7 @@ Create the Terraform configuration file that declares the Azure provider.
7777
7878
1. Paste the following code into the editor:
7979
80-
```JSON
80+
```hcl
8181
provider "azurerm" {
8282
version = "~>1.18"
8383
}
@@ -94,17 +94,21 @@ Create the Terraform configuration file that declares the Azure provider.
9494
```bash
9595
:wq
9696
```
97-
## Define input variables
98-
Create the Terraform configuration file that lists all the variables required for this deployment
99-
1. In Cloud Shell, create a file named `variables.tf`
97+
98+
## Define input variables
99+
Create the Terraform configuration file that lists all the variables required for this deployment.
100+
101+
1. In Cloud Shell, create a file named `variables.tf`.
102+
100103
```bash
101104
vi variables.tf
102105
```
106+
103107
1. Enter insert mode by selecting the I key.
104108
105-
2. Paste the following code into the editor:
109+
1. Paste the following code into the editor:
106110
107-
```JSON
111+
```hcl
108112
variable "resource_group_name" {
109113
description = "Name of the resource group already created."
110114
}
@@ -249,9 +253,9 @@ Create Terraform configuration file that creates all the resources.
249253
250254
1. Paste the following code blocks into the editor:
251255
252-
a. Create a locals block for computed variables to reuse
256+
a. Create a locals block for computed variables to reuse.
253257
254-
```JSON
258+
```hcl
255259
# # Locals block for hardcoded names.
256260
locals {
257261
backend_address_pool_name = "${azurerm_virtual_network.test.name}-beap"
@@ -263,8 +267,10 @@ Create Terraform configuration file that creates all the resources.
263267
app_gateway_subnet_name = "appgwsubnet"
264268
}
265269
```
266-
b. Create a data source for Resource group, new User identity
267-
```JSON
270+
271+
b. Create a data source for Resource group, new User identity.
272+
273+
```hcl
268274
data "azurerm_resource_group" "rg" {
269275
name = "${var.resource_group_name}"
270276
}
@@ -279,8 +285,10 @@ Create Terraform configuration file that creates all the resources.
279285
tags = "${var.tags}"
280286
}
281287
```
282-
c. Create base networking resources
283-
```JSON
288+
289+
c. Create base networking resources.
290+
291+
```hcl
284292
resource "azurerm_virtual_network" "test" {
285293
name = "${var.virtual_network_name}"
286294
location = "${data.azurerm_resource_group.rg.location}"
@@ -323,8 +331,10 @@ Create Terraform configuration file that creates all the resources.
323331
tags = "${var.tags}"
324332
}
325333
```
326-
d. Create Application Gateway resource
327-
```JSON
334+
335+
d. Create Application Gateway resource.
336+
337+
```hcl
328338
resource "azurerm_application_gateway" "network" {
329339
name = "${var.app_gateway_name}"
330340
resource_group_name = "${data.azurerm_resource_group.rg.name}"
@@ -388,8 +398,10 @@ Create Terraform configuration file that creates all the resources.
388398
depends_on = ["azurerm_virtual_network.test", "azurerm_public_ip.test"]
389399
}
390400
```
391-
e. Create role assignments
392-
```JSON
401+
402+
e. Create role assignments.
403+
404+
```hcl
393405
resource "azurerm_role_assignment" "ra1" {
394406
scope = "${data.azurerm_subnet.kubesubnet.id}"
395407
role_definition_name = "Network Contributor"
@@ -419,8 +431,10 @@ Create Terraform configuration file that creates all the resources.
419431
depends_on = ["azurerm_user_assigned_identity.testIdentity", "azurerm_application_gateway.network"]
420432
}
421433
```
422-
f. Create the Kubernetes cluster
423-
```JSON
434+
435+
f. Create the Kubernetes cluster.
436+
437+
```hcl
424438
resource "azurerm_kubernetes_cluster" "k8s" {
425439
name = "${var.aks_name}"
426440
location = "${data.azurerm_resource_group.rg.location}"
@@ -497,7 +511,7 @@ Create Terraform configuration file that creates all the resources.
497511
498512
1. Paste the following code into the editor:
499513
500-
```JSON
514+
```hcl
501515
output "client_key" {
502516
value = "${azurerm_kubernetes_cluster.k8s.kube_config.0.client_key}"
503517
}
@@ -554,7 +568,7 @@ Terraform tracks state locally via the `terraform.tfstate` file. This pattern wo
554568
555569
1. In Cloud Shell, create a container in your Azure storage account (replace the &lt;YourAzureStorageAccountName> and &lt;YourAzureStorageAccountAccessKey> placeholders with the appropriate values for your Azure storage account).
556570
557-
```bash
571+
```azurecli
558572
az storage container create -n tfstate --account-name <YourAzureStorageAccountName> --account-key <YourAzureStorageAccountKey>
559573
```
560574
@@ -582,7 +596,7 @@ In this section, you see how to use the `terraform init` command to create the r
582596
583597
1. Paste the following variables created earlier into the editor:
584598
585-
```JSON
599+
```hcl
586600
resource_group_name = <Name of the Resource Group already created>
587601
588602
location = <Location of the Resource Group>

articles/terraform/terraform-create-k8s-cluster-with-tf-and-aks.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ author: tomarchermsft
88
manager: jeconnoc
99
ms.author: tarcher
1010
ms.topic: tutorial
11-
ms.date: 12/04/2018
11+
ms.date: 09/20/2019
1212
---
1313

1414
# Create a Kubernetes cluster with Azure Kubernetes Service and Terraform
@@ -69,7 +69,7 @@ Create the Terraform configuration file that declares the Azure provider.
6969

7070
1. Paste the following code into the editor:
7171

72-
```JSON
72+
```hcl
7373
provider "azurerm" {
7474
version = "~>1.5"
7575
}
@@ -100,7 +100,7 @@ Create the Terraform configuration file that declares the resources for the Kube
100100

101101
1. Paste the following code into the editor:
102102

103-
```JSON
103+
```hcl
104104
resource "azurerm_resource_group" "k8s" {
105105
name = "${var.resource_group_name}"
106106
location = "${var.location}"
@@ -197,7 +197,7 @@ Create the Terraform configuration file that declares the resources for the Kube
197197

198198
1. Paste the following code into the editor:
199199

200-
```JSON
200+
```hcl
201201
variable "client_id" {}
202202
variable "client_secret" {}
203203
@@ -261,7 +261,7 @@ Create the Terraform configuration file that declares the resources for the Kube
261261

262262
1. Paste the following code into the editor:
263263

264-
```JSON
264+
```hcl
265265
output "client_key" {
266266
value = "${azurerm_kubernetes_cluster.k8s.kube_config.0.client_key}"
267267
}
@@ -318,7 +318,7 @@ Terraform tracks state locally via the `terraform.tfstate` file. This pattern wo
318318

319319
1. In Cloud Shell, create a container in your Azure storage account (replace the &lt;YourAzureStorageAccountName> and &lt;YourAzureStorageAccountAccessKey> placeholders with the appropriate values for your Azure storage account).
320320

321-
```bash
321+
```azurecli
322322
az storage container create -n tfstate --account-name <YourAzureStorageAccountName> --account-key <YourAzureStorageAccountKey>
323323
```
324324

articles/terraform/terraform-create-vm-cluster-module.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ author: tomarchermsft
88
manager: jeconnoc
99
ms.author: tarcher
1010
ms.topic: tutorial
11-
ms.date: 10/19/2017
11+
ms.date: 09/20/2019
1212
---
1313

1414
# Create a VM cluster with Terraform using the Module Registry
@@ -30,7 +30,7 @@ For more information on Terraform, see the [Terraform documentation](https://www
3030
3131
Review [Install Terraform and configure access to Azure](/azure/virtual-machines/linux/terraform-install-configure) to create an Azure service principal. Use this service principal to populate a new file `azureProviderAndCreds.tf` in an empty directory with the following code:
3232

33-
```tf
33+
```hcl
3434
variable subscription_id {}
3535
variable tenant_id {}
3636
variable client_id {}
@@ -48,7 +48,7 @@ provider "azurerm" {
4848

4949
Create a new Terraform template named `main.tf` with the following code:
5050

51-
```tf
51+
```hcl
5252
module mycompute {
5353
source = "Azure/compute/azurerm"
5454
resource_group_name = "myResourceGroup"

0 commit comments

Comments
 (0)