Como criar infraestrutura em diferentes ambientes usando Terraform

Terraform é uma ferramenta IaC (infraestrutura como código) de código aberto que fornece um fluxo de trabalho consistente na CLI para gerenciar centenas de serviços em nuvem. Terraform converte APIs de nuvem em arquivos de configuração declarativos.







, , , . Terraform, , .







imagem







. .









. . — . Terraform .







Terraform — IaC, , .

.









Terraform, .







— 1



terraform.tfvars. , .







. , . outputs.tf, providers.tf, variables.tf . . terraform : init, plan, apply



.







imagem

( 1)







:







  • ,
  • .


:







  • ;
  • , .


— 2



, terraform.tfvars. , .







main.tf variables.tf , terraform . , , :







// Dev Environment
terraform plan --var-file="tfvars/environment/dev.tfvars"
// QA Environment
terraform plan --var-file="tfvars/environment/qa.tfvars"
// Prod Environment
terraform plan --var-file="tfvars/environment/prod.tfvars"
      
      





imagem

( 2)







:







  • ;
  • , .


:







  • ;
  • , .




Terraform default. , , , . , , default.

terraform workspace



. . , terraform workspace new



.









— , . Terraform — root-. Root- , .tf .







, . , . , .







. , .







imagem







Terragrunt



Terragrunt — , DRY , Terraform .







.









  • Terraform — - IaC, CLI .
  • , , , .
  • Terraform.
  • — . .
  • Terraform default. , , , .
  • — , . , .
  • Terragrunt — , DRY , Terraform .


, Terraform. . .








All Articles