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

aws_acm_certificate.this is empty tuple #26

Closed
robsonscm opened this issue Oct 31, 2019 · 6 comments
Closed

aws_acm_certificate.this is empty tuple #26

robsonscm opened this issue Oct 31, 2019 · 6 comments

Comments

@robsonscm
Copy link

Hi, there is a problem when we use the create_certificate=false.
The variable in the locals called validation_domains is not taking in account the flag.
As it does not create the certificate, the FOR operation fails with the message:
Error: Invalid index

on .terraform/modules/resources_accounts.cloudops_prod_acm/terraform-aws-modules-terraform-aws-acm-984f018/main.tf line 6, in locals:
   6:   validation_domains = [for k, v in aws_acm_certificate.this[0].domain_validation_options : tomap(v) if contains(local.distinct_domain_names, v.domain_name)]
    |----------------
    | aws_acm_certificate.this is empty tuple

The given key does not identify an element in this collection value.

I believe the solution would be like this:

validation_domains = var.create_certificate ? [for k, v in aws_acm_certificate.this[0].domain_validation_options : tomap(v) if contains(local.distinct_domain_names, v.domain_name)] : []

Let me know if you need any other info.
Tks
Robson

@atheiman
Copy link

We just hit this problem too in terraform 0.12.12

@robsonscm
Copy link
Author

You’re right. I forgot to mention the version. Terraform 12.12 for me too.
Actually I cloned the module and did the change I suggested locally. It works fine that way.
Cheers

@richardcase
Copy link

I'm encountering this issue when using https://github.com/terraform-aws-modules/terraform-aws-atlantis. So it would be great to get #28 approved and merged.

@antonbabenko
Copy link
Member

v2.4.0 of this module has been just released where this bug is fixed.

@xueshanf
Copy link

@antonbabenko I have spent hours trying to figure out why I am still hitting the issue:


  on /Users/sfeng/projects/cirrus/kubernetes-services/sub-projects/eks-cluster/common/terraform-modules/terraform-aws-acm/main.tf line 6, in locals:
   6:   validation_domains = var.create_certificate ? [for k, v in aws_acm_certificate.this[0].domain_validation_options : tomap(v) if contains(local.distinct_domain_names, replace(v.domain_name, "*.", ""))] : []
    |----------------
    | aws_acm_certificate.this is empty tuple

The given key does not identify an element in this collection value.
aws_acm_certificate.this is empty tuple

I am on Terraform 0.12.23, ACM module v2.5.0, which is supposed to fix this. The same code runs on another AWS route53 domain just fine. Any idea where should I look? Thanks!

mslipets added a commit to mslipets/terraform-aws-acm that referenced this issue Jan 22, 2021
@mslipets mslipets mentioned this issue Jan 22, 2021
mslipets added a commit to mslipets/terraform-aws-acm that referenced this issue Jan 22, 2021
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants