Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Add new variable use_for_each so we can use for_each to create multiple resource instances. #92

Merged
merged 3 commits into from
Dec 8, 2022

Conversation

lonegunmanb
Copy link
Member

Describe your changes

This module was created before Terraform introduce for_each, and according to the document:

If your instances are almost identical, count is appropriate. If some of their arguments need distinct values that can't be directly derived from an integer, it's safer to use for_each.

Since the azurerm_subnet resources were created from var.subnet_names and these subnets are not identical, we should use for_each instead of count. But for the users that already maintained existing resources by this module, migrate from count to for_each requires heavy manually state move operations with extremely caution.

This pull request replicated a new azurerm_subnet which used for_each, and we provide a new toggle variable named use_for_each, this toggle is a switcher between count set and for_each set. Now user can set var.use_for_each to true to use for_each, and users who're maintaining existing resources could keep this toggle false to avoid potential breaking change.

Issue number

#000

Checklist before requesting a review

  • The pr title can be used to describe what this pr did in CHANGELOG.md file
  • I have executed pre-commit on my machine
  • I have passed pr-check on my machine

Thanks for your cooperation!

@lonegunmanb lonegunmanb temporarily deployed to acctests December 8, 2022 07:47 — with GitHub Actions Inactive
@lonegunmanb lonegunmanb temporarily deployed to acctests December 8, 2022 08:22 — with GitHub Actions Inactive
Copy link
Collaborator

@jiaweitao001 jiaweitao001 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @lonegunmanb

@lonegunmanb lonegunmanb merged commit da6ba88 into Azure:master Dec 8, 2022
@lonegunmanb lonegunmanb deleted the for_each branch May 6, 2023 05:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants