gpt4 book ai didi

amazon-web-services - 创建 CloudFront 分配 : NoSuchOrigin: 时出错

转载 作者:行者123 更新时间:2023-12-04 08:01:43 26 4
gpt4 key购买 nike

我正在尝试使用 Terraform 部署 Cloudfront 发行版,但在指定 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是唯一标识。

执行 terraform apply 时,出现此错误:
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_idorigin_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}"

...

关于amazon-web-services - 创建 CloudFront 分配 : NoSuchOrigin: 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55972204/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com