Skip to content

Commit 0b526a1

Browse files
Vipin KumarVipin Kumar
authored andcommitted
change
1 parent 09255b6 commit 0b526a1

File tree

1 file changed

+2
-51
lines changed
  • solutions/fully-configurable

1 file changed

+2
-51
lines changed

solutions/fully-configurable/main.tf

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -195,65 +195,16 @@ module "kms" {
195195
# COS
196196
#######################################################################################################################
197197

198-
# workaround for https://github.com/IBM-Cloud/terraform-provider-ibm/issues/4478
199-
resource "time_sleep" "wait_for_authorization_policy" {
200-
depends_on = [ibm_iam_authorization_policy.policy]
201-
count = var.skip_cos_kms_auth_policy ? 0 : 1
202-
create_duration = "30s"
203-
}
204198

205199
# Data source to account settings for retrieving COS cross account id
206200
data "ibm_iam_account_settings" "iam_cos_account_settings" {
207201
provider = ibm.cos
208202
}
209203

210-
# 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
211-
212-
# Create IAM Authorization Policy to allow COS to access KMS for the encryption key
213-
resource "ibm_iam_authorization_policy" "policy" {
214-
count = local.apply_auth_policy
215-
# Conditionals with providers aren't possible, using ibm.kms as provider incase cross account is enabled
216-
provider = ibm.kms
217-
source_service_account = data.ibm_iam_account_settings.iam_cos_account_settings.account_id
218-
source_service_name = "cloud-object-storage"
219-
source_resource_instance_id = local.cos_instance_guid
220-
roles = ["Reader"]
221-
description = "Allow the COS instance ${local.cos_instance_guid} to read the ${local.kms_service} key ${local.cos_kms_key_id} from the instance ${local.existing_kms_guid}"
222-
resource_attributes {
223-
name = "serviceName"
224-
operator = "stringEquals"
225-
value = local.kms_service
226-
}
227-
resource_attributes {
228-
name = "accountId"
229-
operator = "stringEquals"
230-
value = local.kms_account_id
231-
}
232-
resource_attributes {
233-
name = "serviceInstance"
234-
operator = "stringEquals"
235-
value = local.existing_kms_guid
236-
}
237-
resource_attributes {
238-
name = "resourceType"
239-
operator = "stringEquals"
240-
value = "key"
241-
}
242-
resource_attributes {
243-
name = "resource"
244-
operator = "stringEquals"
245-
value = local.cos_kms_key_id
246-
}
247-
# Scope of policy now includes the key, so ensure to create new policy before
248-
# destroying old one to prevent any disruption to every day services.
249-
lifecycle {
250-
create_before_destroy = true
251-
}
252-
}
204+
253205

254206

255207
module "cos_bucket" {
256-
depends_on = [time_sleep.wait_for_authorization_policy]
257208
providers = {
258209
ibm = ibm.cos
259210
}
@@ -269,7 +220,7 @@ module "cos_bucket" {
269220
kms_guid = local.existing_kms_guid
270221
kms_encryption_enabled = var.kms_encryption_enabled_buckets
271222
kms_key_crn = local.cos_kms_key_crn
272-
skip_iam_authorization_policy = true
223+
skip_iam_authorization_policy = local.apply_auth_policy == 0 ? true : false
273224
management_endpoint_type = var.management_endpoint_type_for_bucket
274225
storage_class = value.class
275226
resource_instance_id = local.cos_instance_crn

0 commit comments

Comments
 (0)