---
type: archive
area: archive
status: archived
date: 2026-05-03
created: 2026-05-03
updated: 1980-01-01
tags:
  - archive
---
### Providers
- Official
AWS | GCP | AZURE | LocalFile
- Partner
BigIP | Heroku
- Community

Terraform-init is a safe command don't impact the running configuration
By default terraform install the lastest version of the providers
Common naming convention is to call the file ***main.tf***
### Input vars 
![[img-20240917-151436-664c6bf4.png]]
filename content... and all other argument are encoded variables and we should no create them they should by assigned by the user the make teh code reusable
steps 
- Create a file ***variables.tf*** that contains the variables
![[img-20240917-151845-55badc2f.png]]
- to call the from the ***main.tf*** file
![[img-20240917-152000-26ae466f.png]]
Type parameter is optional but it can be specified
- List Type
![[img-20240917-153156-d25bbd58.png]]
- Map Type
![[img-20240917-153249-bd0603c7.png]]

List can be typed to any type like list(string) or map(string) 
- Sets
![[img-20240917-153648-6dbcdd07.png]]

- Objects
Define complex structures
![[img-20240917-153815-cda2c5ab.png]]
- Tuples
![[img-20240917-153937-085bf5bf.png]]
#### Examples Variables
```python
variable "hard_drive" {
	type = map
	default = {
		slow = "HHD"
		fast = "SSD"
	}
}
```
To retrieve this we use ***var.hard_drive["slow"]*** or ***var.hard_drive.slow***
### Using vars in Terraform
1. When using vars we can use multiple ways:
2. by using default argument and writing in it the value
3. by using interactive mode we can achieve that by not writing a value in default argument and removing it completely
4. by passing it with apply when apply command is executed -var "varname=value"
5. by using environment variables like that  export TF_VAR_name="value"
6. making use of variables definition file with this extension ***\*.tfvars***
7. ![[img-20240918-105811-869e2905.png]]
8. file extension can be
9. ![[img-20240918-105912-67b2af00.png]]
10. can be run using 
11. ``` python
12. terraform apply -var-file variables.tfvars
13. ```

#### Order of accepting varibales
1. env variables
2. *.tfvars
3. *.auto.tfvars
4. -var or -var-file (cli args) have the big priority over the all other values
#### Dependent resources
Using an output of a resources on another one
![[img-20240918-122925-b90bc458.png]]
when terraform create resources knows about dependencies
- Creation Order
![[img-20240918-124021-00c804d9.png]]
- Delete Order
reverse order
---
Another way to indicate dependencies is by  specifying a block inside the resource with argument **depends_on** this called explicit dependencies

![[img-20240918-124614-df29333a.png]]

#### Output vars
is used to store values generated by a resource in a var to use after

![[img-20240918-131854-069c50cc.png]]
value argument is a mandatory field
those output vars are used to pass value to an **ansible** playbook or an ad-hoc script to do something to provisioned infrastructure or print some in the screen



