-
Notifications
You must be signed in to change notification settings - Fork 201
/
Copy pathTerraform-notes.txt
131 lines (105 loc) · 3.52 KB
/
Terraform-notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
https://www.terraform.io/downloads.html
https://learn.hashicorp.com/terraform
-----------------------------------------------------------------------------------------------------
https://learn.hashicorp.com/tutorials/terraform/install-cli (tested on ubuntu as well as windows)
WIndows
---------
Download Zip and extract -> D:\tools\terraform_0.14.10_windows_amd64
Path -> Environment variables -> System variables -> D:\tools\terraform_1.1.0_windows_amd64
cmd -> terraform --version
terraform -help
terraform -help init
#Terraform with Docker
https://learn.hashicorp.com/tutorials/terraform/install-cli
Install docker on windows - https://docs.docker.com/docker-for-windows/install/
mkdir D:\learn-terraform\docker
cd D:\learn-terraform\docker
#create main.tf at D:\learn-terraform\docker
#main.tf
-----------------------------
terraform {
required_providers {
docker = {
source = "terraform-providers/docker"
}
}
}
provider "docker" {
host = "npipe:////.//pipe//docker_engine"
}
resource "docker_image" "nginx" {
name = "nginx:latest"
keep_locally = false
}
resource "docker_container" "nginx" {
image = docker_image.nginx.latest
name = "tutorial"
ports {
internal = 80
external = 8000
}
}
D:\learn-terraform\docker> terraform init
D:\learn-terraform\docker> terraform plan #make sure docker is running else will get error.
D:\learn-terraform\docker> terraform apply # check at localhost:8000
-------------------------------
Ubuntu -> https://learn.hashicorp.com/tutorials/terraform/install-cli
------
sudo apt-get update && sudo apt-get install -y gnupg software-properties-common curl
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install terraform
mkdir learn-terraform-docker-container
cd learn-terraform-docker-container
main.tf
------------------------
terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
version = "~> 2.13.0"
}
}
}
provider "docker" {}
resource "docker_image" "nginx" {
name = "nginx:latest"
keep_locally = false
}
resource "docker_container" "nginx" {
image = docker_image.nginx.latest
name = "tutorial"
ports {
internal = 80
external = 8000
}
}
-----------------------------
terraform init
terraform apply
terraform destroy
-------------------------------------------------------
Terraform aws
https://learn.hashicorp.com/tutorials/terraform/aws-build?in=terraform/aws-get-started
------------------------------------------------------------------------------------
# multiple ec2 instances
https://automateinfra.com/2021/03/22/how-to-launch-multiple-ec2-instances-on-aws-using-terraform/
====================================================================================
#Terraform with Azure https://learn.hashicorp.com/tutorials/terraform/azure-build
#Prerequisites
Create azure account
Install the Azure CLI tool
Authenticate using the Azure CLI - az login
mkdir D:\learn-terraform\azure
cd D:\learn-terraform\azure
#create main.tf to create resouce group
terraform init
terraform plan
terraform apply
---------------------------
#rename main.tf with main.tf.1
#rename main.tf.2 main.tf to create VM
terraform init
terraform plan
terraform apply
----------------------------------------------