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

Predict serviceId based on service runner location #3493

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alx-andru
Copy link

@alx-andru alx-andru commented Aug 8, 2021

The prediction of the serviceId is based on a hard-coded location (America/Los_Angeles) which, when run in a different time zone can cause a date change and the prediction is off by a day. My guess might be that the initial tests were run against the us-west2 Cloud Run location and fully in Terraform Cloud.

Example when applying following resource with the Execution Mode set to Local:

resource "google_endpoints_service" "openapi_service" {
  service_name = "my-service-name"
  project      = "my-gcp-projectId"
  openapi_config = sensitive(templatefile("./swagger.json", {
    host = "my-service-name"
  }))
}

I'm presented with the predicted service Id which is a day behind: "2021-08-08r5" -> "2021-08-07r0"

  # module.my-api-cloud-endpoints-module.google_endpoints_service.openapi_service will be updated in-place
  ~ resource "google_endpoints_service" "openapi_service" {
      ~ config_id      = "2021-08-08r5" -> "2021-08-07r0"
        id             = "my-service-name"
      ~ openapi_config = (sensitive)
        # (5 unchanged attributes hidden)
    }

Rather than setting a hard-coded location, we are utilizing the system Location.

Note
I'm not a go developer and based my proposed change purely on reading the source code and finding the hopeful right use of Location from the Go-Lang time documentation.

Related issue: hashicorp/terraform-provider-google#6713

In draft to allow for discussion around the proposed change

The prediction of the serviceId is based on a hard-coded location (`America/Los_Angeles`) which, when run in a different time zone can cause a date change and the prediction is off by a day.

Example when applying following resource with the `Execution Mode` set to `Local`: 
```hcl
resource "google_endpoints_service" "openapi_service" {
  service_name = "my-service-name"
  project      = "my-gcp-projectId"
  openapi_config = sensitive(templatefile("./swagger.json", {
    host = "my-service-name"
  }))
}
```
I'm presented with the predicted service Id which is a day behind

```hcl
  # module.my-api-cloud-endpoints-module.google_endpoints_service.openapi_service will be updated in-place
  ~ resource "google_endpoints_service" "openapi_service" {
      ~ config_id      = "2021-08-08r5" -> "2021-08-07r0"
        id             = "my-service-name"
      ~ openapi_config = (sensitive)
        # (5 unchanged attributes hidden)
    }
```

Rather than setting a hard-coded location, we are utilizing the system Location.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant