cloudposse / terraform-aws-cloudfront-cdn

Terraform Module that implements a CloudFront Distribution (CDN) for a custom origin.
https://cloudposse.com/accelerate
Apache License 2.0
99 stars 121 forks source link

Cannot create custom_origins #74

Open air3ijai opened 3 years ago

air3ijai commented 3 years ago

Describe the Bug

Cannot create a custom origin behind the default one, because

  1. The given value is not suitable for child module variable "custom_origins" defined at .terraform/modules/cloudfront-cdn/variables.tf:327,1-26: element 0: attribute "s3_origin_config" is required. Or when we add s3_origin_config
  2. Error: error updating CloudFront Distribution (E2WW4FISAR8BSH): IllegalUpdate: You must specify either a CustomOrigin or an S3Origin. You cannot specify both.

Expected Behavior

We should be able to add a custom origin accordingly to the documentation

Steps to Reproduce

Add the following block to the main.tf

  custom_origins = [
    {
      domain_name    = "domain.com"
      origin_id      = "custom-origin-staging"
      origin_path    = "/staging"
      custom_headers = []
      custom_origin_config = {
        http_port                = 80
        https_port               = 443
        origin_protocol_policy   = "https-only"
        origin_ssl_protocols     = ["TLSv1", "TLSv1.1", "TLSv1.2"]
        origin_keepalive_timeout = 5
        origin_read_timeout      = 30
      }
    }
  ]

Steps to reproduce the behavior:

  1. Run: terraform plan - get the error about missed s3_origin_config option
  2. Add required option
    s3_origin_config = {
      origin_access_identity = ""
    }
  3. Run terraform apply and the the error from CloudFront
    Error: error updating CloudFront Distribution (XXXXXXXXXXXXXX): IllegalUpdate: You must specify either a CustomOrigin or an S3Origin. You cannot specify both.

Environment

cloudposse/cloudfront-cdn/aws = 0.22.1
aws = 3.63.0

Additional Context

Maybe something is missing in my configuration, and where we can find a working example with a custom origin?

Thank you!

weifan01 commented 2 years ago

I have the same problem,but I didn't apply. Shouldn't custom source have origin_access_identity? Adding this config will cause my origin to be recreate.

image
ariretiarno commented 1 year ago

same issue

adrianwnuk commented 1 year ago

Same here, now way to add different origin than S3.

IllegalUpdate: You must specify either a CustomOrigin or an S3Origin. You cannot specify both.