-
Notifications
You must be signed in to change notification settings - Fork 106
Open
Labels
bugissues that report a bugissues that report a bugkeepprevent github from closing issueprevent github from closing issue
Description
Terraform Version
v1.12.2 on darwin_arm64
Linode Provider Version
3.3.0
Effected Terraform Resources
linode_database_postgresql_v2
Terraform Config Files
terraform {
required_providers {
linode = {
source = "linode/linode"
version = "3.3.0"
}
postgresql = {
source = "cyrilgdn/postgresql"
version = "1.25.0"
}
}
}
provider "linode" {
[...]
}
resource "linode_database_postgresql_v2" "this" {
label = "mydatabase"
engine_id = "postgresql/16"
region = "us-mia"
type = "g6-nanode-1"
allow_list = ["0.0.0.0/0"]
}
provider "postgresql" {
host = linode_database_postgresql_v2.this.host_primary
port = linode_database_postgresql_v2.this.port
database = "defaultdb"
superuser = false
username = linode_database_postgresql_v2.this.root_username
password = linode_database_postgresql_v2.this.root_password
sslrootcert = linode_database_postgresql_v2.this.ca_cert
sslmode = "require"
}
resource "postgresql_role" "this" {
name = "test_role"
password = "test_password"
}
Debug Output
No response
Panic Output
No response
Expected Behavior
Once the database is created host_primary should be known at build time.
Actual Behavior
The first apply works as expected, the postgres provider is configured with the newly created postgres.
On the second apply (with a minor change to ACLs) the host_primary is marked as known after apply. That breaks the postgres provider configuration, as it's unable to read its resources (host is unknown and fallbacks to localhost).
It seems that in the current configuration host_primary is marked as known after apply for no good reason.
This makes it hard to use it a source of configuration for other providers.
terraform apply
linode_database_postgresql_v2.this: Refreshing state... [id=357146]
postgresql_role.this: Refreshing state... [id=test_role]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform planned the following actions, but then encountered a problem:
# linode_database_postgresql_v2.this will be updated in-place
~ resource "linode_database_postgresql_v2" "this" {
~ allow_list = [
- "0.0.0.0/0",
+ "1.0.0.0/0",
]
~ host_primary = "a357146-akamai-prod-2995028-default.g2a.akamaidb.net" -> (known after apply)
~ host_secondary = null -> (known after apply)
id = "357146"
~ members = {
- "172.235.146.222" = "primary"
} -> (known after apply)
~ oldest_restore_time = "2025-09-16T06:01:14Z" -> (known after apply)
~ status = "active" -> (known after apply)
~ updated = "2025-09-16T06:01:26Z" -> (known after apply)
~ version = "16.10" -> (known after apply)
# (19 unchanged attributes hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
╷
│ Error: Error connecting to PostgreSQL server (scheme: postgres): dial tcp [::1]:23455: connect: connection refused
│
│ with postgresql_role.this,
│ on main.tf line 38, in resource "postgresql_role" "this":
│ 38: resource "postgresql_role" "this" {
│
╵
Steps to Reproduce
- Run apply
- Change ACLs
- Run apply again
- Observe
known after applyand terraform error
Metadata
Metadata
Assignees
Labels
bugissues that report a bugissues that report a bugkeepprevent github from closing issueprevent github from closing issue