title: Error creating CloudFront Distribution: NoSuchOrigin:
body: <p>I am trying to deploy a Cloudfront distribution with Terraform and getting an error while specifying the origin_id</p>
  
  <p>Cloudfront is pointing at a load balancer via a Route53 lookup.</p>
  
  <pre><code>resource "aws_cloudfront_distribution" "my-app" {
    origin {
      custom_origin_config {
        http_port              = 443
        https_port             = 443
        origin_protocol_policy = "https-only"
        origin_ssl_protocols   = ["TLSv1.2"]
      }
  
      domain_name = "${var.domain_name}"
      origin_id   = "Custom-${var.domain_name}"
    }
  
  ...
  
    default_cache_behavior {
      allowed_methods  = ["GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "DELETE"]
      cached_methods   = ["GET", "HEAD"]
      target_origin_id = "${local.origin_id}"
  
  ...
  </code></pre>
  
  <p>where <code>var.domain_name</code> is a route53 record and <code>local.origin_id</code> is a unique id.</p>
  
  <p>When performing the terraform apply I get this error: </p>
  
  <p><code>aws_cloudfront_distribution.my-app: error creating CloudFront Distribution: NoSuchOrigin: One or more of your origins or origin groups do not exist.</code></p>
  
  <p>The documentation states: <code>origin_id (Required) - A unique identifier for the origin.</code> which it is.</p>