错误创建CloudFront Distribution:Nosuchorigin:



我正在尝试用Terraform部署云额分布并在指定Origin_id

时遇到错误

CloudFront通过Route53查找指向负载平衡器。

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}"
...

其中var.domain_name是Route53记录,local.origin_id是唯一的ID。

执行Terraform应用时,我会收到此错误:

aws_cloudfront_distribution.my-app: error creating CloudFront Distribution: NoSuchOrigin: One or more of your origins or origin groups do not exist.

文档指出: origin_id (Required) - A unique identifier for the origin.是。

错误与缓存行为有关。您需要确保target_origin_id与缓存行为中的origin_id相关。

喜欢:

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 = "Custom-${var.domain_name}"
...

相关内容

  • 没有找到相关文章

最新更新