Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,24 @@ You need the following permissions to run this module.
| [ibm_iam_authorization_policy.kms_policy](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_authorization_policy) | resource |
| [ibm_iam_custom_role.template_assignment_reader](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_custom_role) | resource |
| [ibm_resource_instance.app_config](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_instance) | resource |
| [ibm_resource_tag.app_config_tag](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_tag) | resource |
| [random_string.en_integration_id](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource |
| [random_string.kms_integration_id](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource |
| [time_sleep.wait](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
| [time_sleep.wait_for_en_authorization_policy](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
| [time_sleep.wait_for_kms_authorization_policy](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
| [ibm_iam_access_tag.access_tag](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/iam_access_tag) | data source |

### Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_access_tags"></a> [access\_tags](#input\_access\_tags) | Add access management tags to the App Configuration instance to control access. [Learn more](https://cloud.ibm.com/docs/account?topic=account-tag&interface=ui#create-access-console). | `list(string)` | `[]` | no |
| <a name="input_app_config_collections"></a> [app\_config\_collections](#input\_app\_config\_collections) | A list of collections to be added to the App Configuration instance | <pre>list(object({<br/> name = string<br/> collection_id = string<br/> description = optional(string, null)<br/> tags = optional(string, null)<br/> }))</pre> | `[]` | no |
| <a name="input_app_config_event_notifications_source_name"></a> [app\_config\_event\_notifications\_source\_name](#input\_app\_config\_event\_notifications\_source\_name) | The name by which Event Notifications source will be created in the existing Event Notification instance. | `string` | `"app-config-en-source-name"` | no |
| <a name="input_app_config_name"></a> [app\_config\_name](#input\_app\_config\_name) | Name for the App Configuration service instance | `string` | n/a | yes |
| <a name="input_app_config_plan"></a> [app\_config\_plan](#input\_app\_config\_plan) | Plan for the App Configuration service instance, valid plans are lite, basic, standardv2, and enterprise. | `string` | `"lite"` | no |
| <a name="input_app_config_service_endpoints"></a> [app\_config\_service\_endpoints](#input\_app\_config\_service\_endpoints) | Service Endpoints for the App Configuration service instance, valid endpoints are public or public-and-private. | `string` | `"public-and-private"` | no |
| <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 |
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | The context-based restrictions rule to create. Only one rule is allowed. | <pre>list(object({<br/> description = string<br/> account_id = string<br/> tags = optional(list(object({<br/> name = string<br/> value = string<br/> })), [])<br/> rule_contexts = list(object({<br/> attributes = optional(list(object({<br/> name = string<br/> value = string<br/> }))) }))<br/> enforcement_mode = string<br/> }))</pre> | `[]` | no |
| <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 |
| <a name="input_config_aggregator_enterprise_account_ids_to_assign"></a> [config\_aggregator\_enterprise\_account\_ids\_to\_assign](#input\_config\_aggregator\_enterprise\_account\_ids\_to\_assign) | A list of enterprise account 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 accounts. Only applies if `enable_config_aggregator` is true and a value is being passed for `config_aggregator_enterprise_id`. | `list(string)` | `[]` | no |
Expand All @@ -164,6 +166,7 @@ You need the following permissions to run this module.
| <a name="input_kms_endpoint_url"></a> [kms\_endpoint\_url](#input\_kms\_endpoint\_url) | The URL of the key management service endpoint to use for key encryption. For more information on the endpoint URL format for Key Protect, go to [Service endpoints](https://cloud.ibm.com/docs/key-protect?topic=key-protect-regions#service-endpoints). It is required if `kms_encryption_enabled` is set to true. | `string` | `null` | no |
| <a name="input_region"></a> [region](#input\_region) | The region to provision the App Configuration service. | `string` | `"us-south"` | no |
| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The resource group ID where resources will be provisioned. | `string` | n/a | yes |
| <a name="input_resource_tags"></a> [resource\_tags](#input\_resource\_tags) | Add user resource tags to the App Configuration instance to organize, track, and manage costs. [Learn more](https://cloud.ibm.com/docs/account?topic=account-tag&interface=ui#tag-types). | `list(string)` | `[]` | no |
| <a name="input_root_key_id"></a> [root\_key\_id](#input\_root\_key\_id) | The key ID of a root key, existing in the key management service instance passed in `var.existing_kms_instance_crn`, which is used to encrypt the data encryption keys which are then used to encrypt the data. Required only if `var.kms_encryption_enabled` is set to `true`. | `string` | `null` | no |
| <a name="input_skip_app_config_event_notifications_auth_policy"></a> [skip\_app\_config\_event\_notifications\_auth\_policy](#input\_skip\_app\_config\_event\_notifications\_auth\_policy) | Set to true to skip the creation of an IAM authorization policy that permits App configuration instances to integrate with Event Notification in the same account. | `bool` | `false` | no |
| <a name="input_skip_app_config_kms_auth_policy"></a> [skip\_app\_config\_kms\_auth\_policy](#input\_skip\_app\_config\_kms\_auth\_policy) | Set to true to skip the creation of an IAM authorization policy that permits App configuration instances to read the encryption key from the KMS instance in the same account. | `bool` | `false` | no |
Expand Down
3 changes: 2 additions & 1 deletion examples/advanced/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ module "app_config" {
resource_group_id = module.resource_group.resource_group_id
region = var.region
app_config_name = "${var.prefix}-app-config"
app_config_tags = var.resource_tags
resource_tags = var.resource_tags
access_tags = var.access_tags
enable_config_aggregator = true # See https://cloud.ibm.com/docs/app-configuration?topic=app-configuration-ac-configuration-aggregator
app_config_plan = "enterprise"
config_aggregator_trusted_profile_name = "${var.prefix}-config-aggregator-trusted-profile"
Expand Down
6 changes: 6 additions & 0 deletions examples/advanced/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ variable "resource_tags" {
description = "Optional list of tags to be added to created resources"
default = []
}

variable "access_tags" {
type = list(string)
description = "Optional list of access management tags to add to the App Configuration instance."
default = []
}
2 changes: 1 addition & 1 deletion examples/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ module "app_config" {
resource_group_id = module.resource_group.resource_group_id
region = var.region
app_config_name = "${var.prefix}-app-config"
app_config_tags = var.resource_tags
resource_tags = var.resource_tags
}
11 changes: 11 additions & 0 deletions ibm_catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,17 @@
}
}
},
{
"key": "app_config_access_tags",
"custom_config": {
"grouping": "deployment",
"type": "array",
"original_grouping": "deployment",
"config_constraints": {
"type": "string"
}
}
},
{
"key": "enable_config_aggregator"
},
Expand Down
19 changes: 18 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,24 @@ resource "ibm_resource_instance" "app_config" {
service = "apprapp"
plan = var.app_config_plan
service_endpoints = var.app_config_service_endpoints
tags = var.app_config_tags
tags = var.resource_tags
}

##############################################################################
# Attach Access Tags
##############################################################################

data "ibm_iam_access_tag" "access_tag" {
for_each = length(var.access_tags) != 0 ? toset(var.access_tags) : []
name = each.value
}

resource "ibm_resource_tag" "app_config_tag" {
depends_on = [data.ibm_iam_access_tag.access_tag] # Force dependency on data source validation to ensure access_tags exist and are valid before use.
count = length(var.access_tags) == 0 ? 0 : 1
resource_id = ibm_resource_instance.app_config.crn
tags = var.access_tags
tag_type = "access"
}

##############################################################################
Expand Down
3 changes: 2 additions & 1 deletion solutions/fully-configurable/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ module "app_config" {
app_config_name = "${local.prefix}${var.app_config_name}"
app_config_plan = var.app_config_plan
app_config_service_endpoints = var.app_config_service_endpoints
app_config_tags = var.app_config_tags
resource_tags = var.app_config_tags
access_tags = var.app_config_access_tags
app_config_collections = var.app_config_collections
enable_config_aggregator = var.enable_config_aggregator
config_aggregator_trusted_profile_name = "${local.prefix}${var.config_aggregator_trusted_profile_name}"
Expand Down
8 changes: 7 additions & 1 deletion solutions/fully-configurable/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,13 @@ variable "app_config_collections" {

variable "app_config_tags" {
type = list(string)
description = "Optional list of tags to be added to the App Config instance."
description = "Add user resource tags to the App Configuration instance to organize, track, and manage costs. [Learn more](https://cloud.ibm.com/docs/account?topic=account-tag&interface=ui#tag-types)."
default = []
}

variable "app_config_access_tags" {
type = list(string)
description = "Add access management tags to the App Configuration instance to control access. [Learn more](https://cloud.ibm.com/docs/account?topic=account-tag&interface=ui#create-access-console)."
default = []
}

Expand Down
2 changes: 2 additions & 0 deletions tests/pr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func TestRunAdvancedExampleInSchematics(t *testing.T) {
{Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true},
{Name: "region", Value: options.Region, DataType: "string"},
{Name: "prefix", Value: options.Prefix, DataType: "string"},
{Name: "access_tags", Value: permanentResources["accessTags"], DataType: "list"},
}

err := options.RunSchematicTest()
Expand Down Expand Up @@ -150,6 +151,7 @@ func TestFullyConfigurable(t *testing.T) {
{Name: "existing_resource_group_name", Value: resourceGroup, DataType: "string"},
{Name: "app_config_collections", Value: appConfigCollection, DataType: "list(object)"},
{Name: "app_config_tags", Value: options.Tags, DataType: "list(string)"},
{Name: "app_config_access_tags", Value: permanentResources["accessTags"], DataType: "list"},
{Name: "prefix", Value: options.Prefix, DataType: "string"},
{Name: "enable_config_aggregator", Value: true, DataType: "bool"},
{Name: "kms_encryption_enabled", Value: false, DataType: "bool"},
Expand Down
21 changes: 19 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,27 @@ variable "app_config_service_endpoints" {
}
}

variable "app_config_tags" {
variable "resource_tags" {
type = list(string)
description = "Optional list of tags to be added to the App Config instance."
description = "Add user resource tags to the App Configuration instance to organize, track, and manage costs. [Learn more](https://cloud.ibm.com/docs/account?topic=account-tag&interface=ui#tag-types)."
default = []
validation {
condition = alltrue([for tag in var.resource_tags : can(regex("^[A-Za-z0-9 _\\-.:]{1,128}$", tag))])
error_message = "Each resource tag must be 128 characters or less and may contain only A-Z, a-z, 0-9, spaces, underscore (_), hyphen (-), period (.), and colon (:)."
}
}

variable "access_tags" {
type = list(string)
description = "Add access management tags to the App Configuration instance to control access. [Learn more](https://cloud.ibm.com/docs/account?topic=account-tag&interface=ui#create-access-console)."
default = []

validation {
condition = alltrue([
for tag in var.access_tags : can(regex("[\\w\\-_\\.]+:[\\w\\-_\\.]+", tag)) && length(tag) <= 128
])
error_message = "Tags must match the regular expression `\"[\\w\\-_\\.]+:[\\w\\-_\\.]+\"`. [Learn more](https://cloud.ibm.com/docs/account?topic=account-tag&interface=ui#limits)."
}
}

variable "app_config_collections" {
Expand Down