terraform-aws-modules / terraform-aws-apigateway-v2

Terraform module to create AWS API Gateway v2 (HTTP/WebSocket) 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/apigateway-v2/aws
Apache License 2.0
144 stars 188 forks source link

fix: Fixed output when create_api_domain_name is false #44

Closed mike-carey closed 2 years ago

mike-carey commented 2 years ago

Description

When disabling the entire module by:

Error:

Error: Error in function call

  on .terraform/modules/environment.maintenance.this.apigateway.this/outputs.tf line 70, in output "apigatewayv2_domain_name_target_domain_name":
  70:   value       = var.create_api_domain_name ? lookup(tomap(element(element(concat(aws_apigatewayv2_domain_name.this.*.domain_name_configuration, [""]), 0), 0)), "target_domain_name", "") : ""
    |----------------
    | aws_apigatewayv2_domain_name.this is empty tuple

Call to function "element" failed: cannot read elements from string.

Error: Error in function call

  on .terraform/modules/environment.maintenance.this.apigateway.this/outputs.tf line 75, in output "apigatewayv2_domain_name_hosted_zone_id":
  75:   value       = var.create_api_domain_name ? lookup(tomap(element(element(concat(aws_apigatewayv2_domain_name.this.*.domain_name_configuration, [""]), 0), 0)), "hosted_zone_id", "") : ""
    |----------------
    | aws_apigatewayv2_domain_name.this is empty tuple

Call to function "element" failed: cannot read elements from string.

Motivation and Context

We would like to disable the module.

Breaking Changes

No

How Has This Been Tested?

Yes, this is to get it to plan properly.

tfrigini commented 2 years ago

Hi, do you have some plan to merge this fix? I'm running into the same problem and done the same fix locally, I came here to check if this problem wasn't seen by anyone to send a fix, but you already had an PR opened.

antonbabenko commented 2 years ago

Thanks for the PR and nudge. :)

I have updated the code to use Terraform 0.13 and try().

v1.3.0 has been just released.

github-actions[bot] commented 1 year ago

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.