ContainerSolutions / terraform-examples

Simple and idiomatic examples of various Terraform functions and features.
https://containersolutions.github.io/terraform-examples/
159 stars 51 forks source link

Main broken #31

Closed ianmiell closed 3 years ago

ianmiell commented 3 years ago

Tomasz Tarczynski I’ve spotted one issue after your last change with renaming variables (https://github.com/ContainerSolutions/terraform-examples/commit/529f675b0255ebeee996afec737e597aac6c3c54) The variable names are now unique. But it breaks one functionality here: after that last commit variable projectid (for google examples) changed to changeme_project_id find google -name main.tf | xargs egrep 'variable.+project_id' google/google_compute_instance/simple/main.tf:variable "changeme_google_compute_instance_simple_project_id" { google/google_container_cluster/separate_node_pool/main.tf:variable "changeme_google_container_cluster_separate_node_pool_project_id" { google/google_container_cluster/simple/main.tf:variable "changeme_google_container_cluster_simple_project_id" { google/google_container_cluster/cluster_and_deployment/main.tf:variable "changeme_google_container_cluster_cluster_and_deployment_project_id" { google/google_container_cluster/vpc_native_cluster/main.tf:variable "changeme_google_container_cluster_vpc_native_cluster_project_id" { google/google_compute_network/simple/main.tf:variable "changeme_google_compute_network_simple_project_id" { google/google_compute_attached_disk/count/main.tf:variable "changeme_google_compute_attached_disk_count_project_id" { google/google_compute_attached_disk/simple/main.tf:variable "changeme_google_compute_attached_disk_simple_project_id" { google/google_compute_disk/simple/main.tf:variable "changeme_google_compute_disk_simple_project_id" { google/google_storage_bucket/simple/main.tf:variable "changeme_google_storage_bucket_simple_project_id" { but we want to set this one with an environment variable, see here: https://github.com/ContainerSolutions/terraform-examples/blob/main/bin/shared_google.sh#L15-L21 if [ -z "$TF_VAR_project_id" ] then echo "If you want to suppress this input, run 'export TF_VAR_project_id='" echo "To find your current Project ID, run 'gcloud config get-value project'" echo 'Input TF_VAR_project_id' read -r TF_VAR_project_id fi So I think we cannot make the project_id variable name unique and still have this working. Should we maybe say that this one is an exception (and add some conditional to the check_non_unique_variable.sh script?

ianmiell commented 3 years ago

Fixed by Tomasz