0
サーバーデプロイメント用のPTRレコードを作成しようとしています。下記のサーバーは、従属サーバーセットが適用された後に展開する必要があります。そのため、現在、これらのサーバーモジュールを展開する1つの適用を実行し、次にこれらのリソースを変更する2回目の展開では、展開する。これらのサーバーのPTRレコードを作成するための新しいリソースを追加しました。カウントが0に設定されていても、Terraformは補間を解決しようとします。これは、PTRレコードリソースだけのAレコードリソースに対しては実行しません。0のカウントを持つリソース内の補間を解決しようとしているTerraform
ここにコードがあります。変数に問題があるかどうかを調べるために、カウントを0にハードコーディングしています。カウントが0である間、リストは空であると予想されます。私は、Terraformが補間を解決しようとしないことを期待しています。適用上の
resource "aws_route53_record" "ds_sync_A_records" {
// same number of records as instances
provider = "aws.dns"
count = 0
// count = "${var.ping_sync_cluster_count}"
zone_id = "${data.aws_route53_zone.zone_company_io.zone_id}"
name = "ping-sync-0${count.index}.${var.domain_name}"
type = "A"
ttl = "10"
// matches up record N to instance N
records = ["${element(module.ping_sync_hot_server.private_server_ips, count.index)}"]
}
resource "aws_route53_record" "ds_sync_PTR_records" {
// same number of records as instances
provider = "aws.dns"
count = 0
// count = "${var.ping_sync_cluster_count}"
zone_id = "${data.aws_route53_zone.zone_company_io.zone_id}"
name = "${format(
"%s.%s.%s.$s.in-appr.arpa",
element(split(".", element(module.ping_sync_hot_server.private_server_ips, count.index)), 3),
element(split(".", element(module.ping_sync_hot_server.private_server_ips, count.index)), 2),
element(split(".", element(module.ping_sync_hot_server.private_server_ips, count.index)), 1),
element(split(".", element(module.ping_sync_hot_server.private_server_ips, count.index)), 0)
)}"
type = "PTR"
ttl = "10"
// matches up record N to instance N
records = ["${element(module.ping_sync_hot_server.private_server_ips, count.index)}"]
}
エラーメッセージ:
Error running plan: 3 error(s) occurred:
* element: element() may not be used with an empty list in:
${element(module.ping_sync_hot_server.private_server_ips, count.index)}
* element: element() may not be used with an empty list in:
${element(module.ping_sync_hot_server.private_server_ips, count.index)}
* element: element() may not be used with an empty list in:
${element(module.ping_sync_hot_server.private_server_ips, count.index)}