使用单个Terraform文件创建多个托管区域

时间:2019-08-14 06:53:02

标签: terraform amazon-route53

我正在使用Terraform设置Route53。我不必为每个托管区域创建多个Terraform文件。另外,我不必具有多个aws_route53_recordaws_route53_zone块。有没有办法使它尽可能动态?这样,如果我要创建其他托管区域,它将不会覆盖现有的托管区域?

为避免覆盖,我在不同的.tf文件中定义了每个主机区域。请参阅代码段。

example1.com.tf

resource "aws_route53_zone" "example1" {
  name = "example1.domain"
}

resource "aws_route53_record" "example_gsuite" {
  zone_id = "${aws_route53_zone.example.zone_id}"
}

example2.com.tf

resource "aws_route53_zone" "example2" {
  name = "example2.domain"
}

resource "aws_route53_record" "example_gsuite" {
  zone_id = "${aws_route53_zone.example.zone_id}"
}

我的期望是,我只有一个,例如zones.tf,只有一个aws_route53_zoneaws_route53_record。实现此目标的最佳方法是什么?

0 个答案:

没有答案
相关问题