terraform-provider-redshift
terraform-provider-redshift copied to clipboard
bug in provider when pq fails
On a fresh terraform state, and the following tf config (notice the error in the schema owner - is user
but should be xuser
)
output saved to TF_LOG_FILE: log.broke.txt :
terraform {
required_providers {
redshift = {
source = "brainly/redshift"
version = "0.5.1"
}
}
}
variable "redshift_host" { type = string }
variable "redshift_username" { type = string }
variable "redshift_password" {
type = string
sensitive = true
}
variable "redshift_database" { type = string }
provider "redshift" {
host = var.redshift_host
username = var.redshift_username
password = var.redshift_password
database = var.redshift_database
sslmode = "require"
max_connections = 0
}
resource "redshift_user" "user" {
name = "xuser"
}
resource "redshift_group" "group" {
name = "xgroup"
users = ["xuser"]
}
resource "redshift_schema" "schema" {
name = "xschema"
owner = "user"
}
resource "redshift_grant" "grants" {
group = "xgroup"
schema = "xschema"
object_type = "table"
privileges = ["SELECT", "INSERT", "UPDATE", "DELETE", "DROP", "REFERENCES"]
}
got the following error:
% terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# redshift_grant.grants will be created
+ resource "redshift_grant" "grants" {
+ group = "xgroup"
+ id = (known after apply)
+ object_type = "table"
+ privileges = [
+ "delete",
+ "drop",
+ "insert",
+ "references",
+ "select",
+ "update",
]
+ schema = "xschema"
}
# redshift_group.group will be created
+ resource "redshift_group" "group" {
+ id = (known after apply)
+ name = "xgroup"
+ users = [
+ "xuser",
]
}
# redshift_schema.schema will be created
+ resource "redshift_schema" "schema" {
+ id = (known after apply)
+ name = "xschema"
+ owner = "user"
+ quota = 0
}
# redshift_user.user will be created
+ resource "redshift_user" "user" {
+ connection_limit = -1
+ create_database = false
+ id = (known after apply)
+ name = "xuser"
+ superuser = false
+ valid_until = "infinity"
}
Plan: 4 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
redshift_user.user: Creating...
redshift_group.group: Creating...
redshift_grant.grants: Creating...
redshift_schema.schema: Creating...
redshift_user.user: Creation complete after 2s [id=166]
redshift_grant.grants: Still creating... [10s elapsed]
redshift_grant.grants: Still creating... [20s elapsed]
redshift_grant.grants: Still creating... [30s elapsed]
redshift_grant.grants: Still creating... [40s elapsed]
redshift_grant.grants: Still creating... [50s elapsed]
redshift_grant.grants: Still creating... [1m0s elapsed]
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to redshift_grant.grants, provider "provider[\"registry.terraform.io/brainly/redshift\"]" produced an unexpected new value: Root resource
│ was present, but now absent.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
╷
│ Error: Could not create redshift group: pq: user "xuser" does not exist
│
│ with redshift_group.group,
│ on main.tf line 41, in resource "redshift_group" "group":
│ 41: resource "redshift_group" "group" {
│
╵
╷
│ Error: pq: user "user" does not exist
│
│ with redshift_schema.schema,
│ on main.tf line 46, in resource "redshift_schema" "schema":
│ 46: resource "redshift_schema" "schema" {
│
state after only has one resource: redshift_user.user