_This issue was originally opened by @starkers as hashicorp/terraform#17598. It was migrated here as a result of the provider split. The original body of the issue is below._
0.10.8
data "terraform_remote_state" "kube-resources" {
backend = "gcs"
config {
project = "${var.project}"
bucket = "${var.project}-terraform-state"
path = "${var.env}/kube-resources/terraform.tfstate"
}
}
## connect volumes
# https://www.terraform.io/docs/providers/kubernetes/r/persistent_volume.html
resource "kubernetes_persistent_volume" "drone" {
metadata {
name = "example-${data.terraform_remote_state.kube-resources.drone_size}"
}
spec {
capacity {
/* storage = "5Gi" */
storage = "${data.terraform_remote_state.kube-resources.drone_size}Gi"
}
access_modes = ["ReadWriteOnce"]
persistent_volume_source {
gce_persistent_disk {
pd_name = "${data.terraform_remote_state.kube-resources.drone_name}"
fs_type = "ext4"
}
}
}
}
Correctly get the size of the volume from exported data..
(in this example param storage = "5Gi" is used)
Terraform will perform the following actions:
+ kubernetes_persistent_volume.drone
id: <computed>
metadata.#: "1"
metadata.0.generation: <computed>
metadata.0.name: "example-5"
metadata.0.resource_version: <computed>
metadata.0.self_link: <computed>
metadata.0.uid: <computed>
spec.#: "1"
spec.0.access_modes.#: "1"
spec.0.access_modes.1245328686: "ReadWriteOnce"
spec.0.capacity.%: "1"
spec.0.capacity.storage: "5Gi"
spec.0.persistent_volume_reclaim_policy: "Retain"
spec.0.persistent_volume_source.#: "1"
spec.0.persistent_volume_source.0.gce_persistent_disk.#: "1"
spec.0.persistent_volume_source.0.gce_persistent_disk.0.fs_type: "ext4"
spec.0.persistent_volume_source.0.gce_persistent_disk.0.pd_name: "drone"
terraform plan
Error: kubernetes_persistent_volume.drone: spec.0.capacity.storage ("${data.terraform_remote_state.kube-resources.drone_size}Gi"): quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'
Create a volume and import the output... Example:
resource "google_compute_disk" "drone" {
name = "drone"
type = "pd-ssd"
zone = "${var.zone}"
size = 5
}
output "drone_size" { value = "${google_compute_disk.drone.size}" }
output "drone_name" { value = "${google_compute_disk.drone.name}" }
output "drone_zone" { value = "${google_compute_disk.drone.zone}" }
Nothing fancy here..
I'm happy to answer any questions or provide more details if I can help
Hi @starkers, here are some leads:
What does echo data.terraform_remote_state.kube-resources.drone_size | terraform console output?
Have you tried running it with TF_LOG=trace ?
I'm currently investigating, so far it appears the variable actually isn't interpolating in the capacity which is strange. Even stranger is the same variable used in the metadata.name interpolates just fine.
So after lots of debugging it appears to be an issue with Terraform that might be fixed with the next release (Terraform 0.12). We do have a workaround though:
@starkers try this in your config:
capacity = "${map("storage", "${data.terraform_remote_state.kube-resources.drone_size}Gi")}"
Thanks man, I'll do some tests to verify..
The workaround seems to do the trick. Is there an issue on terraform proper that we can follow to address this?
Still seems to be an issue in Terraform 0.12, at least in a module context. Not sure if not in a module. Workaround does work.
Error: spec.0.capacity.storage ("74D93920-ED26-11E3-AC10-0800200C9A66"): quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'
on ../../modules/shared_volumes/persistent_volumes.tf line 23, in resource "kubernetes_persistent_volume" "aks_pv__config":
23: resource "kubernetes_persistent_volume" "aks_pv__config" {
I can confirm that upgrading to 1.8.0 fixes the issue in 0.12
cc @dcfsc
This issue has been open 180 days with no activity. If this issue is reproducible with the latest version of the provider and with Terraform 0.12, please comment. Otherwise this issue will be closed in 30 days.
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!
Most helpful comment
So after lots of debugging it appears to be an issue with Terraform that might be fixed with the next release (Terraform 0.12). We do have a workaround though:
@starkers try this in your config: