Skip to content

Commit 8aa4ea9

Browse files
authored
fix: always run cos_account_setting block (#188)
1 parent 01b8917 commit 8aa4ea9

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

solutions/instances/main.tf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ resource "ibm_iam_authorization_policy" "cos_policy" {
184184
resource_attributes {
185185
name = "accountId"
186186
operator = "stringEquals"
187-
value = data.ibm_iam_account_settings.iam_cos_account_settings[0].account_id
187+
value = data.ibm_iam_account_settings.iam_cos_account_settings.account_id
188188
}
189189

190190
resource_attributes {
@@ -371,18 +371,17 @@ resource "time_sleep" "wait_for_authorization_policy" {
371371

372372
# Data source to account settings for retrieving cross account id
373373
data "ibm_iam_account_settings" "iam_cos_account_settings" {
374-
count = local.apply_auth_policy
375374
provider = ibm.cos
376375
}
377376

378377
# The auth policy is being created here instead of in COS module because of this limitation: https://github.com/terraform-ibm-modules/terraform-ibm-observability-da/issues/8
379378

380379
# Create IAM Authorization Policy to allow COS to access KMS for the encryption key
381380
resource "ibm_iam_authorization_policy" "policy" {
382-
count = (var.skip_cos_kms_auth_policy || (length(coalesce(local.buckets_config, [])) == 0)) ? 0 : 1
381+
count = local.apply_auth_policy
383382
# Conditionals with providers aren't possible, using ibm.kms as provider incase cross account is enabled
384383
provider = ibm.kms
385-
source_service_account = data.ibm_iam_account_settings.iam_cos_account_settings[0].account_id
384+
source_service_account = data.ibm_iam_account_settings.iam_cos_account_settings.account_id
386385
source_service_name = "cloud-object-storage"
387386
source_resource_instance_id = local.cos_instance_guid
388387
target_service_name = local.kms_service

0 commit comments

Comments
 (0)