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

Resource google_cloud_run_service doesn't allow using attribute status.url #4908

Closed
bdubertret opened this issue Nov 14, 2019 · 7 comments
Closed
Labels
bug forward/review In review; remove label to forward service/run

Comments

@bdubertret
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.12.14
+ provider.google-beta v2.20.0

Affected Resource(s)

  • google_cloud_run_service

Terraform Configuration Files

variable "google_project" {
}

provider "google-beta" {
    project = var.google_project
}
resource "google_cloud_run_service" "service" {
    name = "test-echo"
    location = "europe-west1"
    provider = "google-beta"

    metadata {
        namespace = var.google_project
    }

    spec {
        containers {
            image = "eu.gcr.io/${var.google_project}/echo-server"
        }
    }
}

output "url" {
    value = google_cloud_run_service.service.status.url
}

Debug Output

https://gist.github.com/bdubertret/6a8a322be695034120d71c257e979d6d

Expected Behavior

Terraform should output the Cloud Run service url

Actual Behavior

Running terraform apply gives :

Error: Unsupported attribute

  on main.tf line 25, in output "url":
  25:     value = google_cloud_run_service.service.status.url

This value does not have any attributes.

Steps to Reproduce

  1. terraform apply

References

This pull request introduces the status.url attribute in google_cloud_run_service but something seems to be missing for it to fulfill its role

@ghost ghost added the bug label Nov 14, 2019
@bdubertret bdubertret changed the title Resource google_cloud_run_service doesn't allow using attribute status.url Resource google_cloud_run_service doesn't allow using attribute status.url Nov 14, 2019
@rileykarson
Copy link
Collaborator

Hey @bdubertret! This is actually a variant of #4091. At creation time, the API doesn't make all of the attributes available.

@bdubertret
Copy link
Author

@rileykarson I agree there is a problem at creation time, but even once it's created, when the status attribute is populated, the output also fails, as shown here (edited to replace personal informations with [XXX]) :

$ terraform show
# google_cloud_run_service.service:
resource "google_cloud_run_service" "service" {
    id       = "test-echo"
    location = "europe-west1"
    name     = "test-echo"
    project  = "[XXX]"
    status   = [
        {
            conditions                   = [
                {
                    message = ""
                    reason  = ""
                    status  = "True"
                    type    = "Ready"
                },
                {
                    message = ""
                    reason  = ""
                    status  = "True"
                    type    = "ConfigurationsReady"
                },
                {
                    message = ""
                    reason  = ""
                    status  = "True"
                    type    = "RoutesReady"
                },
            ]
            latest_created_revision_name = "test-echo-wtjm5"
            latest_ready_revision_name   = "test-echo-wtjm5"
            observed_generation          = 1
            url                          = "https://test-echo-quz4e5hcja-ew.a.run.app"
        },
    ]

    metadata {
        annotations      = {
            "serving.knative.dev/creator"      = "[XXX]"
            "serving.knative.dev/lastModifier" = "[XXX]"
        }
        generation       = 1
        labels           = {
            "cloud.googleapis.com/location" = "europe-west1"
        }
        namespace        = "[XXX]"
        resource_version = "AAWXn/AnrsA"
        self_link        = "/apis/serving.knative.dev/v1alpha1/namespaces/[XXX]/services/test-echo"
        uid              = "8420f51b-1ea4-45d9-9a38-9b2fbfec20e8"
    }

    spec {
        container_concurrency = 0

        containers {
            args    = []
            command = []
            image   = "eu.gcr.io/[XXX]/echo-server"
        }
    }
}

So even when this information is available, terraform still considers the output value unavailable :

$ terraform apply -auto-approve

Error: Unsupported attribute

  on main.tf line 25, in output "url":
  25:     value = google_cloud_run_service.service.status.url

This value does not have any attributes.

Also, using terraform state show fails on this resource :

$ terraform state show google_cloud_run_service.service
# google_cloud_run_service.service:
# missing schema for provider "google"

I'm not very up to date as to the roles between magic modules and the terraform provider, but it seems like something is lacking, that's maybe not limited to the availability of the status attribute?

@rileykarson
Copy link
Collaborator

Can you try a terraform refresh prior to terraform apply? If that errors, try -target=google_cloud_run_service.service for the Cloud Run resource.

terraform state show not working is unrelated to this- hashicorp/terraform#22010 is the issue for that.

@rileykarson
Copy link
Collaborator

Also, do you mind trying this syntax instead? Unintuitively, nested objects in Terraform are treated as 1-element lists.

google_cloud_run_service.service.status[0].url should be the correct syntax, I believe.

@bdubertret
Copy link
Author

@rileykarson Using google_cloud_run_service.service.status[0].url works, but only after a terraform refresh which is indeed caused by the initialization bug #4091 you mentioned. Without a refresh, the output value is empty. Thanks for the help!

@rileykarson
Copy link
Collaborator

Great! Sorry for your experience here. It looks like we have a PR out to poll for a ready state, so this should be fixed in 3.1.0.

@ghost
Copy link

ghost commented Dec 16, 2019

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 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Dec 16, 2019
@github-actions github-actions bot added service/run forward/review In review; remove label to forward labels Jan 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug forward/review In review; remove label to forward service/run
Projects
None yet
Development

No branches or pull requests

2 participants