> For the complete documentation index, see [llms.txt](https://asafahmadov.gitbook.io/cloud-and-devops/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://asafahmadov.gitbook.io/cloud-and-devops/devops-bootcamp/infrastructure-as-code-with-terraform/variables.md).

# Variables

Variables (Input variables) let you customize behavior without editing the terraform configuration file

### 2 steps to use variables in Terraform

1. Define variable and use it in your TF script: 2 steps to use variables in Terraform
2. Set the variable values when applying the script

![](https://2601183865-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8QpIzz6VwCOTMwaqKYa3%2Fuploads%2FhCtRhpAhXXZFqaN0oz9O%2Fimage.png?alt=media\&token=7914faa8-dfd9-4e38-b487-0fc9395f6f63)

### 3 ways to set values for the defined variables

![](https://2601183865-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8QpIzz6VwCOTMwaqKYa3%2Fuploads%2FKW89W9Z4WKBSC1QISSr2%2Fimage.png?alt=media\&token=f5bd75e6-70cb-4794-b46c-652127aaf7c3)

![](https://2601183865-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8QpIzz6VwCOTMwaqKYa3%2Fuploads%2FeZJiYA8Cz36g19GJwUrE%2Fimage.png?alt=media\&token=b471d0f8-d12b-435e-96a2-48feed849cfb)

![](https://2601183865-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8QpIzz6VwCOTMwaqKYa3%2Fuploads%2FEPPBpTf9Qv4R1SdGnvXV%2Fimage.png?alt=media\&token=3e2306fb-7c65-4f80-8296-0e5602dbd1e9)

### Real use case with variables

![](https://2601183865-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8QpIzz6VwCOTMwaqKYa3%2Fuploads%2F3PwfOv9QOjIKCpicI1jj%2Fimage.png?alt=media\&token=b76deace-0909-4311-a5d6-f1d7ac553baf)
