我有一个terraform模块,主要在eu-west-1中提供资源。我需要ACM证书才能附加到Cloudfront发行版。证书必须在us-east-1中进行设置。
因此,我配置了两个提供程序:
provider "aws" {
version = "~> 1.0"
region = "eu-west-1"
}
provider "aws" {
version = "~> 1.0"
region = "us-east-1"
alias = "us-east-1"
}
Run Code Online (Sandbox Code Playgroud)
在我的模块中,我像这样配置证书:
resource "aws_acm_certificate" "cert" {
provider = "aws.us-east-1"
domain_name = "${var.domain_name}"
validation_method = "DNS"
tags = "${var.tags}"
lifecycle {
create_before_destroy = true
}
}
Run Code Online (Sandbox Code Playgroud)
问题1:我尝试使用以下方法导入现有的ACM证书:
terraform import module.mymod.aws_acm_certificate.cert arn:aws:acm:us-east-1:xyz:certificate/uuid
Run Code Online (Sandbox Code Playgroud)
失败并显示:“找不到ID为证书的证书”。地形是否在错误的区域中寻找?我通过aws CLI确认证书确实存在(例如,ARN中没有错字)。
好的,所以我认为我可以创建新证书。确实可以,并且我现在有两个证书,但是然后遇到了问题2:
resource "aws_route53_record" "cert_validation" {
name = "${aws_acm_certificate.cert.domain_validation_options.0.resource_record_name}"
type = "${aws_acm_certificate.cert.domain_validation_options.0.resource_record_type}"
zone_id = "${data.aws_route53_zone.zone.id}"
records = ["${aws_acm_certificate.cert.domain_validation_options.0.resource_record_value}"]
ttl = 60
} …Run Code Online (Sandbox Code Playgroud)