terraform
terraform copied to clipboard
backend pg: env PGUSER used for PG_SCHEMA_NAME
Terraform Version
Terraform v1.7.2-dev
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v3.65.0
+ provider registry.terraform.io/hashicorp/vault v4.3.0
Your version of Terraform is out of date! The latest version
is 1.9.3. You can update by downloading from https://www.terraform.io/downloads.html
Terraform Configuration Files
terraform {
backend "pg" {
}
}
Debug Output
2024-07-24T21:23:17.291Z [INFO] Terraform version: 1.7.2 dev
2024-07-24T21:23:17.291Z [DEBUG] using github.com/hashicorp/go-tfe v1.41.0
2024-07-24T21:23:17.291Z [DEBUG] using github.com/hashicorp/hcl/v2 v2.19.1
2024-07-24T21:23:17.291Z [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2024-07-24T21:23:17.291Z [DEBUG] using github.com/zclconf/go-cty v1.14.1
2024-07-24T21:23:17.291Z [INFO] Go runtime version: go1.22.4
2024-07-24T21:23:17.291Z [INFO] CLI args: []string{"terraform", "plan"}
2024-07-24T21:23:17.291Z [TRACE] Stdout is a terminal of width 85
2024-07-24T21:23:17.291Z [TRACE] Stderr is a terminal of width 85
2024-07-24T21:23:17.291Z [TRACE] Stdin is a terminal
2024-07-24T21:23:17.291Z [DEBUG] Attempting to open CLI config file: /root/.terraformrc
2024-07-24T21:23:17.291Z [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2024-07-24T21:23:17.292Z [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2024-07-24T21:23:17.292Z [DEBUG] ignoring non-existing provider search directory /root/.terraform.d/plugins
2024-07-24T21:23:17.292Z [DEBUG] ignoring non-existing provider search directory /root/.local/share/terraform/plugins
2024-07-24T21:23:17.292Z [DEBUG] ignoring non-existing provider search directory /usr/local/share/terraform/plugins
2024-07-24T21:23:17.292Z [DEBUG] ignoring non-existing provider search directory /usr/share/terraform/plugins
2024-07-24T21:23:17.293Z [INFO] CLI command args: []string{"plan"}
2024-07-24T21:23:17.456Z [TRACE] Meta.Backend: built configuration for "pg" backend with hash value 1949691007
2024-07-24T21:23:17.456Z [TRACE] Preserving existing state lineage "7bc0a3b1-67e1-c7a6-ada4-ade3040d13ae"
2024-07-24T21:23:17.456Z [TRACE] Preserving existing state lineage "7bc0a3b1-67e1-c7a6-ada4-ade3040d13ae"
2024-07-24T21:23:17.457Z [TRACE] Meta.Backend: working directory was previously initialized for "pg" backend
2024-07-24T21:23:17.457Z [TRACE] Meta.Backend: using already-initialized, unchanged "pg" backend configuration
Expected Behavior
Terraform should read PG_SCHEMA_NAME
as specified in documentation
Actual Behavior
Terraform reuses the value of PGUSER
for schema, leading to error
│ Error: pq: no pg_hba.conf entry for host "192.168.202.151", user "pg_user", database "pg_user", SSL encryption
Steps to Reproduce
- Use a postgres backend
- Set env vars according to documentation:
-
PGUSER
-
PGPASSWORD
-
PG_SCHEMA_NAME
-
PGHOST
- Run
terraform init
orterraform plan
.
Additional Context
Setting these all inPG_CONN_STR
works fine, but this is not deemed required by the documentation. I'd prefer to use the separate variables for cleaner templating.
References
No response