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

Unable to import google logging metric using terraform #5867

Closed
pkaramol opened this issue Mar 10, 2020 · 3 comments · Fixed by GoogleCloudPlatform/magic-modules#3270, #5944 or hashicorp/terraform-provider-google-beta#1876
Assignees
Labels

Comments

@pkaramol
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.14

Affected Resource(s)

  • google_logging_metric

Terraform Configuration Files

resource "google_logging_metric" "proservices_run" {
  name   = "user/proservices-run"
  filter = "resource.type=gae_app AND severity>=ERROR"
  project = "${google_project.service.project_id}"
  metric_descriptor {
    metric_kind = "DELTA"
    value_type  = "INT64"
  }

Debug Output

pkaramol@terraform-admin:~/systems-terraform/envs_prep/testing/infrastructure/softwareops/gke-k8s-env$ terragrunt import google_logging_metric.proservices_run proservices-run
[terragrunt] [/home/pkaramol/systems-terraform/envs_prep/testing/infrastructure/softwareops/gke-k8s-env] 2020/03/10 13:56:36 Running command: terraform --version
[terragrunt] 2020/03/10 13:56:36 Reading Terragrunt config file at /home/pkaramol/systems-terraform/envs_prep/testing/infrastructure/softwareops/gke-k8s-env/terraform.tfvars
[terragrunt] 2020/03/10 13:56:36 Terraform files in /home/pkaramol/systems-terraform/envs_prep/testing/infrastructure/softwareops/gke-k8s-env/.terragrunt-cache/jw2h1nB1aKl9Lf_vEwZbmHxapE4/rti-M4bonkWtX0PJ1P2uOJ-mTB0/organization/infrastructure/environments/gke-k8s-env are up to date. Will not download again.
[terragrunt] 2020/03/10 13:56:36 Copying files from /home/pkaramol/systems-terraform/envs_prep/testing/infrastructure/softwareops/gke-k8s-env into /home/pkaramol/systems-terraform/envs_prep/testing/infrastructure/softwareops/gke-k8s-env/.terragrunt-cache/jw2h1nB1aKl9Lf_vEwZbmHxapE4/rti-M4bonkWtX0PJ1P2uOJ-mTB0/organization/infrastructure/environments/gke-k8s-env
[terragrunt] 2020/03/10 13:56:36 Setting working directory to /home/pkaramol/systems-terraform/envs_prep/testing/infrastructure/softwareops/gke-k8s-env/.terragrunt-cache/jw2h1nB1aKl9Lf_vEwZbmHxapE4/rti-M4bonkWtX0PJ1P2uOJ-mTB0/organization/infrastructure/environments/gke-k8s-env
[terragrunt] 2020/03/10 13:56:36 Skipping var-file /home/pkaramol/systems-terraform/envs_prep/testing/infrastructure/softwareops/gke-k8s-env/ignore as it does not exist
[terragrunt] 2020/03/10 13:56:36 Skipping var-file ./secrets.auto.tfvars as it does not exist
[terragrunt] 2020/03/10 13:56:36 Backend gcs has not changed.
[terragrunt] 2020/03/10 13:56:36 Detected 1 Hooks
[terragrunt] 2020/03/10 13:56:36 Running command: terraform import -var-file=/home/pkaramol/systems-terraform/envs_prep/testing/infrastructure/softwareops/gke-k8s-env/../../../config.tfvars -var-file=/home/pkaramol/systems-terraform/envs_prep/testing/infrastructure/softwareops/gke-k8s-env/../../../config.tfvars -var-file=/home/pkaramol/systems-terraform/envs_prep/testing/infrastructure/softwareops/gke-k8s-env/../config.auto.tfvars -var-file=/home/pkaramol/systems-terraform/envs_prep/testing/infrastructure/softwareops/gke-k8s-env/../../../secrets.auto.tfvars -var-file=./microservice_vars.auto.tfvars google_logging_metric.proservices_run proservices-run
google_logging_metric.proservices_run: Importing from ID "proservices-run"...
google_logging_metric.proservices_run: Import complete!
  Imported google_logging_metric (ID: proservices-run)
google_logging_metric.proservices_run: Refreshing state... (ID: proservices-run)

Error: google_logging_metric.proservices_run (import id: proservices-run): 1 error occurred:
	* import google_logging_metric.proservices_run result: proservices-run: google_logging_metric.proservices_run: project: required field is not set

Expected Behavior

The resource should have been imported

Actual Behavior

Import fails

@ghost ghost added the bug label Mar 10, 2020
@edwardmedia edwardmedia self-assigned this Mar 10, 2020
@edwardmedia
Copy link
Contributor

edwardmedia commented Mar 10, 2020

@ndmckinley Besides, in the tf import, I see it calls /v2/projects/myproject/metrics/proservices_run. Is this the right api? Below is what I got from gcloud and it seems calling one in https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.metricDescriptors/get instead.

createTime: '2020-03-10T18:22:44.474993312Z'
filter: resource.type=gae_app AND severity>=ERROR
metricDescriptor:
  metricKind: DELTA
  name: projects/myproject/metricDescriptors/logging.googleapis.com/user/proservices-run
  type: logging.googleapis.com/user/proservices-run
  unit: '1'
  valueType: INT64
name: proservices-run
updateTime: '2020-03-10T18:22:44.474993312Z'

@nat-henderson
Copy link
Contributor

When this change is released, which should be a week from Monday, you will be able to import resources like this by running terraform import google_logging_metric.proservices_run "my-project proservices-run"

@ghost
Copy link

ghost commented Apr 20, 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 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.