- 
                Notifications
    
You must be signed in to change notification settings  - Fork 264
 
Open
Description
Hi there,
Thank you for opening an issue. Please provide the following information:
Terraform Version
- docker image hashicorp/terraform:1.4
 - Installing cyrilgdn/postgresql v1.19.0...
 - Installed cyrilgdn/postgresql v1.19.0
 - Installed hashicorp/random v3.5.1 (signed by HashiCorp)
 - Installed hashicorp/aws v4.67.0 (signed by HashiCorp)
 
Affected Resource(s)
Please list the resources as a list, for example:
- postgresql_user_mapping
 
I have successful created a remote server using terraform and have mapped 2 local users to remote users using postgresql_user_mapping. However, I am unable to map the local public user to a remote user.
If I map the public user in SQL succeeds but using postgres_user_mapping fails.
-- SQL: succeeds
CREATE USER MAPPING FOR PUBLIC SERVER ep_modules_db_staging OPTIONS (user 'tsds_read_only', password 'XYZ')
-- Terraform: fails
resource "postgresql_user_mapping" "staging_public" {
  server_name = postgresql_server.remote_staging_server.server_name
  user_name   = var.lab_public_username             # "public"
  options = {
    user = var.staging_readonly_username            # tsds_read_only
    password = var.staging_readonly_password   # XYZ
  }
}
When it fails, it's because it's trying to find a public role. It appears not to recognize public as a keyword for the underlying SQL command.
Plan: 1 to add, 0 to change, 0 to destroy.
postgresql_user_mapping.staging_public: Creating...
╷
│ Error: Could not create user mapping: pq: role "PUBLIC" does not exist
│ 
│   with postgresql_user_mapping.staging_public,
│   on fdw.tf line 43, in resource "postgresql_user_mapping" "staging_public":
│   43: resource "postgresql_user_mapping" "staging_public" {
kinghuang, MattMencel and seboudry
Metadata
Metadata
Assignees
Labels
No labels