Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Jul 29, 2024
1 parent abfcc34 commit 7264155
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ locals {
## })) }


images = var.image_config != null ? { for i in var.image_config : format("%v#%v", i.name, i.tag) =>
_images = var.image_config != null ? { for i in var.image_config : format("%v#%v", i.name, i.tag) =>
merge(i, tomap({
key = format("%v#%v", i.name, i.tag),
source_full_path = format("%v/%v:%v", i.source_registry, i.source_image, element(compact(concat([lookup(i, "source_tag", null)], [i.tag])), 0)),
Expand All @@ -265,15 +265,17 @@ locals {
dest_repository = format("%v/%v", local.repo_parent_name, i.name),
enabled = try(i.enabled, true),
})) } : {}
image_map = { for k in distinct([for v in var.image_config : v.name]) : k => format("%v/%v", local.repo_parent_name, k) }
image_repos = { for k, v in local.images : k => format("%v/%v", local.account_ecr, v.name) }
images = { for k, v in local._images : k => v if v.enabled }
image_name_list = distinct([for k, v in local.images : v.name])
image_map = { for k in local.image_name_list : k => format("%v/%v", local.repo_parent_name, k) }
image_repos = { for k, v in local.images : k => format("%v/%v", local.account_ecr, v.name) }
}

#---
# create repos for image_config
#---
resource "aws_ecr_repository" "image_repos" {
for_each = { for k, v in local.image_map : k => v if v.enabled }
for_each = local.image_map
name = format("%v/%v", local.repo_parent_name, each.key)

image_tag_mutability = "IMMUTABLE"
Expand Down Expand Up @@ -328,5 +330,5 @@ resource "null_resource" "copy_images" {

output "image_map" {
description = "image_config map of name => repo to be used for imports"
value = { for k, v in local.image_map : k => v if v.enabled }
value = local.image_map
}

0 comments on commit 7264155

Please sign in to comment.