Skip to content

Cannot create role #6

@jagregory

Description

@jagregory

When I try to create a role, I get a 400 error from AWS with a syntax error, where ... is the role's password: {"message":"ERROR: syntax error at or near \"'...'\"\n Position: 23; SQLState: 42601"

resource "rdsdataservice_postgres_role" "app" {
  name         = local.app_username
  resource_arn = module.rds-aurora.cluster_arn
  secret_arn   = aws_secretsmanager_secret.master_credentials.arn
  login        = true
  password     = random_password.appuser_password.result
}

When I look at the request sent to AWS the SQL is invalid:

CREATE ROLE  PASSWORD '...'  WITH     INHERIT   LOGIN ;

It's missing role name, and seems to be completely wrong.

When I look at the provider's source it seems like the create SQL formatting is just invalid: https://github.com/awsiv/terraform-provider-rdsdataservice/blob/master/rdsdataservice/resource_rdsdataservice_postgres_role.go#L139

	sql := fmt.Sprintf("CREATE ROLE %s WITH %s %s %s %s %s;",
		password,
		superuser,
		createrole,
		createdatabase,
		inherit,
		login,
	)

The name is missing from format string at all, and presumably all the other arguments are shifted left one place making the SQL invalid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions