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

import google_firestore_index skips important attributes #5588

Assignees
Labels

Comments

@filipzyzniewski-fexco
Copy link

filipzyzniewski-fexco commented Feb 5, 2020

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-firestore-index-import $ terraform -v
Terraform v0.12.20
+ provider.google v3.7.0
terraform-firestore-index-import $ 

Affected Resource(s)

  • google_firestore_index

Terraform Configuration Files

provider "google" {
  version = ">= 3.7.0"
}

terraform {
  required_version = ">= 0.12.20"
}

resource "google_firestore_index" "someindex" {
  project    = "someproject"
  collection = "somecollection"

  fields {
      field_path   = "permissions"
      array_config = "CONTAINS"
  }

  fields {
      field_path = "canonicalTime"
      order      = "DESCENDING"
  }

  fields {
      field_path = "__name__"
      order      = "DESCENDING"
  }
}

Debug Output

terraform import: https://gist.github.com/filipzyzniewski-fexco/1ef4b69786823491ed9df484f7530a37
subsequent terraform plan: https://gist.github.com/filipzyzniewski-fexco/b9e215ab40187cc5fc764799a18f5ccf

Expected Behavior

importing a google_firestore_index should set its collection and database attributes based on the components of its attribute name:

projects/someproject/databases/(default)/collectionGroups/somecollection/indexes/CICAgPi_lZUK => database = "(default)", collection = "somecollection"

terraform plan should report no changes after importing the example index.

Actual Behavior

As shown in https://gist.github.com/filipzyzniewski-fexco/b9e215ab40187cc5fc764799a18f5ccf

Steps to Reproduce

  1. terraform import 'google_firestore_index.someindex' 'projects/someproject/databases/(default)/collectionGroups/somecollection/indexes/CICAgPi_lZUK'
  2. terraform plan

Important Factoids

A Python script that I use to fix the state after importing: https://gist.github.com/filipzyzniewski-fexco/eca5e3ad86793a9de33ab73ab6e22f14

After using the script: https://gist.github.com/filipzyzniewski-fexco/06d46ab91b766a0f5d10c7ae77c95627

  • #0000
@ghost ghost added the bug label Feb 5, 2020
@filipzyzniewski-fexco filipzyzniewski-fexco changed the title import google_firestore_index skips important values import google_firestore_index skips important attributes Feb 5, 2020
@edwardmedia
Copy link
Contributor

edwardmedia commented Feb 5, 2020

@c2thorn After import, I see null for both fields collection and database in the imported state

      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "collection": null,
            "database": null,
            "fields": [
              {
                "array_config": "CONTAINS",
                "field_path": "permissions",
                "order": ""
              },
              {
                "array_config": "",
                "field_path": "canonicalTime",
                "order": "DESCENDING"
              },
              {
                "array_config": "",
                "field_path": "__name__",
                "order": "DESCENDING"
              }
            ],
            "id": "projects/myproject-1/databases/(default)/collectionGroups/somecollection/indexes/CICAgOjXh4EK",
            "name": "projects/myproject-1/databases/(default)/collectionGroups/somecollection/indexes/CICAgOjXh4EK",
            "project": "myproject-1",
            "query_scope": "COLLECTION",
            "timeouts": {
              "create": null,
              "delete": null
            }
          },
          "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwfSwic2NoZW1hX3ZlcnNpb24iOiIwIn0="
        }
      ]

But I do see something in both fields in tf show from the original state

resource "google_firestore_index" "someindex" {
  collection  = "somecollection"
  database    = "(default)"
  id          = "projects/myproject-1/databases/(default)/collectionGroups/somecollection/indexes/CICAgOjXh4EK"
  name        = "projects/myproject-1/databases/(default)/collectionGroups/somecollection/indexes/CICAgOjXh4EK"
  project     = "myproject-1"
  query_scope = "COLLECTION"

  fields {
      array_config = "CONTAINS"
      field_path   = "permissions"
  }
  fields {
      field_path = "canonicalTime"
      order      = "DESCENDING"
  }
  fields {
      field_path = "__name__"
      order      = "DESCENDING"
  }
}

@ghost
Copy link

ghost commented Mar 28, 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 Mar 28, 2020
@github-actions github-actions bot added service/firestore-dataplane 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.