Deploying Your First Terraform Configuration¶
Terraform Components¶
- Terraform executable
- Terraform files
- Terraform plugins
- Terraform state
Variables
variable "aws_access_key" {}
variable "aws_secret_key" {}
variable "aws_region" {
default = "us-east-1"
}
Provider
provider "aws" {
access_key = "var.access_key"
secret_key = "var.secret_key"
region = "var.aws_region"
}
Data
Resource
Output
Examining the Configuration¶
Working with Variables¶
Deploying the Configuration¶
# List terraform commands
terraform
# Get the terraform version
terraform version
# Get AWS plugin and initialise configuration
terraform init
# Look at config files in directory and load variables
terraform plan -out m3.tfplan
# Executing what's in the plan
terraform apply "m3.tfplan"
# Looks at state file and what resources were created and destroys them
terraform destroy