Skip to content

Commit 55c1689

Browse files
committed
Welcome to StackSimplify
1 parent 7a0be99 commit 55c1689

File tree

921 files changed

+49131
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

921 files changed

+49131
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ override.tf.json
2727

2828
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
2929
# example: *tfplan*
30+
31+
# Mac Files
32+
.DS_Store
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Infrastructure as Code Basics
2+
3+
## Step-01: Understand Problems with Traditional way of Managing Infrastructure
4+
- Time it takes for building multiple environments
5+
- Issues we face with different environments
6+
- Scale-Up and Scale-Down On-Demand
7+
8+
## Step-02: Discuss how IaC with Terraform Solves them
9+
- Visibility
10+
- Stability
11+
- Scalability
12+
- Security
13+
- Audit
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
---
2+
title: Install Terraform, Azure CLI and VSCode Editor
3+
description: Install all the tools required for learning Terraform on Azure Cloud
4+
---
5+
6+
## Step-01: Introduction
7+
- Install [Terraform CLI](https://www.terraform.io/downloads.html)
8+
- Install [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
9+
- Install [VS Code Editor](https://code.visualstudio.com/download)
10+
- Install [HashiCorp Terraform plugin for VS Code](https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform)
11+
- Install [Git Client](https://git-scm.com/downloads)
12+
13+
[![Image](https://stacksimplify.com/course-images/azure-terraform-install-1.png "HashiCorp Certified: Terraform Associate on Azure")](https://stacksimplify.com/course-images/azure-terraform-install-1.png)
14+
15+
## Step-02: MACOS: Terraform Install
16+
- [Download Terraform MAC](https://www.terraform.io/downloads.html)
17+
- [Install CLI](https://learn.hashicorp.com/tutorials/terraform/install-cli)
18+
- Unzip the package
19+
```t
20+
# Copy binary zip file to a folder
21+
mkdir /Users/<YOUR-USER>/Documents/terraform-install
22+
COPY Package to "terraform-install" folder
23+
24+
# Unzip
25+
unzip <PACKAGE-NAME>
26+
unzip terraform_0.15.4_darwin_amd64.zip
27+
28+
# Copy terraform binary to /usr/local/bin
29+
echo $PATH
30+
mv terraform /usr/local/bin
31+
32+
# Verify Version
33+
terraform version
34+
35+
# To Uninstall Terraform (NOT REQUIRED)
36+
rm -rf /usr/local/bin/terraform
37+
```
38+
39+
## Step-03: MACOS: IDE for Terraform - VS Code Editor
40+
- [Microsoft Visual Studio Code Editor](https://code.visualstudio.com/download)
41+
- [Hashicorp Terraform Plugin for VS Code](https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform)
42+
- Configure [Course Github Repository](https://github.com/stacksimplify/hashicorp-certified-terraform-associate-on-azure) using VS Code Editor
43+
44+
45+
## Step-04: MACOS: Install Azure CLI
46+
- [Azure CLI Install](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
47+
- [Install Azure CLI - MAC](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-macos)
48+
```t
49+
# Install XCode
50+
brew update
51+
xcode-select --install
52+
Observation: Verify images for reference in "image-reference" folder
53+
54+
# Sample Error (Without Xcode if we try az cli install it will through this error)
55+
Error: python@3.8: the bottle needs the Apple Command Line Tools to be installed.
56+
You can install them, if desired, with:
57+
xcode-select --install
58+
59+
60+
# AZ CLI Current Version (if installed)
61+
az --version
62+
63+
# Install Azure CLI (if not installed)
64+
brew update
65+
brew install azure-cli
66+
67+
# Upgrade az cli version
68+
az --version
69+
brew upgrade azure-cli
70+
[or]
71+
az upgrade
72+
az --version
73+
```
74+
75+
[![Image](https://stacksimplify.com/course-images/xcode-install-1.png "HashiCorp Certified: Terraform Associate on Azure")](https://stacksimplify.com/course-images/xcode-install-1.png)
76+
77+
[![Image](https://stacksimplify.com/course-images/xcode-install-2.png "HashiCorp Certified: Terraform Associate on Azure")](https://stacksimplify.com/course-images/xcode-install-2.png)
78+
79+
[![Image](https://stacksimplify.com/course-images/xcode-install-3.png "HashiCorp Certified: Terraform Associate on Azure")](https://stacksimplify.com/course-images/xcode-install-3.png)
80+
81+
[![Image](https://stacksimplify.com/course-images/xcode-install-4.png "HashiCorp Certified: Terraform Associate on Azure")](https://stacksimplify.com/course-images/xcode-install-4.png)
82+
83+
84+
## Step-05: Terraform - Authenticating using the Azure CLI
85+
- [Azure Provider: Authenticating using the Azure CLI](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/azure_cli)
86+
```t
87+
# Azure CLI Login
88+
az login
89+
90+
# List Subscriptions
91+
az account list
92+
93+
# Set Specific Subscription (if we have multiple subscriptions)
94+
az account set --subscription="SUBSCRIPTION_ID"
95+
```
96+
97+
## Step-06: Install Git Client
98+
- [Download Git Client](https://git-scm.com/downloads)
99+
- This is required when we are working with `Terraform Modules`
100+
101+
## Step-07: WindowsOS: Terraform & Azure CLI Install
102+
### Step-07-01: Install Git Client
103+
- [Download Git Client](https://git-scm.com/downloads)
104+
- This is required when we are working with `Terraform Modules`
105+
106+
### Step-07-02: Install Azure CLI
107+
- Install [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?tabs=azure-cli)
108+
- `Step-05:Terraform - Authenticating using the Azure CLI` is going to be same for WindowsOS too.
109+
```t
110+
# Azure CLI Login
111+
az login
112+
113+
# List Subscriptions
114+
az account list
115+
116+
# Set Specific Subscription (if we have multiple subscriptions)
117+
az account set --subscription="SUBSCRIPTION_ID"
118+
```
119+
120+
### Step-07-03: Install Terraform
121+
- [Download Terraform](https://www.terraform.io/downloads.html)
122+
- [Install CLI](https://learn.hashicorp.com/tutorials/terraform/install-cli)
123+
- Unzip the package
124+
- Create new folder `terraform-bins`
125+
- Copy the `terraform.exe` to a `terraformbins`
126+
- Set PATH in windows
127+
128+
### Step-07-04: Configure Course Git Repo
129+
- [Course Git Repo](https://github.com/stacksimplify/hashicorp-certified-terraform-associate-on-azure)
130+
- Shorten Course folder name to smaller one. Put it in C:\ Drive root path
131+
132+
### Step-07-05: Install Visual Studio Code and Terraform Plugin
133+
- [Microsoft Visual Studio Code Editor](https://code.visualstudio.com/download)
134+
- [Hashicorp Terraform Plugin for VS Code](https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform)
135+
- Configure [Course Github Repository](https://github.com/stacksimplify/hashicorp-certified-terraform-associate-on-azure) using VS Code Editor
136+
137+
### Step-07-06: WindowsOS: Long Path Issues for Terraform CLI
138+
- [Windows10 Long File Name or Path](https://github.com/hashicorp/terraform/issues/21173)
139+
- [Microsoft fix](https://answers.microsoft.com/en-us/windows/forum/all/windows-10-commands-with-long-path-name-are-not/13f0f7c7-d55c-4c6c-b19d-9dfec099dd45)
140+
- Our fix is to shorten our git repo names to see if that helps
141+
142+
## Step-08: LinuxOS: Terraform & Azure CLI Install
143+
- [Download Terraform](https://www.terraform.io/downloads.html)
144+
- [Linux OS - Terraform Install](https://learn.hashicorp.com/tutorials/terraform/install-cli)
145+
- Install [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=script)
146+
- `Step-05:Terraform - Authenticating using the Azure CLI` is going to be same for LinuxOS too.
147+
- [Course Git Repo](https://github.com/stacksimplify/hashicorp-certified-terraform-associate-on-azure)
Loading
Loading
Loading
Loading

03-Terraform-Command-Basics/README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
title: Terraform Command Basics
3+
description: Learn Terraform Commands like init, validate, plan, apply and destroy
4+
---
5+
6+
## Step-01: Introduction
7+
- Understand basic Terraform Commands
8+
1. terraform init
9+
2. terraform validate
10+
3. terraform plan
11+
4. terraform apply
12+
5. terraform destroy
13+
14+
[![Image](https://stacksimplify.com/course-images/azure-terraform-workflow-1.png "HashiCorp Certified: Terraform Associate on Azure")](https://stacksimplify.com/course-images/azure-terraform-workflow-1.png)
15+
16+
[![Image](https://stacksimplify.com/course-images/azure-terraform-workflow-2.png "HashiCorp Certified: Terraform Associate on Azure")](https://stacksimplify.com/course-images/azure-terraform-workflow-2.png)
17+
18+
## Step-02: Review terraform manifests
19+
- **Pre-Conditions-1:** Get Azure Regions and decide the region where you want to create resources
20+
```t
21+
# Get Azure Regions
22+
az account list-locations -o table
23+
```
24+
- **Pre-Conditions-2:** If not done earlier, complete `az login` via Azure CLI. We are going to use Azure CLI Authentication for Terraform when we use Terraform Commands.
25+
```t
26+
# Azure CLI Login
27+
az login
28+
29+
# List Subscriptions
30+
az account list
31+
32+
# Set Specific Subscription (if we have multiple subscriptions)
33+
az account set --subscription="SUBSCRIPTION_ID"
34+
```
35+
- [Azure Regions](https://docs.microsoft.com/en-us/azure/virtual-machines/regions)
36+
- [Azure Regions Detailed](https://docs.microsoft.com/en-us/azure/best-practices-availability-paired-regions#what-are-paired-regions)
37+
```t
38+
# Terraform Settings Block
39+
terraform {
40+
required_version = ">= 1.0.0"
41+
required_providers {
42+
azurerm = {
43+
source = "hashicorp/azurerm"
44+
version = ">= 2.0" # Optional but recommended in production
45+
}
46+
}
47+
}
48+
# Configure the Microsoft Azure Provider
49+
provider "azurerm" {
50+
features {}
51+
}
52+
# Create Resource Group
53+
resource "azurerm_resource_group" "my_demo_rg1" {
54+
location = "eastus"
55+
name = "my-demo-rg1"
56+
}
57+
```
58+
59+
## Step-03: Terraform Core Commands
60+
```t
61+
# Terraform Initialize
62+
terraform init
63+
64+
# Terraform Validate
65+
terraform validate
66+
67+
# Terraform Plan to Verify what it is going to create / update / destroy
68+
terraform plan
69+
70+
# Terraform Apply to Create Resources
71+
terraform apply
72+
```
73+
74+
## Step-04: Verify Azure Resource Group in Azure Management Console
75+
- Go to Azure Management Console -> Resource Groups
76+
- Verify newly created Resource Group
77+
- Review `terraform.tfstate` file
78+
79+
## Step-05: Destroy Infrastructure
80+
```t
81+
# Destroy Azure Resource Group
82+
terraform destroy
83+
Observation:
84+
1. Verify if the resource group got deleted in Azure Management Console
85+
2. Verify terraform.tfstate file and resource group info should be removed
86+
3. Verify terraform.tfstate.backup, it should have the resource group info here stored as backup.
87+
88+
# Delete Terraform files
89+
rm -rf .terraform*
90+
rm -rf terraform.tfstate*
91+
```
92+
93+
## Step-08: Conclusion
94+
- Re-iterate what we have learned in this section
95+
- Learned about Important Terraform Commands
96+
1. terraform init
97+
2. terraform validate
98+
3. terraform plan
99+
4. terraform apply
100+
5. terraform destroy
101+
102+
103+
104+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Terraform Settings Block
2+
terraform {
3+
required_version = ">= 1.0.0"
4+
required_providers {
5+
azurerm = {
6+
source = "hashicorp/azurerm"
7+
version = ">= 2.0" # Optional but recommended in production
8+
}
9+
}
10+
}
11+
12+
# Configure the Microsoft Azure Provider
13+
provider "azurerm" {
14+
features {}
15+
}
16+
17+
# Create Resource Group
18+
resource "azurerm_resource_group" "my_demo_rg1" {
19+
location = "eastus"
20+
name = "my-demo-rg1"
21+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
title: Terraform Configuration Language Syntax
3+
description: Learn Terraform Configuration Language Syntax like Blocks, Arguments, Comments etc
4+
---
5+
6+
## Step-01: Introduction
7+
- Understand Terraform Language Basics
8+
1. Understand Blocks
9+
2. Understand Arguments, Attributes & Meta-Arguments
10+
3. Understand Identifiers
11+
4. Understand Comments
12+
13+
14+
## Step-02: Terraform Configuration Language Syntax
15+
- Understand Blocks
16+
- Understand Arguments
17+
- Understand Identifiers
18+
- Understand Comments
19+
- [Terraform Configuration](https://www.terraform.io/docs/configuration/index.html)
20+
- [Terraform Configuration Syntax](https://www.terraform.io/docs/configuration/syntax.html)
21+
```t
22+
# Template
23+
<BLOCK TYPE> "<BLOCK LABEL>" "<BLOCK LABEL>" {
24+
# Block body
25+
<IDENTIFIER> = <EXPRESSION> # Argument
26+
}
27+
28+
# Azure Example
29+
# Create a resource group
30+
resource "azurerm_resource_group" "myrg" { # Resource BLOCK
31+
name = "myrg-1" # Argument
32+
location = "East US" # Argument
33+
}
34+
# Create Virtual Network
35+
resource "azurerm_virtual_network" "myvnet" { # Resource BLOCK
36+
name = "myvnet-1" # Argument
37+
address_space = ["10.0.0.0/16"]
38+
location = azurerm_resource_group.myrg.location # Argument with value as expression
39+
resource_group_name = azurerm_resource_group.myrg.name # Argument with value as expression
40+
}
41+
```
42+
43+
## Step-03: Understand about Arguments, Attributes and Meta-Arguments.
44+
- Arguments can be `required` or `optional`
45+
- Attribues format looks like `resource_type.resource_name.attribute_name`
46+
- Meta-Arguments change a resource type's behavior (Example: count, for_each)
47+
- [Additional Reference](https://learn.hashicorp.com/tutorials/terraform/resource?in=terraform/configuration-language)
48+
- [Resource: Azure Resource Group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group)
49+
- [Resource: Azure Resource Group Argument Reference](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group#arguments-reference)
50+
- [Resource: Azure Resource Group Attribute Reference](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group#attributes-reference)
51+
- [Resource: Meta-Arguments](https://www.terraform.io/docs/language/meta-arguments/depends_on.html)
52+
53+
## Step-04: Understand about Terraform Top-Level Blocks
54+
- Discuss about Terraform Top-Level blocks
55+
1. Terraform Settings Block
56+
2. Provider Block
57+
3. Resource Block
58+
4. Input Variables Block
59+
5. Output Values Block
60+
6. Local Values Block
61+
7. Data Sources Block
62+
8. Modules Block
63+

0 commit comments

Comments
 (0)