Skip to content

Commit d044b6e

Browse files
committed
fix some numbering
1 parent 39e44f6 commit d044b6e

10 files changed

+81
-59
lines changed

terraform_fundmentals/03-virtual_machine.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,5 @@ resource "azurerm_virtual_machine" "training" {
5454
```
5555

5656
### 2. Run `terraform plan` to view the resources that will be created
57+
5758
### 3. Run `terraform apply` to create the resources specified

terraform_fundmentals/11-meta-arguments.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ So far, we've already used arguments to configure your resources. These argument
1212

1313
We are going to reuse the configuration in the `azure` directory from the exercises `02-basic-configuration` and `03-virtual_machine`. If you don't have those configurations, they are in the appendix of this lab.
1414

15-
Add a count argument to the Azure Virtual Machine resource in `main.tf` with a value of 2. Also adjust the value of `name` to incrementally add a number to the end of each instances name:
15+
Add a count argument to the Azure Virtual Machine resource in `main.tf` with a value of 2. Also adjust the value of `name` to incrementally add a number to the end of each instances name:
1616

1717
```hcl
1818
# ...
@@ -62,7 +62,7 @@ resource "azurerm_network_interface" "training" {
6262

6363
## Task 2: Modify the rest of the configuration to support multiple instances
6464

65-
### Step 8.2.1
65+
### Step 2.1
6666

6767
If you run `terraform apply` now, you'll get an error. Since we added _count_ to the azure_virtual_machine.training resource, it now refers to multiple resources. Because of this, values like our public_dns output no longer refer to the "public dns" of a single resource. We need to tell terraform which resource we're referring to.
6868

@@ -74,9 +74,9 @@ output "public_dns" {
7474
}
7575
```
7676

77-
The syntax `azurerm_public_ip.training[*]...` refers to all of the instances, so this will output a list of all dns entries.
77+
The syntax `azurerm_public_ip.training[*]...` refers to all of the instances, so this will output a list of all dns entries.
7878

79-
### Step 8.2.2
79+
### Step 2.2
8080

8181
Run `terraform apply` to add the new instance. You will notice that because we changed the name of the Azure Virtual Mahine, that there will be a forced replacement of our previous virutal machine.
8282

@@ -92,7 +92,7 @@ Plan: 2 to add, 0 to change, 1 to destroy.
9292

9393
## Task 3: Add variable interpolation to the count argument
9494

95-
### Step 8.3.1
95+
### Step 3.1
9696

9797
Update `variables.tf` to add a new variable definition, and use it:
9898

@@ -130,7 +130,7 @@ Remember to also add the variable declaration to your `terraform.tfvars` accordi
130130
num_vms = 2
131131
```
132132

133-
### Step 8.3.2
133+
### Step 3.2
134134

135135
Run `terraform apply` in the terraform directory. No changes should be detected as the _values_ have not changed:
136136

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Lab: Azure Authentication
2+
3+
Duration: 5 minutes
4+
5+
In this lab, you will explore how Terraform is authenticating to Azure.
6+
7+
- Task 1: View the current environment variables
8+
9+
## Task 1: View the current environment variables
10+
11+
From the terminal of you lab environment, run the following command to view the current environment variables:
12+
13+
```bash
14+
env | grep ARM
15+
```
16+
17+
You should see environment variables for the Azure subscription ID, tenant ID, client ID, and client secret.
18+
19+
From the cloud credentials tab, you can confirm that the values line up to what was provisioned for you.
20+
21+
## Bonus Task: Override the environment variables
22+
23+
You can also set the Azure authentication values directly in the provider block. Although this isn't recommended, it can be useful for testing. Add the necessary arguments in the `azurerm` provider block and use input variables to set the values.

terraform_fundmentals/14-data_source.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,4 @@ Apply the updated configuration:
161161

162162
```bash
163163
terraform apply
164-
```
164+
```

terraform_fundmentals/15-reading_state.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Lab 12: State
1+
# Lab: State
22

33
Duration: 10 minutes
44

@@ -7,15 +7,11 @@ This lab demonstrates how to read state from another Terraform project. It uses
77
- Task 1: Create a Terraform configuration that defines an output
88
- Task 2: Read an output value from that project's state
99

10-
## Prerequisites
11-
12-
This lab only requires a copy of [Terraform](https://www.terraform.io/downloads.html). It doesn't require any cloud provider credentials.
13-
1410
## Task 1: Create a Terraform configuration that defines an output
1511

1612
For this task, you'll create two Terraform configurations in two separate directories. One will read from the other (using state files).
1713

18-
### Step 1.1.1
14+
### Step 1.1
1915

2016
In this step, you'll create a Terraform project on disk that does nothing but emit an output. It should emit `public_ip` which can be a hard-coded value (for simplicity).
2117

@@ -38,7 +34,7 @@ output "public_ip" {
3834
}
3935
```
4036

41-
### Step 1.1.2
37+
### Step 1.2
4238

4339
Generate a state file for the project. Within that project, run `terraform init` and `apply`. You should see a `terraform.tfstate` file after running these commands.
4440

@@ -54,7 +50,7 @@ terraform apply
5450

5551
## Task 2: Read an output value from that project's state
5652

57-
### Step 1.2.1
53+
### Step 2.1
5854

5955
Create a new Terraform configuration that uses a data source to read the configuration from the `primary` project.
6056

@@ -87,7 +83,7 @@ Initialize the secondary project with `init`.
8783
terraform init
8884
```
8985

90-
### Step 1.2.2
86+
### Step 2.2
9187

9288
Declare the `public_ip` as an `output`.
9389

terraform_fundmentals/17-store-state.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ You'll setup a new project using Terraform Cloud as your backed and use a second
1111

1212
## Task 1: Sign up for Terraform Cloud
1313

14-
1. Navigate to [the sign up page](https://app.terraform.io/signup) and create an account for Terraform Cloud. If you already have a TFC account
14+
1. Navigate to [the sign up page](https://app.terraform.io/signup) and create an account for Terraform Cloud and an organization called `###-tfc-demo-2023` where `###` is your initials. If you already have an account, just create the organization.
1515

1616
1. Perform a `terraform login` from your workstation
1717

@@ -40,7 +40,7 @@ Open the following URL to access the tokens page for app.terraform.io:
4040
---------------------------------------------------------------------------------
4141
```
4242

43-
1. If the token was entered succesfully you should see the following:
43+
1. If the token was entered successfully you should see the following:
4444

4545
```bash
4646

@@ -79,23 +79,23 @@ Retrieved token for user tfcuser
7979

8080
For this task, you'll create a Terraform project which stores its state in Terraform Cloud and emits an output.
8181

82-
### Step 2.2.1
82+
### Step 2.1
8383

8484
In this step, you'll create the project and a configuration.
8585

86-
```shell
86+
```bash
8787
mkdir -p ~/workstation/terraform/azure/cloud_state_demo/write_state && cd $_
8888
touch main.tf
8989
```
9090

91-
### Step 2.2.2
91+
### Step 2.2
9292

9393
Setup the configuration to utilize the `remote` backend, replacing `ORGANIZATION NAME` with the name of your organization and ```###``` with your initials.
9494

9595
```hcl
9696
# write_state/main.tf
9797
terraform {
98-
backend "remote" {
98+
cloud {
9999
organization = "<ORGANIZATION NAME>"
100100
101101
workspaces {
@@ -105,7 +105,7 @@ terraform {
105105
}
106106
```
107107

108-
### Step 2.2.3
108+
### Step 2.3
109109

110110
Next, add the ability to generate and emit a `random` output from your configuration:
111111

@@ -124,7 +124,7 @@ output "random" {
124124
}
125125
```
126126

127-
### Step 2.2.4
127+
### Step 2.4
128128

129129
Provision the resource and push the state to Terraform Cloud with:
130130

@@ -136,11 +136,10 @@ terraform apply -auto-approve
136136
You'll see Terraform confirm it is creating your state remotely as well as your `random` output.
137137
If you navigate back to your organization, you will also see a new workspace name `###_write_state`.
138138

139-
### Step 2.2.5
139+
### Step 2.5
140+
141+
Congratulations! You're now storing state remotely. With Terraform Cloud you are able to share your workspace with teammates.
140142

141-
Congratulations!
142-
You're now storing state remotely.
143-
With Terraform Cloud you are able to share your workspace with teammates.
144143
Back in the Terraform Cloud UI you'll be able to:
145144

146145
* View all your organization's workspaces
@@ -151,7 +150,7 @@ Back in the Terraform Cloud UI you'll be able to:
151150

152151
Now that we have our state stored in Terraform Cloud in our `###_write_state` workspace, we will create another project, configuration, and workspace to read from it.
153152

154-
### Step 2.3.1
153+
### Step 3.1
155154

156155
Start by creating a new directory and `main.tf` file:
157156

@@ -160,15 +159,15 @@ mkdir -p ~/workstation/terraform/azure/cloud_state_demo/read_state && cd $_
160159
touch main.tf
161160
```
162161

163-
### Step 2.3.2
162+
### Step 3.2
164163

165164
Just as we did in Step 2.2.2, we need to setup our configuration to use the `remote` backend, once again replacing `ORGANIZATION NAME`.
166165
We will also create a new `random` resource to compare against:
167166

168167
```hcl
169168
# read_state/main.tf
170169
terraform {
171-
backend "remote" {
170+
cloud {
172171
organization = "<ORGANIZATION NAME>"
173172
174173
workspaces {
@@ -186,11 +185,12 @@ resource "random_id" "random" {
186185
}
187186
```
188187

189-
### Step 2.3.3
188+
### Step 3.3
190189

191190
In order to read from our `###_write_state` workspace, we will need to setup a `terraform_remote_state` data source.
192191
Data sources are used to retrieve read-only data from sources outside of our project.
193-
It supports several cloud providers, but we'll be using `remote` as the `backend`.
192+
193+
It supports several cloud providers, but we'll be using `remote` as the `backend`. That is the name of the Terraform Cloud backend.
194194

195195
```hcl
196196
# read_state/main.tf
@@ -211,7 +211,7 @@ In addition to creating the `terraform_remote_state` data source in your configu
211211

212212
From the Terraform Cloud UI, go to the `###_write_state` workspace, and select *Settings->General*. Under the *Remote state sharing* section change the radio button to **Share with all workspaces in this organization**, then click on *Save settings* at the bottom of the page.
213213

214-
### Step 2.3.4
214+
### Step 3.4
215215

216216
Now that we have access to our remote `###_write_state` workspace, we can retrieve the `random` output contained within it.
217217
We'll also output `random` which we created in this configuration, confirming that they are distinct.
@@ -227,7 +227,7 @@ output "write_state_random" {
227227
}
228228
```
229229

230-
### Step 2.3.5
230+
### Step 3.5
231231

232232
To verify that we have successfully retrieved the state from out `###_write_state` workspace, we can run our configuration and validate our outputs.
233233

terraform_fundmentals/18-secure_variables.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ terraform {
2828
}
2929
}
3030
31-
backend "remote" {
31+
cloud {
3232
organization = "YOUR_ORGANIZATION_NAME"
3333
3434
workspaces {
@@ -78,7 +78,7 @@ resource "azurerm_subnet" "training" {
7878

7979
## Task 2: Login to TFC and initialize the configuration
8080

81-
Log into your TFC account:
81+
Log into your TFC account (this is only necessary once per sandbox, you can skip this step if you've already logged into Terraform Cloud):
8282

8383
```bash
8484
terraform login
@@ -122,4 +122,4 @@ Approve the apply from the Terraform Cloud UI and view the state data when the r
122122

123123
## Task 5: (BONUS) Change the prefix
124124

125-
If you're feeling like a little bonus content, try changing the `prefix` variable value and running a plan directly from the UI.
125+
If you're feeling like a little bonus content, try changing the `prefix` variable value and running a plan directly from the UI.

terraform_fundmentals/19-lifecycles.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This lab demonstrates how to use lifecycle directives to control the order in wh
77
- Task 1: Use `create_before_destroy` with an instance rename
88
- Task 2: Use `prevent_destroy` with an instance
99

10-
### Create the base Terraform Configuration
10+
## Create the base Terraform Configuration
1111

1212
Change directory into a folder specific to this challenge, and create a `main.tf` and `terraform.tfvars` files to hold our configuration.
1313

@@ -23,7 +23,7 @@ We will start with a few of the basic resources needed.
2323

2424
When you rename a Azure Virtual Machine, terraform will reprovision the resource (delete and then create a new instance). We can leverage `create_before_destroy` to override that default behavior
2525

26-
### Step 6.1.1: Deploy your Azure Virtual Machine
26+
### Step 1.1: Deploy your Azure Virtual Machine
2727

2828
Place the following configuration in your `main.tf` file to deploy your virtual machine.
2929

@@ -136,7 +136,7 @@ vm_size = "Standard_A2_v2"
136136
- Run a `terraform plan`
137137
- Run a `terraform apply`
138138

139-
### Step 6.1.2: Rename your Azure Virtual Machine
139+
### Step 1.2: Rename your Azure Virtual Machine
140140

141141
Edit your `main.tf` file and add the suffix _renamed_ to the value for `name` as shown below:
142142

@@ -170,7 +170,7 @@ Terraform will perform the following actions:
170170

171171
Answer `yes` to proceed with the replacement of the instances.
172172

173-
### Step 6.1.3: Use `create_before_destroy` and rename the instances again
173+
### Step 1.3: Use `create_before_destroy` and rename the instances again
174174

175175
Add a `lifecycle` configuration to the `azurerm_virtual_machine` resource. Specify that this resource should be created before the existing instance(s) are destroyed. Additionally, rename the instance(s) again, by removing the suffix _renamed_, and replacing it with `new`
176176

@@ -189,7 +189,7 @@ resource "azurerm_virtual_machine" "main" {
189189
}
190190
```
191191

192-
Also update the `azurerm_network_interface` with a lifecyle block and new name:
192+
Also update the `azurerm_network_interface` with a lifecycle block and new name:
193193

194194
```hcl
195195
resource "azurerm_network_interface" "main" {
@@ -245,7 +245,7 @@ Terraform will perform the following actions:
245245
246246
We'll demonstrate how `prevent_destroy` can be used to guard an instance from being destroyed.
247247
248-
### Step 6.2.1: Use `prevent_destroy`
248+
### Step 2.1: Use `prevent_destroy`
249249
250250
Add `prevent_destroy = true` to the same `lifecycle` stanza where you added `create_before_destroy`.
251251
@@ -263,11 +263,11 @@ resource "azurerm_virtual_machine" "main" {
263263
264264
Attempt to destroy the existing infrastructure. You should see the error that follows.
265265
266-
```shell
266+
```bash
267267
terraform destroy
268268
```
269269
270-
```
270+
```bash
271271
Error: Instance cannot be destroyed
272272
273273
on main.tf line 32:
@@ -280,7 +280,7 @@ lifecycle.prevent_destroy or reduce the scope of the plan using the -target
280280
flag.
281281
```
282282
283-
### Step 6.2.2: Destroy cleanly
283+
### Step 2.2: Destroy cleanly
284284
285285
Now that you have finished the steps in this lab, destroy the infrastructure you have created.
286286

0 commit comments

Comments
 (0)