fbpx

Terraform not creating AWS Oracle DB due to Password Error

Problem – Terraform Response Error after doing atlantis apply -p project-name: Error: Error creating DB Instance: InvalidParameterValue: The parameter MasterUserPassword is not a valid password. Only printable ASCII characters besides ‘/’, ‘@’, ‘”‘, ‘ ‘ may be used. status code: 400, request id: fd652c3c-7026-4409-b648-7eb32fca0c2e, {…

Cause of problem: The original code used to generate the password in terraform is this

## Creating password for oracle DB
resource "random_string" "password" {
  length = 16
  upper = true
  lower = true
  number = true
  special= true -- PROBLEM HERE
  /* variables that when changed force a resource regeneration */
  keepers = {}
}

The above code is problematic because the special field was generating values that were not allowed in the password data.

Solution: Solution is to change the special field to false. Just removing the special field input doesn’t work because the default value for the special field is true.

I know this is confusing because in the terraform module documentation for random_string, it doesn’t specify that the default value is true. So, just deleting the special field would still generate the above error.

Here is the solution code:

## Creating password for oracle DB
resource "random_string" "password" {
  length = 16
  upper = true
  lower = true
  number = true
  special= false -- SOLUTION HERE
  /* variables that when changed force a resource regeneration */
  keepers = {}
}

I hope this helps.

One Comment

Leave a Comment

Scroll to Top