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

cloudfront_custom_behaviors throws inconsistent conditional result types #130

Open
f3dd3rn opened this issue May 27, 2021 · 2 comments
Open
Labels
question Question about usage of the library

Comments

@f3dd3rn
Copy link

f3dd3rn commented May 27, 2021

When executing terraform plan, I get the following error:

Error: Inconsistent conditional result types
│ 
│   on .terraform/modules/tf_next/main.tf line 192, in locals:
│  192:   cloudfront_custom_behaviors = var.cloudfront_custom_behaviors != null ? concat(
│  193:     local.next_image_custom_behavior,
│  194:     var.cloudfront_custom_behaviors
│  195:   ) : local.next_image_custom_behavior
│     ├────────────────
│     │ local.next_image_custom_behavior is list of object with 1 element
│     │ var.cloudfront_custom_behaviors is list of object with 1 element
│ 
│ The true and false result expressions must have consistent types. The given expressions are tuple and list of object, respectively.

My main.tf looks like this:

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.0"
    }
  }
}

# Main region where the resources should be created in
# Should be close to the location of your viewers
provider "aws" {
  region = "ca-central-1"
}

# Provider used for creating the Lambda@Edge function which must be deployed
# to us-east-1 region (Should not be changed)
provider "aws" {
  alias  = "global_region"
  region = "us-east-1"
}

resource "aws_cloudfront_function" "password_protection" {
  name = "test-password-protection"
  runtime = "cloudfront-js-1.0"
  comment = "Basic Auth"
  publish = true
  code = file("${path.module}/path/to/file.js")
}

module "tf_next" {
  source = "dealmore/next-js/aws"
  providers = {
    aws.global_region = aws.global_region
  }

  cloudfront_custom_behaviors = [{
    function_association = {
      event_type   = "viewer-request"
      function_arn = aws_cloudfront_function.password_protection.arn
    }
  }]

  deployment_name = "test"
}

output "cloudfront_domain_name" {
  value = module.tf_next.cloudfront_domain_name
}

Can somebody please help me getting it to work?
Thank you very much in advance!

@ofhouse
Copy link
Member

ofhouse commented Jun 7, 2021

Hi, sorry for delayed response.

Adding functions to the internal CloudFront distribution is currently not possible since the values that can be passed in are limited.
We will lift this limitation in #55 which allows a fully customization of the CloudFront distribution.
We plan to release this feature this week with the upcoming 0.9.0 release.

I will post update on this issue how to integrate CloudFront functions once the release is done.

@ofhouse ofhouse added the question Question about usage of the library label Jun 7, 2021
@f3dd3rn
Copy link
Author

f3dd3rn commented Jun 8, 2021

Thanks! Looking forward to this feature! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about usage of the library
Projects
None yet
Development

No branches or pull requests

2 participants