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

Invalid function argument error when using merge method #64

Closed
1 task done
yuekui opened this issue May 5, 2024 · 6 comments
Closed
1 task done

Invalid function argument error when using merge method #64

yuekui opened this issue May 5, 2024 · 6 comments

Comments

@yuekui
Copy link

yuekui commented May 5, 2024

Description

To conditionally create an endpoint, we plan to use a merge method combined with a ternary expression. However, this approach may lead to an 'Invalid function argument' error because the lookup function might return a null value, which differs from the expected default type [].

  • ✋ I have searched the open/closed issues and my issue is not listed.

Versions

  • Terraform version:
    1.5.7
  • Provider version(s):
    hashicorp/aws v5.48.0

Reproduction Code [Required]

locals {
  is_additional_task_needed = true
}

module "dms_aurora_postgresql_aurora_mysql" {
  # Endpoints
  endpoints = merge({
    postgresql-destination = {
      ...
    },local.is_additional_task_needed ? {
    mysql-source = {
      database_name = "foo"
      ...
    } } : {}
  )

Expected behavior

Endpoints should be created successfully

Actual behavior

Invalid function argument errors were raised when trying to lookup settings of each value

Terminal Output Screenshot(s)

image

Additional context

I've created a PR and added the conditional endpoints in example

Copy link

github-actions bot commented Jun 5, 2024

This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days

@github-actions github-actions bot added the stale label Jun 5, 2024
@yuekui
Copy link
Author

yuekui commented Jun 5, 2024

Hi @bryantbiggs , it would be great if you could review this when you have a chance. Thanks!

@github-actions github-actions bot removed the stale label Jun 6, 2024
Copy link

github-actions bot commented Jul 7, 2024

This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days

@yuekui
Copy link
Author

yuekui commented Jul 9, 2024

Just re-opened the PR, waiting for review

@github-actions github-actions bot removed the stale label Jul 10, 2024
@bryantbiggs
Copy link
Member

this looks like a dynamic workspace use issue, not a module issue. if you want to do this sort of dynamic "if this, then that", then you should use map comprehension instead of a conditional on the map object

@yuekui yuekui closed this as not planned Won't fix, can't repro, duplicate, stale Jul 11, 2024
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 Aug 10, 2024
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

2 participants