Lynx icon indicating copy to clipboard operation
Lynx copied to clipboard

Simplify Terrform Backend configuration

Open ankek opened this issue 9 months ago • 0 comments

Current configuration of TF Backend. backend "http" { username = "hs2d21pk" password = "pO(BwDTjs5ND" address = "http://localhost:4000/client/clivern/monitoring/prod/state" lock_address = "http://localhost:4000/client/clivern/monitoring/prod/lock" unlock_address = "http://localhost:4000/client/clivern/monitoring/prod/unlock" lock_method = "POST" unlock_method = "POST" }

Desired configuration of TF Backend.

terraform { backend "remote" {
hostname = "http://localhost:4000/api_path" organization = "company" token = "tXXkgPPOYDk4Sx5wxWtrXT4qPZxYq72yqOe2HpUQNjedW" workspaces { name = "clivern-monitoring-prod" # ${project}-${workspace}-${environment} } }

Additional context I want to propose you use "remote" backend instead of "http". There are a lot of benefits like:

  • No need to create unique username and password for each environment in Project. Mostly project managed by team and you can create "team" token for authentication and authorization within team creation. Segregation and isolation resources created in one project could be based on environment definition (or workspace+environment, if you would have a will/chance/etc. to do this (-: ).
  • No need to redefine it in back-end configurations each time.
  • This is very brief explanation. Feel free to ping me if you will needed more details. Please find more details in
  • https://developer.hashicorp.com/terraform/language/settings/backends/remote
  • https://developer.hashicorp.com/terraform/cloud-docs/api-docs

ankek avatar May 25 '24 18:05 ankek