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

Error: Call to function "merge" failed using cloudfront_origins #66

Closed
jagarzonhuge opened this issue Mar 5, 2021 · 5 comments · Fixed by #105
Closed

Error: Call to function "merge" failed using cloudfront_origins #66

jagarzonhuge opened this issue Mar 5, 2021 · 5 comments · Fixed by #105
Labels
bug Something isn't working
Milestone

Comments

@jagarzonhuge
Copy link

jagarzonhuge commented Mar 5, 2021

Using the input cloudfront_origins results in a terraform error:

Error: Error in function call

  on .terraform/modules/tf_next/main.tf line 173, in locals:
 173:   proxy_cloudfront_origins = var.cloudfront_origins != null ? merge(
 174:     local.next_image_cloudfront_origins,
 175:     var.cloudfront_origins
 176:   ) : local.next_image_cloudfront_origins
    |----------------
    | local.next_image_cloudfront_origins is list of object with 1 element
    | var.cloudfront_origins is list of object with 1 element

Call to function "merge" failed: arguments must be maps or objects, got "list
of object".
@ofhouse
Copy link
Member

ofhouse commented Mar 6, 2021

Are you able to share what you passed as argument?
It's not very well documented (since we will provide a better solution for it soon #55) but it requires a very specific format in order to make it work.

@jagarzonhuge
Copy link
Author

I tried with an empty list [] and with this:

cloudfront_origins           = [{
    domain_name: aws_s3_bucket.storybook.bucket_regional_domain_name,
    origin_id: local.s3_origin_id,

    s3_origin_config: {
      origin_access_identity: "origin-access-identity/cloudfront/XXXXXXXXXXXXXX"
    }
}]

As the error message says, the module is trying to merge 2 lists of objects but the merge function only works with maps/objects

@ofhouse
Copy link
Member

ofhouse commented Mar 8, 2021

We use it internally so I can definitely confirm that it works under normal conditions 😁

Object notation seems incorrect here, = instead of : should be used to separate key/values:

cloudfront_origins           = [{
    domain_name = aws_s3_bucket.storybook.bucket_regional_domain_name
    origin_id = local.s3_origin_id

    s3_origin_config = {
      origin_access_identity = "origin-access-identity/cloudfront/XXXXXXXXXXXXXX"
    }
}]

@ofhouse ofhouse added the question Question about usage of the library label Mar 13, 2021
@ofhouse
Copy link
Member

ofhouse commented Mar 23, 2021

@jagarzonhuge Were you able to solve the issue or does the problem persist?

@ofhouse ofhouse added bug Something isn't working and removed question Question about usage of the library labels Apr 3, 2021
@ofhouse ofhouse added this to the v0.7.4 milestone Apr 3, 2021
@ofhouse ofhouse linked a pull request Apr 3, 2021 that will close this issue
@ofhouse
Copy link
Member

ofhouse commented Apr 3, 2021

This has been fixed in v0.7.4.

@ofhouse ofhouse closed this as completed Apr 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants