HttpVersion is missing for the resource

75 views
Skip to first unread message

Subir Pradhanang

unread,
Jan 12, 2017, 1:24:54 AM1/12/17
to Terraform
Hi all,

I have provisioned a cloudfront distribution using terraform v0.7.11, but when trying to update with some minor changes, it throws the following error:

---
* aws_cloudfront_distribution.distribution: IllegalUpdate: HttpVersion is missing for the resource
	status code: 400, request id: 629a22d7-d884-11e6-831d-9b564d83ffa1
---

After getting this error, when I put 'http_version' as 'http2', it gave me the following error:

---

aws_cloudfront_distribution.distribution: : invalid or unknown key: http_version[0m[0m

Syntax error found

---
If I delete the distribution and reprovision, it is successfully deployed.

Please advise how to fix this issue so that the changes could be applied through Terraform.

Thanks,
Subir

Lowe Schmidt

unread,
Jan 12, 2017, 1:32:48 AM1/12/17
to terrafo...@googlegroups.com
Could you show us the code please?

--
Lowe Schmidt | +46 723 867 157

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/48671d43-7881-4ab5-b527-59972ef64aa0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Subir Pradhanang

unread,
Jan 12, 2017, 2:16:45 AM1/12/17
to terrafo...@googlegroups.com
Hi Lowe,

Here it is:

// S3 Resource
resource "aws_s3_bucket" "cfd_logs_bucket" {
   bucket = "cloudfront-logs-test"
   acl = "private"
   tags {
     environment = "test"
   }
}

// Cloudfront Resource
resource "aws_cloudfront_distribution" "distribution" {
  origin {
    domain_name = "origin.example.com"
    origin_id   = "test-origin-id"

    custom_header {
      name  = "x-cfd-secret-name"
      value = "secretvalue"
    }

    custom_origin_config {
      origin_protocol_policy = "https-only"
      http_port              = "80"
      https_port             = "443"
      origin_ssl_protocols   = "TLSv1,TLSv1.1,TLSv1.2,SSLv3"
    }
  }

  enabled             = "true"
  comment             = "CloudFront Distribution for testing"
  default_root_object = "index.html"

  logging_config {
    include_cookies = "true"
    bucket          = "cfd-logs-test.s3.amazonaws.com"
    prefix          = "myprefix"
  }

  aliases = "alias.example.com"

  default_cache_behavior {
    allowed_methods  = "GET,HEAD,OPTIONS"
    cached_methods   = "GET,HEAD"
    target_origin_id = "test-origin-id"

    forwarded_values {
      query_string = "false"

      cookies {
        forward = "none"
      }

        headers = "Accept,Host,Referer"

    }

    viewer_protocol_policy = "redirect-to-https"
    min_ttl                = "0"
    default_ttl            = "3600"
    max_ttl                = "86401"
  }

  price_class = "PriceClass_All"

  restrictions {
    geo_restriction {
      restriction_type = "none"
    }
  }

  viewer_certificate {
    cloudfront_default_certificate = "true"
  }
}

Thanks,
Subir


Subir Pradhanang

unread,
Jan 12, 2017, 2:50:10 AM1/12/17
to terrafo...@googlegroups.com
Sorry, please read the S3 bucket as cfd-logs-test in the S3 Resource block.

Thanks,
Subir

Subir Pradhanang

unread,
Jan 12, 2017, 8:51:49 AM1/12/17
to terrafo...@googlegroups.com
Hi all,

Please take this as the final template we are using, and getting error in the subsequent terraform runs:


// S3 Resource
resource "aws_s3_bucket" "cfd_logs_bucket" {
   bucket = "cfd-logs-test"
   acl = "private"
   tags {
     environment = "test"
   }
}

// Cloudfront Resource
resource "aws_cloudfront_distribution" "distribution" {
  origin {
    domain_name = "origin.example.com"
    origin_id   = "test-origin-id"

    custom_header {
      name  = "x-cfd-secret-name"
      value = "secretvalue"
    }

    custom_origin_config {
      origin_protocol_policy = "https-only"
      http_port              = 80
      https_port             = 443
      origin_ssl_protocols   = ["TLSv1", "TLSv1.1", "TLSv1.2", "SSLv3"]
    }
  }

  enabled             = true
  comment             = "CloudFront Distribution for testing"
  default_root_object = "index.html"

  logging_config {
    include_cookies = true
    bucket          = "cfd-logs-test.s3.amazonaws.com"
    prefix          = "myprefix"
  }

  aliases = ["alias.example.com"]

  default_cache_behavior {
    allowed_methods  = ["GET", "HEAD", "OPTIONS"]
    cached_methods   = ["GET", "HEAD"]
    target_origin_id = "test-origin-id"

    forwarded_values {
      query_string = false

      cookies {
        forward = "none"
      }

        headers = ["Accept", "Host", "Referer"]

    }

    viewer_protocol_policy = "redirect-to-https"
    min_ttl                = 0
    default_ttl            = 3600
    max_ttl                = 86401
  }

  price_class = "PriceClass_All"

  restrictions {
    geo_restriction {
      restriction_type = "none"
    }
  }

  viewer_certificate {
    cloudfront_default_certificate = true
  }
}
---

The terraform documentation mentions headers (maximum one), but we have put as headers = ["Accept", "Host", "Referer"].

Hope that line is fine.

Thanks,
Subir
Reply all
Reply to author
Forward
0 new messages