Skip to content

Commit f4ee284

Browse files
authored
some cleanup to enterprise example (#214)
1 parent be98644 commit f4ee284

File tree

1 file changed

+29
-26
lines changed

1 file changed

+29
-26
lines changed

examples/enterprise/main.tf

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ module "trusted_profile_scc_wp" {
3434
trusted_profile_identity = {
3535
identifier = module.scc_wp.crn
3636
identity_type = "crn"
37-
type = "crn"
3837
}
3938

4039
trusted_profile_policies = [
@@ -86,7 +85,6 @@ module "trusted_profile_app_config_general" {
8685
trusted_profile_identity = {
8786
identifier = module.app_config.app_config_crn
8887
identity_type = "crn"
89-
type = "crn"
9088
}
9189

9290
trusted_profile_policies = [
@@ -118,10 +116,13 @@ module "trusted_profile_app_config_general" {
118116
# This role, "Template Assignment Reader", is used in the trusted profile
119117
# to grant permission to read IAM template assignments. It is required
120118
# by the App Config enterprise-level trusted profile to manage IAM templates.
119+
locals {
120+
custom_role = "Template Assignment Reader"
121+
}
121122
resource "ibm_iam_custom_role" "template_assignment_reader" {
122123
name = "TemplateAssignmentReader"
123124
service = "iam-identity"
124-
display_name = "Template Assignment Reader"
125+
display_name = local.custom_role
125126
description = "Custom role to allow reading template assignments"
126127
actions = ["iam-identity.profile-assignment.read"]
127128
}
@@ -130,18 +131,17 @@ resource "ibm_iam_custom_role" "template_assignment_reader" {
130131
module "trusted_profile_app_config_enterprise" {
131132
source = "terraform-ibm-modules/trusted-profile/ibm"
132133
version = "2.1.0"
133-
trusted_profile_name = "app-config-enterprise-profile"
134+
trusted_profile_name = "${var.prefix}-app-config-enterprise-profile"
134135
trusted_profile_description = "Trusted Profile for App Config to manage IAM templates"
135136

136137
trusted_profile_identity = {
137138
identifier = module.app_config.app_config_crn
138139
identity_type = "crn"
139-
type = "crn"
140140
}
141141

142142
trusted_profile_policies = [
143143
{
144-
roles = ["Viewer", "Template Assignment Reader"]
144+
roles = ["Viewer", local.custom_role]
145145
resource_attributes = [{
146146
name = "service_group_id"
147147
value = "IAM"
@@ -166,25 +166,6 @@ module "trusted_profile_app_config_enterprise" {
166166
}]
167167
}
168168

169-
# Enable the config aggregator
170-
resource "ibm_config_aggregator_settings" "scc_wp_aggregator" {
171-
instance_id = module.app_config.app_config_guid
172-
region = var.region
173-
resource_collection_enabled = true
174-
resource_collection_regions = ["all"]
175-
trusted_profile_id = module.trusted_profile_app_config_general.profile_id
176-
177-
additional_scope {
178-
type = "Enterprise"
179-
enterprise_id = var.enterprise_id
180-
181-
profile_template {
182-
id = module.trusted_profile_template.trusted_profile_template_id
183-
trusted_profile_id = module.trusted_profile_app_config_enterprise.profile_id
184-
}
185-
}
186-
}
187-
188169
########################################################################################################################
189170
# Trusted profile template
190171
########################################################################################################################
@@ -194,7 +175,7 @@ module "trusted_profile_template" {
194175
version = "2.1.0"
195176
template_name = "Trusted Profile Template for SCC-WP-${var.prefix}"
196177
template_description = "IAM trusted profile template to onboard accounts for CSPM"
197-
profile_name = "Trusted Profile for IBM Cloud CSPM in SCC-WP"
178+
profile_name = "Trusted Profile for IBM Cloud CSPM in SCC-WP-${var.prefix}"
198179
profile_description = "Template profile used to onboard child accounts"
199180
identity_crn = module.app_config.app_config_crn
200181
onboard_all_account_groups = true
@@ -214,3 +195,25 @@ module "trusted_profile_template" {
214195
}
215196
]
216197
}
198+
199+
########################################################################################################################
200+
# Enable the config aggregator
201+
########################################################################################################################
202+
203+
resource "ibm_config_aggregator_settings" "scc_wp_aggregator" {
204+
instance_id = module.app_config.app_config_guid
205+
region = var.region
206+
resource_collection_enabled = true
207+
resource_collection_regions = ["all"]
208+
trusted_profile_id = module.trusted_profile_app_config_general.profile_id
209+
210+
additional_scope {
211+
type = "Enterprise"
212+
enterprise_id = var.enterprise_id
213+
214+
profile_template {
215+
id = module.trusted_profile_template.trusted_profile_template_id
216+
trusted_profile_id = module.trusted_profile_app_config_enterprise.profile_id
217+
}
218+
}
219+
}

0 commit comments

Comments
 (0)