From f042c1b8efbddc5a16c324f53891d79f90918c49 Mon Sep 17 00:00:00 2001 From: Colin Wilk Date: Sun, 4 Jun 2023 11:13:59 +0200 Subject: 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 --- terraform/ansible.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'terraform') 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" -- cgit v1.2.3