Skip to content

Commit 2a376f9

Browse files
authored
Create README for Azure Terraform templates
Added README.md for Azure Infrastructure Terraform templates, detailing prerequisites, template structure, and execution steps.
1 parent 3c6fb4d commit 2a376f9

1 file changed

Lines changed: 141 additions & 0 deletions

File tree

terraform-infrastructure/README.md

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Azure Infrastructure Terraform Templates
2+
3+
Costa Rica
4+
5+
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/)
6+
[brown9804](https://github.com/brown9804)
7+
8+
Last updated: 2026-02-02
9+
10+
----------
11+
12+
> This approach focuses on `setting up the required infrastructure via Terraform`. It allows for source control of not only the solution code, connections, and setups `but also the infrastructure itself`.
13+
14+
<div align="center">
15+
<img src="https://github.com/user-attachments/assets/d16f2489-b7a6-4f62-9ca8-f137fcb8678c" alt="Centered Image" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
16+
</div>
17+
18+
<div align="center">
19+
<img src="https://github.com/user-attachments/assets/797e7981-6505-4cd9-839c-a107e43282d4" alt="Centered Image" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
20+
</div>
21+
22+
## Prerequisites
23+
24+
- An `Azure subscription is required`. All other resources, including instructions for creating a Resource Group, are provided in this workshop.
25+
- `Contributor role assigned or any custom role that allows`: access to manage all resources, and the ability to deploy resources within subscription.
26+
- Please ensure that:
27+
- [Terraform is installed on your local machine](https://developer.hashicorp.com/terraform/tutorials/azure-get-started/install-cli#install-terraform).
28+
- [Install the Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) to work with both Terraform and Azure commands.
29+
30+
## Overview
31+
32+
Templates structure:
33+
34+
```
35+
.
36+
├── README.md
37+
├────── main.tf
38+
├────── variables.tf
39+
├────── provider.tf
40+
├────── terraform.tfvars
41+
├────── outputs.tf
42+
```
43+
44+
- main.tf `(Main Terraform configuration file)`: This file contains the core infrastructure code. It defines the resources you want to create, such as virtual machines, networks, and storage. It's the primary file where you describe your infrastructure in a declarative manner.
45+
- variables.tf `(Variable definitions)`: This file is used to define variables that can be used throughout your Terraform configuration. By using variables, you can make your configuration more flexible and reusable. For example, you can define variables for resource names, sizes, and other parameters that might change between environments.
46+
- provider.tf `(Provider configurations)`: Providers are plugins that Terraform uses to interact with cloud providers, SaaS providers, and other APIs. This file specifies which providers (e.g., AWS, Azure, Google Cloud) you are using and any necessary configuration for them, such as authentication details.
47+
- terraform.tfvars `(Variable values)`: This file contains the actual values for the variables defined in `variables.tf`. By separating variable definitions and values, you can easily switch between different sets of values for different environments (e.g., development, staging, production) without changing the main configuration files.
48+
- outputs.tf `(Output values)`: This file defines the output values that Terraform should return after applying the configuration. Outputs are useful for displaying information about the resources created, such as IP addresses, resource IDs, and other important details. They can also be used as inputs for other Terraform configurations or scripts.
49+
50+
> KeyVault:
51+
52+
<div align="center">
53+
<img src="https://github.com/user-attachments/assets/a87ad7b6-9059-4679-934e-2ba1a3ea3bba" alt="Centered Image" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
54+
</div>
55+
56+
<div align="center">
57+
<img src="https://github.com/user-attachments/assets/6f6b819e-6c71-43e7-83df-102055d38fb1" alt="Centered Image" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
58+
</div>
59+
60+
> Artifact Signing Account:
61+
62+
<div align="center">
63+
<img src="https://github.com/user-attachments/assets/8c302be2-7762-4496-8166-b3bea345fd48" alt="Centered Image" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
64+
</div
65+
66+
## How to execute it
67+
68+
```mermaid
69+
graph TD;
70+
A[az login] --> B(terraform init)
71+
B --> C{Terraform provisioning stage}
72+
C -->|Review| D[terraform plan]
73+
C -->|Order Now| E[terraform apply]
74+
C -->|Delete Resource if needed| F[terraform destroy]
75+
```
76+
77+
> [!IMPORTANT]
78+
> Please modify `terraform.tfvars` with your information, then run the following flow. If you need more visual guidance, please check the video that illustrates the provisioning steps.
79+
80+
1. **Login to Azure**: This command logs you into your Azure account. It opens a browser window where you can enter your Azure credentials. Once logged in, you can manage your Azure resources from the command line.
81+
82+
> Go to the path where Terraform files are located:
83+
84+
```sh
85+
cd terraform-infrastructure
86+
```
87+
88+
```sh
89+
az login
90+
```
91+
92+
<img width="550" alt="img" src="https://github.com/user-attachments/assets/53b47aa7-134e-4cf7-b0b8-cdebdd0583ed" />
93+
94+
<img width="550" alt="img" src="https://github.com/user-attachments/assets/1d9a247d-3dc9-472f-9305-4e4f0ecb72f1" />
95+
96+
2. **Initialize Terraform**: Initializes the working directory containing the Terraform configuration files. It downloads the necessary provider plugins and sets up the backend for storing the state.
97+
98+
``` sh
99+
terraform init
100+
```
101+
102+
<img width="550" alt="img" src="https://github.com/user-attachments/assets/a7a32891-ad72-423a-a1fe-bdb50925b546" />
103+
104+
3. **Terraform Provisioning Stage**:
105+
106+
- **Review**: Creates an execution plan, showing what actions Terraform will take to achieve the desired state defined in your configuration files. It uses the variable values specified in `terraform.tfvars`.
107+
108+
```sh
109+
terraform plan -var-file terraform.tfvars
110+
```
111+
112+
> At the end, you will see a message in green if everything was executed successfully:
113+
114+
<img width="550" alt="Screenshot 2025-03-18 145143" src="https://github.com/user-attachments/assets/4741e863-1ccd-4f2a-a0b8-d5d1964bd890" />
115+
116+
- **Order Now**: Applies the changes required to reach the desired state of the configuration. It prompts for confirmation before making any changes. It also uses the variable values specified in `terraform.tfvars`.
117+
118+
```sh
119+
terraform apply -var-file terraform.tfvars
120+
```
121+
122+
> At the end, you will see a message in green if everything was executed successfully:
123+
124+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/2b32b63f-3e9f-46da-a5e9-c39360135251">
125+
126+
- **Remove**: Destroys the infrastructure managed by Terraform. It prompts for confirmation before deleting any resources. It also uses the variable values specified in `terraform.tfvars`.
127+
128+
```sh
129+
terraform destroy -var-file terraform.tfvars
130+
```
131+
132+
> At the end, you will see a message in green if everything was executed successfully:
133+
134+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/f2089d03-3a3d-431d-b462-8148ef519104">
135+
136+
<!-- START BADGE -->
137+
<div align="center">
138+
<img src="https://img.shields.io/badge/Total%20views-1416-limegreen" alt="Total views">
139+
<p>Refresh Date: 2026-02-02</p>
140+
</div>
141+
<!-- END BADGE -->

0 commit comments

Comments
 (0)