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

bug: module inside module get Invalid for_each argument #46

Open
babebort opened this issue Nov 30, 2022 · 0 comments
Open

bug: module inside module get Invalid for_each argument #46

babebort opened this issue Nov 30, 2022 · 0 comments
Labels
bug 🐛 An issue with the system

Comments

@babebort
Copy link

babebort commented Nov 30, 2022

Found a bug? Maybe our Slack Community can help.

Slack Community

Describe the Bug

When I am execute module inside module I get
│ Error: Invalid for_each argument │ │ on .terraform/modules/argocd.argocd_parameter_store/main.tf line 30, in resource "aws_ssm_parameter" "ignore_value_changes": │ 30: for_each = local.parameter_write_ignore_values │ ├──────────────── │ │ local.parameter_write_ignore_values will be known only after apply │ │ The "for_each" map includes keys derived from resource attributes that cannot be determined until apply, and so Terraform cannot determine the full set of keys that will identify the instances of this │ resource. │ │ When working with unknown values in for_each, it's better to define the map keys statically in your configuration and place apply-time results only in the map values. │ │ Alternatively, you could use the -target planning option to first apply only the resources that the for_each value depends on, and then apply a second time to fully converge. ╵

So, bellow all my configuration

`module "this" {
count = local.enabled ? 1 : 0
source = "cloudposse/label/null"
version = "0.25.0" # requires Terraform >= 0.13.0

enabled = var.enabled
namespace = var.namespace
tenant = var.tenant
environment = var.environment
stage = var.stage
name = var.name
delimiter = var.delimiter
attributes = var.attributes
tags = var.tags
additional_tag_map = var.additional_tag_map
label_order = var.label_order
regex_replace_chars = var.regex_replace_chars
id_length_limit = var.id_length_limit
label_key_case = var.label_key_case
label_value_case = var.label_value_case
descriptor_formats = var.descriptor_formats
labels_as_tags = var.labels_as_tags

context = var.context
}

module "argocd_additional_label" {
count = local.enabled ? 1 : 0
source = "cloudposse/label/null"
version = "0.25.0"

tenant = var.tenant
context = one(module.this[*].context)
}

module "parameter_store_label" {
count = local.enabled ? 1 : 0
source = "cloudposse/label/null"
version = "0.25.0"

#name = module.this.name
label_order = ["namespace", "environment", "stage", "tenant", "name", "attributes"]
attributes = ["argocd-password"]
context = one(module.argocd_additional_label[*].context)
}

module "argocd_parameter_store" {
count = local.enabled ? 1 : 0

source = "cloudposse/ssm-parameter-store/aws"
version = "0.10.0"

parameter_write = [
{
name = "/${local.eks_cluster_id}/argocd/password"
type = "SecureString"
value = one(random_password.argocd_password[].result)
description = "A password for accessing ArgoCD installation in ${local.eks_cluster_id} EKS cluster"
},
{
name = "/${local.eks_cluster_id}/argocd/password/encrypted"
type = "SecureString"
value = bcrypt(one(random_password.argocd_password[
].result), 10)
description = "An encrypted password for accessing ArgoCD installation in ${local.eks_cluster_id} EKS cluster"
},
]

ignore_value_changes = true
kms_arn = one(module.argocd_kms_key[*].alias_arn)

#enabled = true
#name = null
context = one(module.parameter_store_label[*].context)
depends_on = [random_password.argocd_password]
}
`

@babebort babebort added the bug 🐛 An issue with the system label Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue with the system
Projects
None yet
Development

No branches or pull requests

1 participant