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

Creating Uptime Checks will error in the first try and succeed in the second #7015

Closed
aabedraba opened this issue Aug 13, 2020 · 5 comments
Closed
Assignees
Labels

Comments

@aabedraba
Copy link

Terraform Version

Terraform v0.12.26

Terraform Configuration Files

resource "google_compute_instance" "vm" {
  name         = local.instance_name
  machine_type = "n1-standard-1"

  boot_disk {
    initialize_params {
      image = module.gce-container-application.source_image
    }
  }

  tags = ["custom-tag"]

  network_interface {
    network = "default"

    access_config {
      // Ephemeral IP
    }
  }

  metadata = {
    gce-container-declaration = module.gce-container-application.metadata_value
    google-logging-enabled    = "true"
  }

  labels = {
    container-vm = module.gce-container-application.vm_container_label
  }

  service_account {
    scopes = [
      "https://www.googleapis.com/auth/cloud-platform",
    ]
  }
}

resource "google_monitoring_uptime_check_config" "http" {
  display_name = "invers-router-healthcheck"
  period       = "60s"
  timeout      = "15s"

  http_check {
    path = "/health"
    port = "8000"
  }

  monitored_resource {
    type = "gce_instance"
    labels = {
      project_id  = "greenmobility-staging"
      instance_id = google_compute_instance.vm.instance_id
      zone        = "europe-west4-a"
    }
  }

  content_matchers {
    content = "{\"Test"}"
  }
}
...

Debug Output

VM creates fine.

Crash Output

Error: Error creating UptimeCheckConfig: googleapi: Error 404: Error confirming monitored resource:
type: "gce_instance"

Expected Behavior

UptimeCheck waits for the VM to be created and then tries to be created.

Actual Behavior

UptimeCheck fails to be created as it waits for VM creation to finish. So in the second try it does get created.

Steps to Reproduce

terraform apply

Additional Context

References

@edwardmedia edwardmedia self-assigned this Aug 14, 2020
@edwardmedia
Copy link
Contributor

@aabedraba can you take a look below solution and see if that helps address your issue?

#6377

resource "null_resource" "delay" {
  provisioner "local-exec" {
    command = "sleep 60"
  }
  triggers = {
    "project" = "${google_project.project.id}"
  }

@edwardmedia
Copy link
Contributor

@aabedraba does that workaround work for you?

@edwardmedia
Copy link
Contributor

@aabedraba closing this as I have not heard back from you. Assuming this is no longer an issue. If not, please reopen it and let me know how you apply the suggestion. Thanks

@aabedraba
Copy link
Author

Hi Edward! Thanks for your solution. It worked fine!

For some reason I wasn't receiving notifications from this thread, excuse the lack of response.

@ghost ghost removed the waiting-response label Aug 30, 2020
@ghost
Copy link

ghost commented Sep 22, 2020

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 Sep 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants