Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random_password resource not working? #69

Closed
Bharathkumarraju opened this issue Aug 22, 2019 · 4 comments
Closed

Random_password resource not working? #69

Bharathkumarraju opened this issue Aug 22, 2019 · 4 comments

Comments

@Bharathkumarraju
Copy link

Bharathkumarraju commented Aug 22, 2019

resource "random_password" "db_password" {
  length = 16
  special = true
  override_special = "!#()-[]<>"
}

resource "aws_db_instance" "bharaths_mysql" {
  instance_class = "db.t2.micro"
  identifier_prefix = "bharaths-terraform-up-and-running"
  engine = "mysql"
  allocated_storage = 10
  name = "bharaths_example_database"
  username = "bharath_admin"
  skip_final_snapshot     =  true
  apply_immediately = true
  password = random_password.db_password.id
  lifecycle {
    ignore_changes = ["password"]
  }
}

It is throwing error as below. And while running terraform apply it still displaying as id=None

random_password.db_password: Creating...
random_password.db_password: Creation complete after 0s [id=none]
aws_db_instance.bharaths_mysql: Creating...

Error: Error creating DB Instance: InvalidParameterValue: The parameter MasterUserPassword is not a valid password because it is shorter than 8 characters.
        status code: 400, request id: 2c27c0b3-811c-41c0-89e3-8a455ba52c9e, {
  AllocatedStorage: 10,
  AutoMinorVersionUpgrade: true,
  BackupRetentionPeriod: 0,
  CopyTagsToSnapshot: false,
  DBInstanceClass: "db.t2.micro",
  DBInstanceIdentifier: "bharaths-terraform-up-and-running20190822040017255400000001",
  DBName: "bharaths_example_database",
  DeletionProtection: false,
  Engine: "mysql",
  EngineVersion: "",
  MasterUserPassword: "********",
  MasterUsername: "bharath_admin",
  PubliclyAccessible: false,
  StorageEncrypted: false,
  Tags: []
}

  on main.tf line 23, in resource "aws_db_instance" "bharaths_mysql":
  23: resource "aws_db_instance" "bharaths_mysql" {


Releasing state lock. This may take a few moments...
Bharaths-MacBook-Pro:mysql bharathdasaraju$ 

any workaround for this?

@Bharathkumarraju
Copy link
Author

When i use random_string it is showing password as below..

code

resource "random_string" "db_password" {
  length = 16
  special = true
  override_special = "!#()-[]<>"
}

resource "aws_db_instance" "bharaths_mysql" {
  instance_class = "db.t2.micro"
  identifier_prefix = "bharaths-terraform-up-and-running"
  engine = "mysql"
  allocated_storage = 10
  name = "bharaths_example_database"
  username = "bharath_admin"
  skip_final_snapshot     =  true
  apply_immediately = true
  password = random_string.db_password.result
  lifecycle {
    ignore_changes = ["password"]
  }
}

output

random_string.db_password: Creating...
random_string.db_password: Creation complete after 0s [id=Z29ZTNntBzwfjeAg]
aws_db_instance.bharaths_mysql: Creating...
aws_db_instance.bharaths_mysql: Still creating... [10s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [20s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [30s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [40s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [50s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [1m0s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [1m10s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [1m20s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [1m30s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [1m41s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [1m51s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [2m1s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [2m11s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [2m21s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [2m31s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [2m41s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [2m51s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [3m1s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [3m11s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [3m21s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [3m31s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [3m41s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [3m51s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [4m1s elapsed]
aws_db_instance.bharaths_mysql: Still creating... [4m11s elapsed]
aws_db_instance.bharaths_mysql: Creation complete after 4m14s [id=bharaths-terraform-up-and-running20190822061908468900000001]

Apply complete! Resources: 2 added, 0 changed, 1 destroyed.
Releasing state lock. This may take a few moments...
Bharaths-MacBook-Pro:mysql bharathdasaraju$

@techspeque
Copy link

techspeque commented Nov 7, 2019

@Bharathkumarraju Instead of ID for the password you need to use:

${random_password.db_password.result}

@Bharathkumarraju
Copy link
Author

Thanks @techspeque worked!!!

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants