问题
I'm trying to import a google_storage_bucket
storage bucket in my Terraform state:
terraform import module.bf-nathan.google_storage_bucket.assets-bucket my-bucket
However, it fails as follows:
module.bf-nathan.google_storage_bucket.assets-bucket: Importing from ID "my-bucket"...
module.bf-nathan.google_storage_bucket.assets-bucket: Import complete! Imported google_storage_bucket (ID: next-assets-bf-nathan-botfront-cloud)
module.bf-nathan.google_storage_bucket.assets-bucket: Refreshing state... (ID: next-assets-bf-nathan-botfront-cloud)
Error: module.bf-nathan.provider.kubernetes: 1:11: unknown variable accessed: var.cluster_ip in:
https://${var.cluster_ip}
The refreshing step doesn't work. I ran the command from the project's root where a terraform.tfvars
file exists.
I tried adding -var-file=terraform.tfvars
but no luck.
Note that the variables are correctly interpolated with all other terraform commands.
It's worth noting that the bucket in question is defined in a module and not in the main.tf
. Here is how the bucket is declared:
resource "google_storage_bucket" "assets-bucket" {
name = "${local.assets_bucket_name}"
storage_class = "MULTI_REGIONAL"
force_destroy = true
}
```
来源:https://stackoverflow.com/questions/59885641/importing-a-google-storage-bucket-resource-in-terraform-state-fails