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

Panic on google_sql interface {} is nil, not map[string]interface {} #2220

Closed
meyskens opened this issue Oct 10, 2018 · 5 comments · Fixed by #2229
Closed

Panic on google_sql interface {} is nil, not map[string]interface {} #2220

meyskens opened this issue Oct 10, 2018 · 5 comments · Fixed by #2229
Assignees

Comments

@meyskens
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
  • If an issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to "hashibot", a community member has claimed the issue already.

Terraform Version

Terraform v0.11.8
+ provider.google v1.19.0
+ provider.google-beta v1.19.0

Affected Resource(s)

  • google_sql_user
  • google_sql_database_instance

Terraform Configuration Files

module "lookout_staging_cloudsql" {
  source      = "../../modules/google-cloud/sql" 
  project = "srcd-public-development"
  name = "lookout-staging"
  machine_type = "db-f1-micro"
  user_name = "maartje"
  user_host = "*"
  user_password = "<redacted>"
  db_name = "lookout"
}
resource "google_sql_database_instance" "primary" {
  name             = "${var.name}-primary"
  region           = "${var.region}"
  project          = "${var.project}"
  database_version = "POSTGRES_9_6"

  settings {
    tier              = "${var.machine_type}"
    disk_type         = "${var.disk_type}"
    disk_size         = "${var.disk_size}"
    disk_autoresize   = "${var.disk_autoresize}"
    activation_policy = "ALWAYS"
    availability_type = "REGIONAL"
    replication_type  = "${var.replication_type}"

    backup_configuration {
      enabled = true
    }
  }
}

resource "google_sql_database_instance" "secondary" {
  name                 = "${var.name}-secondary"
  region               = "${var.region}"
  project              = "${var.project}"
  database_version     = "POSTGRES_9_6"
  master_instance_name = "${google_sql_database_instance.primary.name}"

  settings {
    tier              = "${var.machine_type}"
    disk_type         = "${var.disk_type}"
    disk_size         = "${var.disk_size}"
    disk_autoresize   = "${var.disk_autoresize}"
    activation_policy = "ALWAYS"
    availability_type = "REGIONAL"
    replication_type  = "${var.replication_type}"
  }
}

resource "google_sql_user" "default" {
  name     = "${var.user_name}"
  project  = "${var.project}"
  instance = "${google_sql_database_instance.primary.name}"
  host     = "${var.user_host}"
  password = "${var.user_password}"
}

resource "google_sql_database" "default" {
  name     = "${var.db_name}"
  project  = "${var.project}"
  instance = "${google_sql_database_instance.primary.name}"
  charset  = "UTF8"   
}

Panic Output

https://gist.github.com/meyskens/be4194a44bad433060bfad952e8708ec

Expected Behavior

Should have created the resources.

Actual Behavior

Panics after creating the primary CloudSQL instance.

Steps to Reproduce

  1. terraform plan -out plan.out
  2. terraform apply plan.out

References

@ghost ghost added the bug label Oct 10, 2018
@rileykarson
Copy link
Collaborator

rileykarson commented Oct 10, 2018

I'm having trouble reproducing this - would you be able to post a minimal config?

When I try something like the config I've posted below I don't get an error.

resource "google_sql_database_instance" "primary" {
  provider         = "google-beta"
  name             = "somename-primary"
  database_version = "POSTGRES_9_6"
  region           = "us-central1"

  settings {
    tier              = "db-f1-micro"
    disk_type         = "PD_SSD"
    disk_size         = "50"
    disk_autoresize   = "false"
    activation_policy = "ALWAYS"
    availability_type = "REGIONAL"
    replication_type  = "SYNCHRONOUS"

    backup_configuration {
      enabled = true
    }
  }
}

resource "google_sql_database_instance" "secondary" {
  provider             = "google-beta"
  name                 = "somename-secondary"
  database_version     = "POSTGRES_9_6"
  master_instance_name = "${google_sql_database_instance.primary.name}"
  region               = "us-central1"

  settings {
    tier              = "db-f1-micro"
    disk_type         = "PD_SSD"
    disk_size         = "50"
    disk_autoresize   = "false"
    activation_policy = "ALWAYS"
    replication_type  = "SYNCHRONOUS"
  }
}

provider "google-beta" {
}

@meyskens
Copy link
Author

@rileykarson thanks for the fast reply. I did just try to replicate it in test config to report it here but I did not get the error anymore. Will continue to investigate this.

@meyskens
Copy link
Author

I think i found the problem here. In my original code I kept replica_configuration empty as I had commented something out. Which to keep it clean in this ticked I deleted. I removed and it is creating now.

replica_configuration {
  // commented code
}

@paddycarver
Copy link
Contributor

I believe this should be fixed with the release of v1.19.1. Please update your provider, and feel free to comment if you continue to experience problems.

@ghost
Copy link

ghost commented Nov 16, 2018

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants