Closed ghost closed 1 year ago
@lpqI can you see if below docs are helpful?
https://cloud.google.com/resource-manager/docs/tags/tags-supported-services
https://cloud.google.com/iam/docs/full-resource-names
For me, it works with below config. Make sure the dataset resides at the same region as what the location was given
resource "google_tags_location_tag_binding" "binding" {
parent = "//bigquery.googleapis.com/projects/myproject/datasets/issue14932"
tag_value = "tagValues/${google_tags_tag_value.value.name}"
location = "us-central1"
}
For import, below command works for me
terraform import google_tags_location_tag_binding.binding us-central1/tagBindings/%2F%2Fbigquery.googleapis.com%2Fprojects%2Fmyproject%2Fdatasets%2Fissue14932/tagValues/281475794261234
@edwardmedia thanks for your reply
unfortunately, the link you suggested didn't work
i could successfully import the resource
but I got the above error when I ran terraform plan
to make sure it was imported correctly
@lpqI how did you create the resource? Can you share the state of the imported one? Can you share the config for your terraform plan
?
@edwardmedia thanks for your reply
how did you create the resource?
i created these resources manually import is executed after creating
Can you share the state of the imported one?
dataset
{
"mode": "managed",
"type": "google_tags_location_tag_binding",
"name": "dataset",
"provider": "provider[\"registry.terraform.io/hashicorp/google\"]",
"instances": [
{
"index_key": "test-dataset-binding",
"schema_version": 0,
"attributes": {
"id": "asia-northeast1/tagBindings/%2F%2Fbigquery.googleapis.com%2Fprojects%2Ftest-project%2Fdatasets%2Ftest-dataset/tagValues/1234567890",
"location": "asia-northeast1",
"name": "tagBindings/%2F%2Fbigquery.googleapis.com%2Fprojects%2Fagj-groupdwh%2Fdatasets%2Ftest-dataset/tagValues/1234567890",
"parent": "//bigquery.googleapis.com/projects/test-project/datasets/test-dataset",
"tag_value": "tagValues/1234567890",
"timeouts": {
"create": null,
"delete": null
}
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxMjAwMDAwMDAwMDAwLCJkZWxldGUiOjEyMDAwMDAwMDAwMDB9LCJzY2hlbWFfdmVyc2lvbiI6IjAifQ=="
},
]
},
bucket
{
"mode": "managed",
"type": "google_tags_location_tag_binding",
"name": "bucket",
"provider": "provider[\"registry.terraform.io/hashicorp/google\"]",
"instances": [
{
"index_key": "test-bucket-binding",
"schema_version": 0,
"attributes": {
"id": "asia-northeast1/tagBindings/%2F%2Fstorage.googleapis.com%2Fprojects%2F_%2Fbuckets%2Ftest-buket/tagValues/1234567890",
"location": "asia-northeast1",
"name": "tagBindings/%2F%2Fstorage.googleapis.com%2Fprojects%2F_%2Fbuckets%2Ftest-buket/tagValues/1234567890",
"parent": "//storage.googleapis.com/projects/_/buckets/test-buket",
"tag_value": "tagValues/1234567890",
"timeouts": {
"create": null,
"delete": null
}
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxMjAwMDAwMDAwMDAwLCJkZWxldGUiOjEyMDAwMDAwMDAwMDB9LCJzY2hlbWFfdmVyc2lvbiI6IjAifQ=="
},
]
},
Can you share the config for your
terraform plan
?
i didn't use option for terraform plan
@lpqI have you tried updating the config with all the attributes you got from the imported and then run plan? The states look fine with me.
@edwardmedia thanks for your reply
i guess i am doing what you told me to do i had configure all parameters shown URL below, run import and plan https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_tags_location_tag_binding
@edwardmedia i had tried remove tfstate and import again, but i got same errors i used provider with version 4.69.1
provider "registry.terraform.io/hashicorp/google" {
version = "4.69.1"
}
@lpqI I assume you have updated the config before you run terraform plan
, right? Can you share the debug log for both import and plan?
@lpqI it looks like the provider was failing on finding the parent
. As I mentioned earlier, did you update the config before you run terraform plan
?
resource "google_tags_location_tag_binding" "dataset" {
parent = <---- did you provide a value here when you run plan
....
}
@edwardmedia
did you update the config before you run
terraform plan
?
yes, i am using csv to set the value specific values are
resource "google_tags_location_tag_binding" "dataset" {
parent = "//bigquery.googleapis.com/projects/test-project/datasets/all_c"
tag_value = "tagValues/1234567890"
location = "asia-northeast1"
}
@lpqI I don't understand what you meant below. Your config is is similar to what I provided which works for me. I have no clue why it doesn't work for you. Keep in mind, the error appears to complain about the value of parent. I would suggest you hardcode the config to see it works
yes, i am using csv to set the value
@edwardmedia
I would suggest you hardcode the config to see it works
i will try
@edwardmedia thanks for your advice
however, the cause of the error was not the for_each using CSV, but the import performed by another worker it seems that an error occurred because a tag that does not exist was imported with tag_bind βit worked fine after removing wrongs from tfstate file
@lpqI cool. Glad you have seen where is the problem. Any more issues (questions)?
@edwardmedia thanks for your asking me
i guess this is the root cause of this issue that it was able to import tag_bind that does not exist
for example,
if dataset as all_c with tag_value tv1 is correct pairs,
but pair of all_c and tv2 that does not exist was able to import
(i got type.googleapis.com/google.rpc.BadRequest
errors after importing)
i want error message with wrong pair, but i ended up importing successfully
@lpqI Cool, closing the issue now. Thanks
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Community Note
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 tohashibot
, a community member has claimed the issue already.Terraform Version
1.3.4
Affected Resource(s)
Terraform Configuration Files
Debug Output
Panic Output
Expected Behavior
terraform plan
exits without errorActual Behavior
end with error in
terraform plan
Steps to Reproduce
terraform plan
Important Factoids
i had imported google_tags_location_tag_binding with
terraform import
and triedterraform plan
to check if the import was successful the result was an error, so when I checked the log with TF_LOG=DEBUG, i had found that provider had accessed to the url https://asia-northeast1-cloudresourcemanager.googleapis.com//v3/tagBindings/?alt=json&pageSize=300&parent=upon careful checking the url, I got that the
parent
was not set (parent
set in terraform resource does not seem to be set)References