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

Define local.validation_domains properly. #28

Merged
merged 1 commit into from
Nov 12, 2019

Conversation

plutino
Copy link
Contributor

@plutino plutino commented Nov 7, 2019

Description

We came across this bug when upgrading to Terraform 0.12.

We use a pre-created ACM cert when using the terraform-aws-modules/atlantis/aws module. During terraform plan, we got this error:

Error: Invalid index

  on .terraform/modules/atlantis.acm/terraform-aws-modules-terraform-aws-acm-566067c/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.

This appears to be caused by resource count being zero for aws_acm_certificate.this, and thus aws_acm_certificate.this[0] is an invalid reference.

This PR fix this by setting local.validation_domains to an empty list when var.create_certificate is false.

This local variable references `aws_acm_certificate.this`, which might be empty if `var.create_certificate` is false.
@richardcase
Copy link

Would be great to get this merged

@antonbabenko
Copy link
Member

Thanks a lot, @plutino !

This works as expected, I have just released v2.4.0 of this module.

@plutino
Copy link
Contributor Author

plutino commented Nov 12, 2019

Thank for the quick action @antonbabenko. Now we can do another PR for the aws-atlantis module to use this latest version so that we can continue our terraform 0.12 upgrade.

@antonbabenko
Copy link
Member

I've just done it. Please, use v2.3.0 of terraform-aws-atlantis module.

@plutino
Copy link
Contributor Author

plutino commented Nov 12, 2019

wow, thank you!

@github-actions
Copy link

I'm going to lock this pull request 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 related to this change, 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 16, 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

Successfully merging this pull request may close these issues.

None yet

3 participants