Skip to content

Commit 7abdb45

Browse files
fix: added a fix to the DA where the prefix value was not getting added to the Trusted profile name (#220)
1 parent 83d514e commit 7abdb45

File tree

7 files changed

+72
-37
lines changed

7 files changed

+72
-37
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ For more information on access and permissions, see <https://cloud.ibm.com/docs/
8686
| Name | Source | Version |
8787
|------|--------|---------|
8888
| <a name="module_cbr_rule"></a> [cbr\_rule](#module\_cbr\_rule) | terraform-ibm-modules/cbr/ibm//modules/cbr-rule-module | 1.28.0 |
89-
| <a name="module_config_aggregator_trusted_profile"></a> [config\_aggregator\_trusted\_profile](#module\_config\_aggregator\_trusted\_profile) | terraform-ibm-modules/trusted-profile/ibm | 2.1.1 |
90-
| <a name="module_config_aggregator_trusted_profile_enterprise"></a> [config\_aggregator\_trusted\_profile\_enterprise](#module\_config\_aggregator\_trusted\_profile\_enterprise) | terraform-ibm-modules/trusted-profile/ibm | 2.1.1 |
89+
| <a name="module_config_aggregator_trusted_profile"></a> [config\_aggregator\_trusted\_profile](#module\_config\_aggregator\_trusted\_profile) | terraform-ibm-modules/trusted-profile/ibm | 3.0.0 |
90+
| <a name="module_config_aggregator_trusted_profile_enterprise"></a> [config\_aggregator\_trusted\_profile\_enterprise](#module\_config\_aggregator\_trusted\_profile\_enterprise) | terraform-ibm-modules/trusted-profile/ibm | 3.0.0 |
9191
| <a name="module_config_aggregator_trusted_profile_template"></a> [config\_aggregator\_trusted\_profile\_template](#module\_config\_aggregator\_trusted\_profile\_template) | terraform-ibm-modules/trusted-profile/ibm//modules/trusted-profile-template | 2.2.0 |
9292

9393
### Resources

examples/advanced/main.tf

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@ module "cbr_zone" {
4747
########################################################################################################################
4848

4949
module "app_config" {
50-
source = "../.."
51-
resource_group_id = module.resource_group.resource_group_id
52-
region = var.region
53-
app_config_name = "${var.prefix}-app-config"
54-
app_config_tags = var.resource_tags
55-
enable_config_aggregator = true # See https://cloud.ibm.com/docs/app-configuration?topic=app-configuration-ac-configuration-aggregator
56-
app_config_plan = "standardv2"
50+
source = "../.."
51+
resource_group_id = module.resource_group.resource_group_id
52+
region = var.region
53+
app_config_name = "${var.prefix}-app-config"
54+
app_config_tags = var.resource_tags
55+
enable_config_aggregator = true # See https://cloud.ibm.com/docs/app-configuration?topic=app-configuration-ac-configuration-aggregator
56+
app_config_plan = "standardv2"
57+
config_aggregator_trusted_profile_name = "${var.prefix}-config-aggregator-trusted-profile"
5758
app_config_collections = [
5859
{
5960
name = "${var.prefix}-collection",

main.tf

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,24 @@ resource "ibm_app_config_collection" "collections" {
4040
module "config_aggregator_trusted_profile" {
4141
count = var.enable_config_aggregator ? 1 : 0
4242
source = "terraform-ibm-modules/trusted-profile/ibm"
43-
version = "2.1.1"
43+
version = "3.0.0"
4444
trusted_profile_name = var.config_aggregator_trusted_profile_name
4545
trusted_profile_description = "Trusted Profile for App Configuration instance ${ibm_resource_instance.app_config.guid} with required access for configuration aggregator"
4646
trusted_profile_identity = {
4747
identifier = ibm_resource_instance.app_config.crn
4848
identity_type = "crn"
4949
}
50+
# unique_identifier should not be updated as it will create a breaking change for trusted profile. For more information please check https://github.com/terraform-ibm-modules/terraform-ibm-trusted-profile/releases/tag/v3.0.0 .
5051
trusted_profile_policies = [
5152
{
53+
unique_identifier = "config-aggregator-trusted-profile-0"
5254
roles = ["Viewer", "Service Configuration Reader"]
5355
account_management = true
5456
description = "All Account Management Services"
5557
},
5658
{
57-
roles = ["Viewer", "Service Configuration Reader", "Reader"]
59+
unique_identifier = "config-aggregator-trusted-profile-1"
60+
roles = ["Viewer", "Service Configuration Reader", "Reader"]
5861
resource_attributes = [{
5962
name = "serviceType"
6063
value = "service"
@@ -64,7 +67,8 @@ module "config_aggregator_trusted_profile" {
6467
}
6568
]
6669
trusted_profile_links = [{
67-
cr_type = "VSI"
70+
unique_identifier = "config-aggregator-trusted-profile-0"
71+
cr_type = "VSI"
6872
links = [{
6973
crn = ibm_resource_instance.app_config.crn
7074
}]
@@ -90,7 +94,7 @@ resource "ibm_iam_custom_role" "template_assignment_reader" {
9094
module "config_aggregator_trusted_profile_enterprise" {
9195
count = var.enable_config_aggregator && var.config_aggregator_enterprise_id != null ? 1 : 0
9296
source = "terraform-ibm-modules/trusted-profile/ibm"
93-
version = "2.1.1"
97+
version = "3.0.0"
9498
trusted_profile_name = var.config_aggregator_enterprise_trusted_profile_name
9599
trusted_profile_description = "Trusted Profile for App Configuration instance ${ibm_resource_instance.app_config.guid} with required access for configuration aggregator for enterprise accounts"
96100

@@ -101,7 +105,8 @@ module "config_aggregator_trusted_profile_enterprise" {
101105

102106
trusted_profile_policies = [
103107
{
104-
roles = ["Viewer", local.custom_role]
108+
unique_identifier = "config-aggregator-trusted-profile-0"
109+
roles = ["Viewer", local.custom_role]
105110
resource_attributes = [{
106111
name = "service_group_id"
107112
value = "IAM"
@@ -110,7 +115,8 @@ module "config_aggregator_trusted_profile_enterprise" {
110115
description = "IAM access with custom role"
111116
},
112117
{
113-
roles = ["Viewer"]
118+
unique_identifier = "config-aggregator-trusted-profile-1"
119+
roles = ["Viewer"]
114120
resources = [{
115121
service = "enterprise"
116122
}]
@@ -119,7 +125,8 @@ module "config_aggregator_trusted_profile_enterprise" {
119125
]
120126

121127
trusted_profile_links = [{
122-
cr_type = "VSI"
128+
unique_identifier = "config-aggregator-trusted-profile-0"
129+
cr_type = "VSI"
123130
links = [{
124131
crn = ibm_resource_instance.app_config.crn
125132
}]

solutions/fully-configurable/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ No resources.
4242
| <a name="input_app_config_tags"></a> [app\_config\_tags](#input\_app\_config\_tags) | Optional list of tags to be added to the App Config instance. | `list(string)` | `[]` | no |
4343
| <a name="input_config_aggregator_enterprise_account_group_ids_to_assign"></a> [config\_aggregator\_enterprise\_account\_group\_ids\_to\_assign](#input\_config\_aggregator\_enterprise\_account\_group\_ids\_to\_assign) | A list of enterprise account group IDs to assign the trusted profile template to in order for the accounts to be scanned. Supports passing the string 'all' in the list to assign to all account groups. Only applies if `enable_config_aggregator` is true and a value is being passed for `config_aggregator_enterprise_id`. | `list(string)` | <pre>[<br/> "all"<br/>]</pre> | no |
4444
| <a name="input_config_aggregator_enterprise_id"></a> [config\_aggregator\_enterprise\_id](#input\_config\_aggregator\_enterprise\_id) | If the account is an enterprise account, this value should be set to the enterprise ID (NOTE: This is different to the account ID). | `string` | `null` | no |
45-
| <a name="input_config_aggregator_enterprise_trusted_profile_name"></a> [config\_aggregator\_enterprise\_trusted\_profile\_name](#input\_config\_aggregator\_enterprise\_trusted\_profile\_name) | The name to give the enterprise viewer trusted profile with that will be created if `enable_config_aggregator` is set to `true` and a value is passed for `config_aggregator_enterprise_id`. | `string` | `"config-aggregator-enterprise-trusted-profile"` | no |
46-
| <a name="input_config_aggregator_enterprise_trusted_profile_template_name"></a> [config\_aggregator\_enterprise\_trusted\_profile\_template\_name](#input\_config\_aggregator\_enterprise\_trusted\_profile\_template\_name) | The name to give the trusted profile template that will be created if `enable_config_aggregator` is set to `true` and a value is passed for `config_aggregator_enterprise_id`. | `string` | `"config-aggregator-trusted-profile-template"` | no |
45+
| <a name="input_config_aggregator_enterprise_trusted_profile_name"></a> [config\_aggregator\_enterprise\_trusted\_profile\_name](#input\_config\_aggregator\_enterprise\_trusted\_profile\_name) | The name to give the enterprise viewer trusted profile with that will be created if `enable_config_aggregator` is set to `true` and a value is passed for `config_aggregator_enterprise_id`. If a prefix input variable is specified, the prefix is added to the name in the `<prefix>-<name>` format. | `string` | `"config-aggregator-enterprise-trusted-profile"` | no |
46+
| <a name="input_config_aggregator_enterprise_trusted_profile_template_name"></a> [config\_aggregator\_enterprise\_trusted\_profile\_template\_name](#input\_config\_aggregator\_enterprise\_trusted\_profile\_template\_name) | The name to give the trusted profile template that will be created if `enable_config_aggregator` is set to `true` and a value is passed for `config_aggregator_enterprise_id`. If a prefix input variable is specified, the prefix is added to the name in the `<prefix>-<name>` format. | `string` | `"config-aggregator-trusted-profile-template"` | no |
4747
| <a name="input_config_aggregator_resource_collection_regions"></a> [config\_aggregator\_resource\_collection\_regions](#input\_config\_aggregator\_resource\_collection\_regions) | From which region do you want to collect configuration data? Only applies if `enable_config_aggregator` is set to true. | `list(string)` | <pre>[<br/> "all"<br/>]</pre> | no |
48-
| <a name="input_config_aggregator_trusted_profile_name"></a> [config\_aggregator\_trusted\_profile\_name](#input\_config\_aggregator\_trusted\_profile\_name) | The name to give the trusted profile that will be created if `enable_config_aggregator` is set to `true`. | `string` | `"config-aggregator-trusted-profile"` | no |
48+
| <a name="input_config_aggregator_trusted_profile_name"></a> [config\_aggregator\_trusted\_profile\_name](#input\_config\_aggregator\_trusted\_profile\_name) | The name to give the trusted profile that will be created if `enable_config_aggregator` is set to `true`. If a prefix input variable is specified, the prefix is added to the name in the `<prefix>-<name>` format. | `string` | `"config-aggregator-trusted-profile"` | no |
4949
| <a name="input_enable_config_aggregator"></a> [enable\_config\_aggregator](#input\_enable\_config\_aggregator) | Set to true to enable configuration aggregator. By setting to true a trusted profile will be created with the required access to record configuration data from all resources across regions in your account. [Learn more](https://cloud.ibm.com/docs/app-configuration?topic=app-configuration-ac-configuration-aggregator). | `bool` | `false` | no |
5050
| <a name="input_existing_resource_group_name"></a> [existing\_resource\_group\_name](#input\_existing\_resource\_group\_name) | The name of an existing resource group to provision resource in. | `string` | `"Default"` | no |
5151
| <a name="input_ibmcloud_api_key"></a> [ibmcloud\_api\_key](#input\_ibmcloud\_api\_key) | The IBM Cloud API key used to provision resources. | `string` | n/a | yes |

solutions/fully-configurable/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ module "app_config" {
2424
app_config_tags = var.app_config_tags
2525
app_config_collections = var.app_config_collections
2626
enable_config_aggregator = var.enable_config_aggregator
27-
config_aggregator_trusted_profile_name = var.config_aggregator_trusted_profile_name
27+
config_aggregator_trusted_profile_name = "${local.prefix}${var.config_aggregator_trusted_profile_name}"
2828
config_aggregator_resource_collection_regions = var.config_aggregator_resource_collection_regions
2929
config_aggregator_enterprise_id = var.config_aggregator_enterprise_id
30-
config_aggregator_enterprise_trusted_profile_name = var.config_aggregator_enterprise_trusted_profile_name
31-
config_aggregator_enterprise_trusted_profile_template_name = var.config_aggregator_enterprise_trusted_profile_template_name
30+
config_aggregator_enterprise_trusted_profile_name = "${local.prefix}${var.config_aggregator_enterprise_trusted_profile_name}"
31+
config_aggregator_enterprise_trusted_profile_template_name = "${local.prefix}${var.config_aggregator_enterprise_trusted_profile_template_name}"
3232
config_aggregator_enterprise_account_group_ids_to_assign = var.config_aggregator_enterprise_account_group_ids_to_assign
3333
cbr_rules = var.app_config_cbr_rules
3434
}

solutions/fully-configurable/variables.tf

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@ variable "app_config_collections" {
9090
tags = optional(string, null)
9191
}))
9292
default = []
93+
94+
validation {
95+
condition = (
96+
var.app_config_plan != "lite" ||
97+
length(var.app_config_collections) <= 1
98+
)
99+
error_message = "When using the 'lite' plan, you can define at most 1 App Configuration collection."
100+
}
93101
}
94102

95103
variable "app_config_tags" {
@@ -103,12 +111,23 @@ variable "enable_config_aggregator" {
103111
type = bool
104112
default = false
105113
nullable = false
114+
115+
# Lite plan does not support enabling Config Aggregator as mention in doc : https://cloud.ibm.com/docs/app-configuration?topic=app-configuration-ac-configuration-aggregator
116+
validation {
117+
condition = !(var.enable_config_aggregator && var.app_config_plan == "lite")
118+
error_message = "The configuration aggregator cannot be enabled when the app_config_plan is set to 'lite'. Please use a different plan (e.g., 'basic', 'standardv2', or 'enterprise')."
119+
}
106120
}
107121

108122
variable "config_aggregator_trusted_profile_name" {
109-
description = "The name to give the trusted profile that will be created if `enable_config_aggregator` is set to `true`."
123+
description = "The name to give the trusted profile that will be created if `enable_config_aggregator` is set to `true`. If a prefix input variable is specified, the prefix is added to the name in the `<prefix>-<name>` format."
110124
type = string
111125
default = "config-aggregator-trusted-profile"
126+
127+
validation {
128+
condition = var.enable_config_aggregator ? var.config_aggregator_trusted_profile_name != null : true
129+
error_message = "'config_aggregator_trusted_profile_name' cannot be null if 'enable_config_aggregator' is true."
130+
}
112131
}
113132

114133
variable "config_aggregator_resource_collection_regions" {
@@ -121,25 +140,45 @@ variable "config_aggregator_enterprise_id" {
121140
type = string
122141
description = "If the account is an enterprise account, this value should be set to the enterprise ID (NOTE: This is different to the account ID). "
123142
default = null
143+
144+
validation {
145+
condition = !var.enable_config_aggregator ? var.config_aggregator_enterprise_id == null : true
146+
error_message = "A value can only be passed for 'config_aggregator_enterprise_id' if 'enable_config_aggregator' is true."
147+
}
124148
}
125149

126150
variable "config_aggregator_enterprise_trusted_profile_name" {
127-
description = "The name to give the enterprise viewer trusted profile with that will be created if `enable_config_aggregator` is set to `true` and a value is passed for `config_aggregator_enterprise_id`."
151+
description = "The name to give the enterprise viewer trusted profile with that will be created if `enable_config_aggregator` is set to `true` and a value is passed for `config_aggregator_enterprise_id`. If a prefix input variable is specified, the prefix is added to the name in the `<prefix>-<name>` format."
128152
type = string
129153
default = "config-aggregator-enterprise-trusted-profile"
154+
155+
validation {
156+
condition = var.enable_config_aggregator && var.config_aggregator_enterprise_id != null ? var.config_aggregator_enterprise_trusted_profile_name != null : true
157+
error_message = "'config_aggregator_enterprise_trusted_profile_name' cannot be null if 'enable_config_aggregator' is true and a value is being passed for 'config_aggregator_enterprise_id'."
158+
}
130159
}
131160

132161
variable "config_aggregator_enterprise_trusted_profile_template_name" {
133-
description = "The name to give the trusted profile template that will be created if `enable_config_aggregator` is set to `true` and a value is passed for `config_aggregator_enterprise_id`."
162+
description = "The name to give the trusted profile template that will be created if `enable_config_aggregator` is set to `true` and a value is passed for `config_aggregator_enterprise_id`. If a prefix input variable is specified, the prefix is added to the name in the `<prefix>-<name>` format."
134163
type = string
135164
default = "config-aggregator-trusted-profile-template"
165+
166+
validation {
167+
condition = var.enable_config_aggregator && var.config_aggregator_enterprise_id != null ? var.config_aggregator_enterprise_trusted_profile_template_name != null : true
168+
error_message = "'config_aggregator_enterprise_trusted_profile_template_name' cannot be null if 'enable_config_aggregator' is true and a value is being passed for 'config_aggregator_enterprise_id'."
169+
}
136170
}
137171

138172
variable "config_aggregator_enterprise_account_group_ids_to_assign" {
139173
type = list(string)
140174
default = ["all"]
141175
description = "A list of enterprise account group IDs to assign the trusted profile template to in order for the accounts to be scanned. Supports passing the string 'all' in the list to assign to all account groups. Only applies if `enable_config_aggregator` is true and a value is being passed for `config_aggregator_enterprise_id`."
142176
nullable = false
177+
178+
validation {
179+
condition = contains(var.config_aggregator_enterprise_account_group_ids_to_assign, "all") ? length(var.config_aggregator_enterprise_account_group_ids_to_assign) == 1 : true
180+
error_message = "When specifying 'all' in the list, you cannot add any other values to the list"
181+
}
143182
}
144183

145184
##############################################################

tests/pr_test.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,6 @@ func TestRunCompleteExample(t *testing.T) {
5959
assert.NotNil(t, output, "Expected some output")
6060
}
6161

62-
func TestRunUpgradeExample(t *testing.T) {
63-
t.Parallel()
64-
65-
options := setupOptions(t, "app-conf-upg", advancedExampleDir)
66-
67-
output, err := options.RunTestUpgrade()
68-
if !options.UpgradeTestSkipped {
69-
assert.Nil(t, err, "This should not have errored")
70-
assert.NotNil(t, output, "Expected some output")
71-
}
72-
}
73-
7462
func TestFullyConfigurable(t *testing.T) {
7563
t.Parallel()
7664
// Verify ibmcloud_api_key variable is set

0 commit comments

Comments
 (0)