diff --git a/README.md b/README.md index 8f046f71..861c390e 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ You need the following permissions to run this module. | [kms\_key\_crn](#input\_kms\_key\_crn) | The root key CRN of a Key Management Service like Key Protect or Hyper Protect Crypto Services (HPCS) that you want to use for encryption. Only used if `kms_encryption_enabled` is set to true. | `string` | `null` | no | | [region](#input\_region) | The region where the resource will be provisioned.Its not required if passing a value for `existing_sm_instance_crn`. | `string` | `null` | no | | [resource\_group\_id](#input\_resource\_group\_id) | The ID of the resource group | `string` | n/a | yes | -| [secrets](#input\_secrets) | Secret Manager secrets configurations. |
list(object({
secret_group_name = string
secret_group_description = optional(string)
existing_secret_group = optional(bool, false)
secrets = optional(list(object({
secret_name = string
secret_description = optional(string)
secret_type = optional(string)
imported_cert_certificate = optional(string)
imported_cert_private_key = optional(string)
imported_cert_intermediate = optional(string)
secret_username = optional(string)
secret_labels = optional(list(string), [])
secret_payload_password = optional(string, "")
secret_auto_rotation = optional(bool, true)
secret_auto_rotation_unit = optional(string, "day")
secret_auto_rotation_interval = optional(number, 89)
service_credentials_ttl = optional(string, "7776000") # 90 days
service_credentials_source_service_crn = optional(string)
service_credentials_source_service_role_crn = optional(string)
})))
})) | `[]` | no |
+| [secrets](#input\_secrets) | Secret Manager secrets configurations. | list(object({
secret_group_name = string
secret_group_description = optional(string)
existing_secret_group = optional(bool, false)
create_access_group = optional(bool, false)
access_group_name = optional(string)
access_group_roles = optional(list(string))
access_group_tags = optional(list(string))
secrets = optional(list(object({
secret_name = string
secret_description = optional(string)
secret_type = optional(string)
imported_cert_certificate = optional(string)
imported_cert_private_key = optional(string)
imported_cert_intermediate = optional(string)
secret_username = optional(string)
secret_labels = optional(list(string), [])
secret_payload_password = optional(string, "")
secret_auto_rotation = optional(bool, true)
secret_auto_rotation_unit = optional(string, "day")
secret_auto_rotation_interval = optional(number, 89)
service_credentials_ttl = optional(string, "7776000") # 90 days
service_credentials_source_service_crn = optional(string)
service_credentials_source_service_role_crn = optional(string)
})))
})) | `[]` | no |
| [secrets\_manager\_name](#input\_secrets\_manager\_name) | The name of the Secrets Manager instance to create | `string` | n/a | yes |
| [skip\_en\_iam\_authorization\_policy](#input\_skip\_en\_iam\_authorization\_policy) | Set to true to skip the creation of an IAM authorization policy that permits all Secrets Manager instances (scoped to the resource group) an 'Event Source Manager' role to the given Event Notifications instance passed in the `existing_en_instance_crn` input variable. In addition, no policy is created if `enable_event_notification` is set to false. | `bool` | `false` | no |
| [skip\_iam\_authorization\_policy](#input\_skip\_iam\_authorization\_policy) | Whether to skip the creation of the IAM authorization policies required to enable the IAM credentials engine. If set to false, policies will be created that grants the Secrets Manager instance 'Operator' access to the IAM identity service, and 'Groups Service Member Manage' access to the IAM groups service. | `bool` | `false` | no |
diff --git a/ibm_catalog.json b/ibm_catalog.json
index 4b89b135..19be8e47 100644
--- a/ibm_catalog.json
+++ b/ibm_catalog.json
@@ -29,6 +29,14 @@
"title": "Creates a Secrets Manager instance.",
"description": "Creates an IBM Secrets Manager instance."
},
+ {
+ "title": "Create secret groups.",
+ "description": "Optionally create secret groups inside your IBM Secrets Manager instance."
+ },
+ {
+ "title": "Create access groups for your secret groups.",
+ "description": "Optionally create access groups for the secret groups inside your IBM Secrets Manager instance."
+ },
{
"title": "Optionally configure an IBM Secrets Manager IAM credentials engine to an IBM Secrets Manager instance.",
"description": "Optionally configure an IBM Secrets Manager IAM credentials engine to an IBM Secrets Manager instance."
@@ -134,12 +142,12 @@
"key": "existing_resource_group_name",
"required": true,
"custom_config": {
- "type": "resource_group",
- "grouping": "deployment",
- "original_grouping": "deployment",
- "config_constraints": {
- "identifier": "rg_name"
- }
+ "type": "resource_group",
+ "grouping": "deployment",
+ "original_grouping": "deployment",
+ "config_constraints": {
+ "identifier": "rg_name"
+ }
}
},
{
@@ -169,7 +177,7 @@
"config_constraints": {
"type": "string"
}
- }
+ }
},
{
"key": "service_plan",
@@ -252,6 +260,9 @@
},
{
"key": "secrets_manager_cbr_rules"
+ },
+ {
+ "key": "secret_groups"
}
],
"architecture": {
@@ -401,7 +412,7 @@
"config_constraints": {
"type": "string"
}
- }
+ }
},
{
"key": "service_plan",
@@ -423,12 +434,12 @@
"key": "existing_resource_group_name",
"required": true,
"custom_config": {
- "type": "resource_group",
- "grouping": "deployment",
- "original_grouping": "deployment",
- "config_constraints": {
- "identifier": "rg_name"
- }
+ "type": "resource_group",
+ "grouping": "deployment",
+ "original_grouping": "deployment",
+ "config_constraints": {
+ "identifier": "rg_name"
+ }
}
},
{
@@ -463,6 +474,9 @@
},
{
"key": "secrets_manager_cbr_rules"
+ },
+ {
+ "key": "secret_groups"
}
],
"architecture": {
diff --git a/modules/secrets/README.md b/modules/secrets/README.md
index fc8132b1..411eef03 100644
--- a/modules/secrets/README.md
+++ b/modules/secrets/README.md
@@ -50,7 +50,7 @@ module "secrets_manager" {
| Name | Source | Version |
|------|--------|---------|
-| [secret\_groups](#module\_secret\_groups) | terraform-ibm-modules/secrets-manager-secret-group/ibm | 1.2.3 |
+| [secret\_groups](#module\_secret\_groups) | terraform-ibm-modules/secrets-manager-secret-group/ibm | 1.3.2 |
| [secrets](#module\_secrets) | terraform-ibm-modules/secrets-manager-secret/ibm | 1.7.0 |
### Resources
@@ -66,7 +66,7 @@ module "secrets_manager" {
| [endpoint\_type](#input\_endpoint\_type) | The service endpoint type to communicate with the provided secrets manager instance. Possible values are `public` or `private` | `string` | `"public"` | no |
| [existing\_sm\_instance\_guid](#input\_existing\_sm\_instance\_guid) | Instance ID of Secrets Manager instance in which the Secret will be added. | `string` | n/a | yes |
| [existing\_sm\_instance\_region](#input\_existing\_sm\_instance\_region) | Region which the Secret Manager is deployed. | `string` | n/a | yes |
-| [secrets](#input\_secrets) | Secret Manager secrets configurations. | list(object({
secret_group_name = string
secret_group_description = optional(string)
existing_secret_group = optional(bool, false)
secrets = optional(list(object({
secret_name = string
secret_description = optional(string)
secret_type = optional(string)
imported_cert_certificate = optional(string)
imported_cert_private_key = optional(string)
imported_cert_intermediate = optional(string)
secret_username = optional(string)
secret_labels = optional(list(string), [])
secret_payload_password = optional(string, "")
secret_auto_rotation = optional(bool, true)
secret_auto_rotation_unit = optional(string, "day")
secret_auto_rotation_interval = optional(number, 89)
service_credentials_ttl = optional(string, "7776000") # 90 days
service_credentials_source_service_crn = optional(string)
service_credentials_source_service_role_crn = optional(string)
service_credentials_source_service_hmac = optional(bool, false)
})))
})) | `[]` | no |
+| [secrets](#input\_secrets) | Secret Manager secrets configurations. | list(object({
secret_group_name = string
secret_group_description = optional(string)
existing_secret_group = optional(bool, false)
create_access_group = optional(bool, false)
access_group_name = optional(string)
access_group_roles = optional(list(string))
access_group_tags = optional(list(string))
secrets = optional(list(object({
secret_name = string
secret_description = optional(string)
secret_type = optional(string)
imported_cert_certificate = optional(string)
imported_cert_private_key = optional(string)
imported_cert_intermediate = optional(string)
secret_username = optional(string)
secret_labels = optional(list(string), [])
secret_payload_password = optional(string, "")
secret_auto_rotation = optional(bool, true)
secret_auto_rotation_unit = optional(string, "day")
secret_auto_rotation_interval = optional(number, 89)
service_credentials_ttl = optional(string, "7776000") # 90 days
service_credentials_source_service_crn = optional(string)
service_credentials_source_service_role_crn = optional(string)
service_credentials_source_service_hmac = optional(bool, false)
})), [])
})) | `[]` | no |
### Outputs
diff --git a/modules/secrets/main.tf b/modules/secrets/main.tf
index 7d49e1e9..b03aba72 100644
--- a/modules/secrets/main.tf
+++ b/modules/secrets/main.tf
@@ -6,8 +6,12 @@ locals {
secret_groups = flatten([
for secret_group in var.secrets :
secret_group.existing_secret_group ? [] : [{
- secret_group_name = secret_group.secret_group_name
- secret_group_description = secret_group.secret_group_description
+ secret_group_name = secret_group.secret_group_name
+ secret_group_description = secret_group.secret_group_description
+ secret_group_create_access_group = secret_group.create_access_group
+ secret_group_access_group_name = secret_group.access_group_name
+ secret_group_access_group_roles = secret_group.access_group_roles
+ secret_group_access_group_tags = secret_group.access_group_tags
}]
])
}
@@ -21,12 +25,16 @@ data "ibm_sm_secret_groups" "existing_secret_groups" {
module "secret_groups" {
for_each = { for obj in local.secret_groups : obj.secret_group_name => obj }
source = "terraform-ibm-modules/secrets-manager-secret-group/ibm"
- version = "1.2.3"
+ version = "1.3.2"
region = var.existing_sm_instance_region
secrets_manager_guid = var.existing_sm_instance_guid
secret_group_name = each.value.secret_group_name
secret_group_description = each.value.secret_group_description
endpoint_type = var.endpoint_type
+ create_access_group = each.value.secret_group_create_access_group
+ access_group_name = each.value.secret_group_access_group_name
+ access_group_roles = each.value.secret_group_access_group_roles
+ access_group_tags = each.value.secret_group_access_group_tags
}
##############################################################################
diff --git a/modules/secrets/variables.tf b/modules/secrets/variables.tf
index 80a4d0ba..9097de9d 100644
--- a/modules/secrets/variables.tf
+++ b/modules/secrets/variables.tf
@@ -23,6 +23,10 @@ variable "secrets" {
secret_group_name = string
secret_group_description = optional(string)
existing_secret_group = optional(bool, false)
+ create_access_group = optional(bool, false)
+ access_group_name = optional(string)
+ access_group_roles = optional(list(string))
+ access_group_tags = optional(list(string))
secrets = optional(list(object({
secret_name = string
secret_description = optional(string)
@@ -40,7 +44,7 @@ variable "secrets" {
service_credentials_source_service_crn = optional(string)
service_credentials_source_service_role_crn = optional(string)
service_credentials_source_service_hmac = optional(bool, false)
- })))
+ })), [])
}))
description = "Secret Manager secrets configurations."
default = []
@@ -58,4 +62,11 @@ variable "secrets" {
true if(secret.secret_group_name == "default" && secret.existing_secret_group == false)
]) == 0
}
+ validation {
+ error_message = "When creating an access group, a list of roles must be specified."
+ condition = length([
+ for secret in var.secrets :
+ true if(secret.create_access_group && secret.access_group_roles == null)
+ ]) == 0
+ }
}
diff --git a/reference-architecture/secrets_manager.svg b/reference-architecture/secrets_manager.svg
index 5cb34c79..14b9d2a2 100644
--- a/reference-architecture/secrets_manager.svg
+++ b/reference-architecture/secrets_manager.svg
@@ -1,4 +1,4 @@
-
\ No newline at end of file
+list(object({
secret_group_name = string
secret_group_description = optional(string)
create_access_group = optional(bool, true)
access_group_name = optional(string)
access_group_roles = optional(list(string), ["SecretsReader"])
access_group_tags = optional(list(string))
})) | [| no | | [secrets\_manager\_cbr\_rules](#input\_secrets\_manager\_cbr\_rules) | (Optional, list) List of CBR rules to create. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-secrets-manager/blob/main/solutions/fully-configurable/DA-cbr_rules.md) |
{
"access_group_name": "general-secrets-group-access-group",
"access_group_roles": [
"SecretsReader"
],
"create_access_group": true,
"secret_group_description": "A general purpose secrets group with an associated access group which has a secrets reader role",
"secret_group_name": "General"
}
]
list(object({
description = string
account_id = string
rule_contexts = list(object({
attributes = optional(list(object({
name = string
value = string
}))) }))
enforcement_mode = string
operations = optional(list(object({
api_types = list(object({
api_type_id = string
}))
})))
})) | `[]` | no |
| [secrets\_manager\_endpoint\_type](#input\_secrets\_manager\_endpoint\_type) | The type of endpoint (public or private) to connect to the Secrets Manager API. The Terraform provider uses this endpoint type to interact with the Secrets Manager API and configure Event Notifications. | `string` | `"private"` | no |
| [secrets\_manager\_instance\_name](#input\_secrets\_manager\_instance\_name) | The name to give the Secrets Manager instance provisioned by this solution. If a prefix input variable is specified, it is added to the value in the `list(object({
secret_group_name = string
secret_group_description = optional(string)
create_access_group = optional(bool, true)
access_group_name = optional(string)
access_group_roles = optional(list(string), ["SecretsReader"])
access_group_tags = optional(list(string))
})) | [| no | | [secrets\_manager\_cbr\_rules](#input\_secrets\_manager\_cbr\_rules) | (Optional, list) List of CBR rules to create. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-secrets-manager/blob/main/solutions/fully-configurable/DA-cbr_rules.md) |
{
"access_group_name": "general-secrets-group-access-group",
"access_group_roles": [
"SecretsReader"
],
"create_access_group": true,
"secret_group_description": "A general purpose secrets group with an associated access group which has a secrets reader role",
"secret_group_name": "General"
}
]
list(object({
description = string
account_id = string
rule_contexts = list(object({
attributes = optional(list(object({
name = string
value = string
}))) }))
enforcement_mode = string
operations = optional(list(object({
api_types = list(object({
api_type_id = string
}))
})))
})) | `[]` | no |
| [secrets\_manager\_instance\_name](#input\_secrets\_manager\_instance\_name) | The name to give the Secrets Manager instance provisioned by this solution. If a prefix input variable is specified, it is added to the value in the `