1- data "aws_partition" "current" {}
2- data "aws_caller_identity" "current" {}
1+ data "aws_partition" "current" {
2+ count = var. create ? 1 : 0
3+ }
4+ data "aws_caller_identity" "current" {
5+ count = var. create ? 1 : 0
6+ }
7+
8+ locals {
9+ account_id = try (data. aws_caller_identity . current [0 ]. account_id , " " )
10+ partition = try (data. aws_partition . current [0 ]. partition , " " )
11+ dns_suffix = try (data. aws_partition . current [0 ]. dns_suffix , " " )
12+ }
313
414# ###############################################################################
515# Key
@@ -98,7 +108,7 @@ data "aws_iam_policy_document" "this" {
98108
99109 principals {
100110 type = " AWS"
101- identifiers = [" arn:${ data . aws_partition . current . partition } :iam::${ data . aws_caller_identity . current . account_id } :root" ]
111+ identifiers = [" arn:${ local . partition } :iam::${ local . account_id } :root" ]
102112 }
103113 }
104114 }
@@ -342,7 +352,7 @@ data "aws_iam_policy_document" "this" {
342352
343353 principals {
344354 type = " Service"
345- identifiers = [" dnssec-route53.${ data . aws_partition . current . dns_suffix } " ]
355+ identifiers = [" dnssec-route53.${ local . dns_suffix } " ]
346356 }
347357 }
348358 }
@@ -358,7 +368,7 @@ data "aws_iam_policy_document" "this" {
358368
359369 principals {
360370 type = " Service"
361- identifiers = [" dnssec-route53.${ data . aws_partition . current . dns_suffix } " ]
371+ identifiers = [" dnssec-route53.${ local . dns_suffix } " ]
362372 }
363373
364374 condition {
@@ -373,7 +383,7 @@ data "aws_iam_policy_document" "this" {
373383 content {
374384 test = " StringEquals"
375385 variable = " aws:SourceAccount"
376- values = try (condition. value . account_ids , [data . aws_caller_identity . current . account_id ])
386+ values = try (condition. value . account_ids , [local . account_id ])
377387 }
378388 }
379389
@@ -383,7 +393,7 @@ data "aws_iam_policy_document" "this" {
383393 content {
384394 test = " ArnLike"
385395 variable = " aws:SourceArn"
386- values = [try (condition. value . hosted_zone_arn , " arn:${ data . aws_partition . current . partition } :route53:::hostedzone/*" )]
396+ values = [try (condition. value . hosted_zone_arn , " arn:${ local . partition } :route53:::hostedzone/*" )]
387397 }
388398 }
389399 }
0 commit comments