我在两个区域ap-northeast-1和us-east-1中为同一域颁发了2个证书,因为我的主服务器位于ap-northeast-1中,而CloudFront要求在us-east-1中具有证书。
我想在us-east-1中选择一个作为地形数据源,但是它们具有相同的域名。
我定义了证书资源,例如
# ACM Certificate on us-east-1 (Global)
data "aws_acm_certificate" "cert_global" {
domain = "my.example.com"
statuses = ["ISSUED"]
}
我提到它像
resource "aws_cloudfront_distribution" "static" {
(snip)
viewer_certificate {
acm_certificate_arn = "${data.aws_acm_certificate.cert_global.arn}"
minimum_protocol_version = "TLSv1"
ssl_support_method = "sni-only"
}
}
原因
1 error(s) occurred:
* aws_cloudfront_distribution.static: 1 error(s) occurred:
* aws_cloudfront_distribution.static: InvalidViewerCertificate: The specified SSL certificate doesn't exist, isn't in us-east-1 region, isn't valid, or doesn't include a valid certificate chain.
status code: 400, request id: ceece17f-6610-11e7-977d-114d7e67d7c1
我了解到terraform在两个区域中检测到两个具有相同域名的证书,但不知道如何指定一个。
该文档未提及特定资源https://www.terraform.io/docs/providers/aws/d/acm_certificate.html的区域
如何在us-east-1中使用一个?
最佳答案
我自己找到了答案。data
具有provider
属性。
provider "aws" {
alias = "virginia"
region = "us-east-1"
}
data "aws_acm_certificate" "cert_global" {
domain = "my.example.com"
statuses = ["ISSUED"]
provider = "aws.virginia"
}
在us-east-1中找到证书。
关于amazon-web-services - 如何在特定区域中为数据源指定ACM证书?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45027175/