hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.8k stars 9.15k forks source link

AWS Aurora Postgress Cluster with Babelfish support - Login failed for user #25556

Closed dlok672 closed 2 years ago

dlok672 commented 2 years ago

Community Note

Terraform CLI and Terraform AWS Provider Version

Affected Resource(s)

Terraform Configuration Files

provider declared in a central script, provided for context olny

provider "aws" { region = var.region.af alias = "africa" }

resource "aws_rds_cluster" "rds_cluster_test" { availability_zones = ["af-south-1a", "af-south-1b", "af-south-1c"] backup_retention_period = "7" cluster_identifier = "npr-test-cluster" copy_tags_to_snapshot = true database_name = "testdb" db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.rds_cluster_test_pg.name db_subnet_group_name = aws_db_subnet_group.default_sn.name deletion_protection = true enabled_cloudwatch_logs_exports = [] engine = "aurora-postgresql" engine_mode = "provisioned" engine_version = "14.3" final_snapshot_identifier = npr-test-cluster-snapshot" iam_database_authentication_enabled = false iam_roles = [] kms_key_id = var.kms_key.af.data master_password = "11mpXX22345samAA" master_username = "testAdmin" preferred_backup_window = "23:00-00:00" preferred_maintenance_window = "sun:01:00-sun:02:00" provider = aws.africa skip_final_snapshot = true storage_encrypted = true vpc_security_group_ids = [aws_security_group.rds_security_group_psql.id]

tags = { Owner = "test" Environment = "dev" support = "testdb" } }

resource "aws_rds_cluster_instance" "rds_cluster_instance_test" {

cluster_identifier = aws_rds_cluster.rds_cluster_test.id instance_class = "db.t3.medium" count = 1 identifier = "npr-test-cluster-inst-0" engine = aws_rds_cluster.rds_cluster_test.engine engine_version = aws_rds_cluster.rds_cluster_test.engine_version

auto_minor_version_upgrade = true copy_tags_to_snapshot = true db_parameter_group_name = "default.aurora-postgresql14" db_subnet_group_name = aws_db_subnet_group.default_sn.name monitoring_interval = "0" monitoring_role_arn = "" performance_insights_enabled = false preferred_maintenance_window = "sat:08:00-sat:09:00" provider = aws.africa publicly_accessible = false

babelfish = true #Future support only

tags = { Owner = "test" Environment = "dev" support = "testdb" } }

resource "aws_security_group" "rds_security_group_psql" { name = "npr-test-cluster-sg" description = "Allow database connection for Postgres SQL" vpc_id = var.vpc_ids.af provider = aws.africa

ingress { from_port = 5432 description = "ingress-postgres" protocol = "tcp" to_port = 5432 cidr_blocks = ["10.0.0.0/8"] }

ingress { from_port = 1433 description = "ingress-mssql" protocol = "tcp" to_port = 1433 cidr_blocks = ["10.0.0.0/8"] }

egress { from_port = 0 protocol = "-1" to_port = 0 cidr_blocks = ["10.0.0.0/8"] }

tags = { Owner = "test" Environment = "dev" support = "testdb" } }

resource "aws_rds_cluster_parameter_group" "rds_cluster_test_pg" { name = "npr-test-cluster-pg" family = "aurora-postgresql14" provider = aws.africa

Enable babelfish to be active

parameter { name = "rds.babelfish_status" value = "on" apply_method = "pending-reboot" }

}

resource "aws_db_subnet_group" "default_sn" { name = "${local.naming_prefix}-db-subnet" subnet_ids = [var.subnet_ids.af.a3, var.subnet_ids.af.a0, var.subnet_ids.af.c2, var.subnet_ids.af.b1] provider = aws.africa tags = { Name = "RDS Default Subnet group" } }

resource "aws_cloudwatch_log_group" "rds_cluster_test_lg" { provider = aws.africa name = "/aws/rds/cluster/${aws_rds_cluster.rds_cluster_test.cluster_identifier}/postgresql" retention_in_days = 14 }

Debug Output

https://gist.github.com/dlok672/051138a809412a7e7d1c2dad43a2e603

Panic Output

Not applicable

Expected Behavior

  1. Terraform created the Aurora Postgress Cluster
  2. Created the postgress instance
  3. Created the Babelfish endpoints
  4. Connect to the primary instance via pgAdmin via port 5432
  5. Connect to the writer Babelfish endpoint via pgAdmin via port 5432
  6. Connect to the writer Babelfish endpoint via SSMS or sqlcmd via port 1433

Actual Behavior

  1. Terraform created the Aurora Postgress Cluster
  2. Created the postgress instance
  3. Created the Babelfish endpoints
  4. Connect to the primary instance via pgAdmin via port 5432
  5. Connect to the writer Babelfish endpoint via pgAdmin via port 5432
  6. Failed to connect to the writer Babelfish endpoint via SSMS or sqlcmd via port 1433 - "Login failed for user 'testAdmin' "

Steps to Reproduce

  1. Run the Terraform script to create the cluster

  2. Wait for the cluster to create in AWS

  3. Connect using pgAdmin as per above - confirm this is working for port 5432

  4. Connect using SSMS or sqlcmd via port 1433 as per step 6

  5. terraform apply

Important Factoids

Nothing specific

References

dlok672 commented 2 years ago

Solved this problem. Need to use lowercase for username.

github-actions[bot] commented 2 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.