Hashicorp Terraform
Get up and running with Terraform
Check out my full terraform course on Cybr!
https://cybr.com/courses/terraform-on-aws-from-zero-to-cloud-infrastructure/
What is Terraform?
Terraform is an open-source, declarative Infrastructure as Code language from HashiCorp.
Providers are used to define the resources to build. These abstract the underlying API calls made to build, modify, and destroy resources by wrapping this into HCL syntax. In other words, you just worry about writing Terraform code without having to understand and work with the underlying APIs.
Installation
# Installing via Homebrew on MacOS
brew tap hashicorp/tap
brew install hashicorp/tap/terraform
brew update
brew upgrade hashicorp/tap/terraformh
# Enabling tab completion
terraform -install-autocomplete
# Restarting shell
. ~/.zshrc # bash is ~/.bashrcCommands
Initialize the directory where Terraform files are stored:
terraform initVerify the Terraform syntax is correct:
terraform validateView the resources the code would build if run:
terraform planBuild the resources:
terraform applyDestroy the resources created with Terraform:
terraform destroy
Example
Typically, Terraform code is defined in a
main.tffile and variables found in that file can be declared invariables.tfVariables are not required and you could hard code everything into
main.tfif desired.Here's an example of configuring an AWS S3 bucket in Terraform utilizing the AWS Provider.
Last updated
Was this helpful?