Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

README.md

Terraform Utils

Install tfenv

# https://github.com/tfutils/tfenv
$ git clone --depth=1 https://github.com/tfutils/tfenv.git ~/.tfenv
$ echo 'export PATH=$PATH:$HOME/.tfenv/bin' >> ~/.bashrc

Install terraform

$ tfenv install $VERSION
$ tfenv list
$ tfenv use $VERSION

# check
$ terraform -v

Main commands

# prepare your working directory for other commands
$ terraform init

# check whether the configuration is valid
$ terraform validate

# show changes required by the current configuration
$ terraform plan

# create or update infrastructure
$ terraform apply

# destroy previously-created infrastructure
$ terraform destroy

Useful commands

# reformat your configuration in the standard style
$ terraform fmt

# show the current state or a saved plan
$ terraform show

# try Terraform expressions at an interactive command prompt
$ terraform console 

# apply with auto approve
$ terraform apply -auto-approve

# apply informing tfvars file and auto approve
$ terraform apply -var-file="local.tfvars" -auto-approve

# plan and apply using a output file
$ terraform plan -out="tfplan.out"
$ terraform apply "tfplan.out"

# plan informin variables dynamically
$ terraform plan -var="key=value"

Useful environment variables

# access key and secret key (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, ...)
$ AWS_ACCESS_KEY_ID=value AWS_SECRET_ACCESS_KEY=value terraform plan

# variables (TF_VAR_key, ...)
$ TF_VAR_key=value terraform plan

Feedback

If you have any feedback, please contact me at raphaeldias.ti@gmail.com

github linkedin