Skip to content

Commit 5a2b1ae

Browse files
committed
terraform intro cheatsheet sent
1 parent 99f1fbf commit 5a2b1ae

1 file changed

Lines changed: 115 additions & 0 deletions

File tree

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
## Introduction to Terraform
2+
3+
### What is Terraform? 🛠️
4+
5+
Terraform is an open-source Infrastructure as Code (IaC) tool by HashiCorp, enabling you to define and provision infrastructure using declarative configuration files.
6+
7+
### When is Terraform Used? 🤔
8+
9+
Terraform is used:
10+
- To automate the provisioning and management of infrastructure.
11+
- For creating and updating infrastructure components in a repeatable and scalable manner.
12+
- To enforce consistency and reliability across deployments.
13+
14+
### Real World Application of Terraform 🌐
15+
16+
In real-world scenarios, Terraform is utilized for:
17+
- **Cloud Provisioning:** Automating the creation of virtual machines, networks, and storage in AWS, Azure, Google Cloud, etc.
18+
- **Multi-Cloud Deployment:** Managing infrastructure across multiple cloud providers with consistent configurations.
19+
- **DevOps Automation:** Integrating with CI/CD pipelines to automate infrastructure deployment and updates.
20+
21+
## Getting Started 🚀
22+
23+
### Installation
24+
25+
1. **Download Terraform:**
26+
- Visit [Terraform Downloads](https://www.terraform.io/downloads.html) and download the appropriate package for your operating system.
27+
28+
29+
30+
2. **Install Terraform:**
31+
32+
- **Linux/macOS:**
33+
- Extract the downloaded ZIP archive:
34+
```sh
35+
unzip terraform*.zip
36+
```
37+
- Move the `terraform` binary to a directory included in your system's PATH (e.g., `/usr/local/bin/`):
38+
```sh
39+
sudo mv terraform /usr/local/bin/
40+
```
41+
42+
- **Windows:**
43+
- Extract the downloaded ZIP archive.
44+
- Move the `terraform.exe` binary to a directory included in your system's PATH (e.g., `C:\Windows\System32\`).
45+
46+
47+
3. **Verify Installation:**
48+
Open a new terminal/command prompt and check that Terraform is properly installed:
49+
```sh
50+
terraform --version
51+
52+
### Initializing a Terraform Project
53+
54+
1. **Create a Working Directory:**
55+
```sh
56+
mkdir my-terraform-project
57+
cd my-terraform-project
58+
```
59+
60+
2. **Initialize Terraform:**
61+
```sh
62+
terraform init
63+
```
64+
65+
### Terraform Configuration (HCL) 📄
66+
67+
**Example: Provisioning AWS EC2 Instance**
68+
```hcl
69+
# main.tf
70+
71+
provider "aws" {
72+
region = "us-east-1"
73+
}
74+
75+
resource "aws_instance" "example" {
76+
ami = "ami-0c55b159cbfafe1f0"
77+
instance_type = "t2.micro"
78+
tags = {
79+
Name = "ExampleInstance"
80+
}
81+
}
82+
```
83+
84+
### Terraform Commands Cheatsheet
85+
86+
**Initializing Terraform**
87+
88+
```sh
89+
terraform init
90+
```
91+
92+
**Planning Infrastructure Changes**
93+
94+
```sh
95+
terraform plan
96+
```
97+
98+
**Applying Changes**
99+
```sh
100+
terraform apply
101+
```
102+
103+
**Destroying Resources**
104+
```sh
105+
terraform destroy
106+
```
107+
### Best Practices
108+
109+
>Use Version Control: Store Terraform configurations in version control systems (e.g., Git) for collaboration and change tracking.
110+
>Modularization: Organize Terraform code into reusable modules for better management and scalability.
111+
112+
### Additional Resources
113+
114+
Explore more about Terraform and Infrastructure as Code concepts at [Terraform Documentation](https://developer.hashicorp.com/terraform/docs).
115+

0 commit comments

Comments
 (0)