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

use for_each instead of count to create resource #86

Conversation

adrian-gierakowski
Copy link
Contributor

This prevents unnencesary recreation of resources when content/order of the
names list changes.

Addresses issue mentioned in: https://github.com/terraform-google-modules/cloud-foundation-fabric/tree/73b7613cc062491305ebfabf8a8b1db0c53fc55b/foundations#things-to-be-aware-of

@comment-bot-dev
Copy link

comment-bot-dev commented Sep 21, 2020

Thanks for the PR! 🚀
✅ Lint checks have passed.

@adrian-gierakowski
Copy link
Contributor Author

running integration tests locally but it's taking a long time as I'm seeing the following:

module.project.module.project-factory.module.gcloud_disable.null_resource.upgrade[0] (local-exec): Your current Cloud SDK version is: 281.0.0
module.project.module.project-factory.module.gcloud_disable.null_resource.upgrade[0] (local-exec): You will be upgraded to version: 310.0.0

Since the docker image from which the tests are ran already comes with gcloud pre-installed it would be nice if the installed version was sufficient to avoid the extra download during a test run

@morgante
Copy link
Contributor

@adrian-gierakowski Newer versions avoid that.

This is the error in tests:

       Error: Incorrect attribute value type
       
         on ../../../main.tf line 158, in resource "google_storage_bucket_object" "folders":
        158:   bucket   = google_storage_bucket.buckets[each.value.bucket]
           |----------------
           | each.value.bucket is "two"
           | google_storage_bucket.buckets is object with 2 attributes
       
       Inappropriate value for attribute "bucket": string required.

This prevents unnencesary recreation of resources when content/order of the
names list changes.

Addresses issue mentioned in: https://github.com/terraform-google-modules/cloud-foundation-fabric/tree/73b7613cc062491305ebfabf8a8b1db0c53fc55b/foundations#things-to-be-aware-of

WARNING: this is a breaking change as the terraform state created before this
change will be incompatible with state expected after the change. This can
be fixed with `terraform state mv`.
@adrian-gierakowski adrian-gierakowski force-pushed the use-for-each-instead-of-count-to-create-resources branch from 8573f87 to 80b225f Compare September 21, 2020 19:26
@adrian-gierakowski
Copy link
Contributor Author

@morgante integration tests are now passing, not sure about the other 2 jobs

Copy link
Contributor

@morgante morgante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding this.

@morgante
Copy link
Contributor

Before release, we'll also need an upgrade guide / script added like this one.

@morgante morgante merged commit af73533 into terraform-google-modules:master Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants