diff options
| author | Colin Wilk <colin.wilk@tum.de> | 2023-06-04 11:13:59 +0200 |
|---|---|---|
| committer | Colin Wilk <colin.wilk@tum.de> | 2023-06-04 11:20:37 +0200 |
| commit | f042c1b8efbddc5a16c324f53891d79f90918c49 (patch) | |
| tree | 59932df79ac243e792ca271ff18349ff1b3d8d88 | |
| parent | a8fec62e509ca31af9296274d4f2fa6a2f3ef79e (diff) | |
| download | terraform-github-f042c1b8efbddc5a16c324f53891d79f90918c49.tar.gz terraform-github-f042c1b8efbddc5a16c324f53891d79f90918c49.zip | |
Move to for_each states with repo names as keys
Previously the states of the resources had the index of the repos in the
variable in them. This leads to a lot of force recreate when you remove
something from the middle since all the indexes afterwards get changed.
Now we use the repository name as the key for the repository states
which is also unique and more permanent.
Signed-off-by: Colin Wilk <colin.wilk@tum.de>
| -rw-r--r-- | terraform/ansible.tf | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/terraform/ansible.tf b/terraform/ansible.tf index 7ea0701..bdcf837 100644 --- a/terraform/ansible.tf +++ b/terraform/ansible.tf @@ -1,5 +1,5 @@ resource "github_repository" "ansible" { - for_each = { for idx, repo in var.repos : idx => repo } + for_each = { for repo in var.repos : repo.name => repo } name = "ansible-role-${each.value.name}" description = each.value.description @@ -16,7 +16,7 @@ resource "github_repository" "ansible" { } resource "github_actions_secret" "example_secret" { - for_each = { for idx, repo in var.repos : idx => repo if repo.galaxy } + for_each = { for repo in var.repos : repo.name => repo if repo.galaxy } repository = "ansible-role-${each.value.name}" secret_name = "GALAXY_API_KEY" |