-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathsession-33.txt
More file actions
93 lines (67 loc) · 2.21 KB
/
Copy pathsession-33.txt
File metadata and controls
93 lines (67 loc) · 2.21 KB
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
count based loop
- list
- count.index
for based loop
- set or map
- each, each.key and each.value
dynamic block
- we get special variable with block name, for example ingress
data sources
- query the provider for existing information
functions
state
=====
terraform stores/tracks what it had created in the state file, it is like memory to terraform
.tf files -> desired/declared/expected/asked infra
actual infra -> what is actually creted inside provider
state -> what terraform created
desired infra == actual infra
first time
=========
declare infra
actual infra not created
state is empty
terraform apply
terraform creates the resources in provider and note them in state file
apply again
.tf files, state file, actual infra
state file == actual infra
scan .tf files
.tf files == actual infra
update tf files
===============
.tf, actual infra, state file
state file == actual infra -> means nothing changed outside of terraform
.tf files != actual infra
changes outside terraform
==============
.tf, actual infra, state file
state file != actual infra -> means someone changed outside of terraform
desired != actual infra
destroy
=======
delete the infra, update state file
state file -> for terraform
tf files -> us
state file is locked by terraform when it is performing actions on that
remote state
==========
in colloboration environment, state should be stored in remote like S3 so that we can prevent errors and duplicates, it should be locked parellel modifications should not be allowed
remote state secure
=================
1. users should not have access to delete except terraform
2. you should enable versions
3. data replication in another bucket
locals
=======
locals are like variables but has extra capabilities
1. you can refer other variables inside locals
2. values inside locals cant be overridden.
3. we can store functions or expressions in locals
Provisioners
=============
1. local-exec -> where terraform executes
2. remote-exec -> executes inside the resources created by terraform
if we want to take some actions or run scripts then we can use provisioners
provisioners will be executed at the time of destroy or creation but not at the time of updating the resources
openssl ssh version mismatch