Skip to content

aernesto24/elopez-terraform-templates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

elopez-terraform-templates

Terraform templates from different trainings or developed by myself

NOTE : Inside each folder there will be specific README files adapted to the template request

Useful commands

This small part provide some useful commands for terraform

terraform state list

List all resources we have state for, mostly resources that i created

terraform state show <resource>

Provides detailf of an specific resource, example:

  • terraform state show aws_instance.myfirstServer
terraform apply --auto-approve

Apply your terraform template with automatic approval (you must be cautious with this)

terraform output

Show all the outputs defined on your template

terraform refresh

Refresh the state of your terraform deployment without actually redeploying anything, helpful if you add outputs to your template and want to see how it looks like

terraform destroy --target resource.name

This command will destroy a specific resource instead of all the resources defined in the template

  • Example: terraform destroy --target aws_instance.myfirstServer
terraform apply --target resource.name

This command will create a specific resource instead of all the resources defined in the template

  • Example: terraform apply --target aws_instance.myfirstServer
terraform apply -var "var_name=var_value"

Apply a terraform template entering the value you defined in a variable inside the template.

  • Lets say you define the following variable:
    • variable "instance_type" { description = "Instance Type"}
    • you can apply it using terraform apply -var "instance_type=t3.micro"
terraform apply -var-file <name>.tfvars

This command apply a template using the variables defined in an specific file.

  • Note by default terraform look for a file named terraform.tfvars for variables but you can rename this file and send it to terraform

About

Terraform templates from practices or training resources

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published