Various files, derived from content here.
Mostly exists to document a quick start to using Terraform.
Begin with initializing a folder with the needed terraform plugins and providers:
terraform init
This will create a .terraform folder with needed libraries, as well as a lockfile.
Afterwards, do a quick format of the terraform scripts via:
terraform fmt
Terraform also offers
terraform validate
If successful, the following will appear:
Success! The configuration is valid.
To apply the configuration to production, do the following:
terraform apply
If that worked, then take a quick look at live:
terraform show
Assuming all the infra changes were made, then.
List the current state of this configuration:
terraform state list
Remove all resources and components associated with this configuration:
terraform destroy
Once you have infrastructure provisioned, you can query the outputs of those like so:
terraform output
Variables for your scripts can used, if needed.
Add something like the following to your script, setting a safe default:
variable "instance_name" {
description = "Value of the Name tag for the EC2 instance"
type = string
default = "TerraformTutorial"
}
Afterwards, the variable can be set at the commandline like so:
terraform apply -var "instance_name=BrandNewInstance"
To login to Terraform Cloud, type the following:
terraform login
Terraform will then request an API token for app.terraform.io using your browser.