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 @@ -
IBM Cloud
Region
Existing Resource Group
Secrets Manager
s2s IAM auth
Existing KMS
Key Ring
Root  Key
Existing Event NotificationsIAM
\ No newline at end of file +
IBM Cloud
IBM Cloud
Region
Region
Existing Resource Group
Existing Resource Group
Secrets Manager
Secrets Manager
s2s IAM auth
s2s IAM auth
Existing KMS
Existing KMS
Key Ring
Key Ring
Root  Key
Existing Event Notifications
Identity & Access
Management
Identity & Access...
user
Access Groups
Access Groups
Secret Groups
Secret Groups
Text is not SVG - cannot display
\ No newline at end of file diff --git a/solutions/fully-configurable/README.md b/solutions/fully-configurable/README.md index 4d60060f..58a3964f 100644 --- a/solutions/fully-configurable/README.md +++ b/solutions/fully-configurable/README.md @@ -3,6 +3,8 @@ This solution supports the following: - Taking in an existing resource group. - Provisioning and configuring of a Secrets Manager instance. +- Provisioning secrets groups inside a new or pre-existing Secrets Manager instance. +- Provisioning access groups to the secrets groups of the Secrets Manager instance. - Configuring KMS encryption using a newly created key, or passing an existing key. ![secret-manager-deployable-architecture](../../reference-architecture/secrets_manager.svg) @@ -65,6 +67,7 @@ This solution supports the following: | [prefix](#input\_prefix) | The prefix to add to all resources created by this solution. To not use any prefix value, you can set this value to `null` or an empty string. | `string` | n/a | yes | | [provider\_visibility](#input\_provider\_visibility) | Set the visibility value for the IBM terraform provider. Supported values are `public`, `private`, `public-and-private`. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/guides/custom-service-endpoints). | `string` | `"private"` | no | | [region](#input\_region) | The region to provision resources to. | `string` | `"us-south"` | no | +| [secret\_groups](#input\_secret\_groups) | Secret Manager secret group and access group configurations. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-secrets-manager/tree/main/solutions/fully-configurable/provisioning_secrets_groups.md). |
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))
}))
|
[
{
"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"
}
]
| 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) |
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 `-value` format. Applies only if `existing_secrets_manager_crn` is not provided. | `string` | `"secrets-manager"` | no | diff --git a/solutions/fully-configurable/main.tf b/solutions/fully-configurable/main.tf index 94b74d59..d2d26a88 100644 --- a/solutions/fully-configurable/main.tf +++ b/solutions/fully-configurable/main.tf @@ -187,6 +187,7 @@ module "secrets_manager" { cbr_rules = var.secrets_manager_cbr_rules endpoint_type = var.secrets_manager_endpoint_type allowed_network = var.allowed_network + secrets = var.secret_groups } data "ibm_resource_instance" "existing_sm" { diff --git a/solutions/fully-configurable/provisioning_secrets_groups.md b/solutions/fully-configurable/provisioning_secrets_groups.md new file mode 100644 index 00000000..0a5a33f6 --- /dev/null +++ b/solutions/fully-configurable/provisioning_secrets_groups.md @@ -0,0 +1,33 @@ +# Provisioning Secrets Groups + +Secrets groups and access groups associated to them can be provisioned using the `secret_groups` variable. + +An example value: +``` +[ + { + secret_group_name = "Example Secret Group" + secret_group_description = "an example secret group" + create_access_group = true + access_group_name = "example-secret-group-access-group" + access_group_roles = ["SecretsReader"] + access_group_tags = [] + }, + { + secret_group_name = "Existing Secret Group" + secret_group_description = "an existing secret group" + existing_secret_group = true + } +] +``` + +It is a list of objects, so you can specify as many secrets groups as you wish. If you do not want to create any secret groups, pass a value of `[]`. + +## Options: + +- `secret_group_name` (required) - the name of secrets group +- `secret_group_description` (optional, default = `null`) - the description of secrets group +- `create_access_group` (optional, default = `false`) - Whether to create an access group associated to this secrets group +- `access_group_name` (optional, default = `null`) - Name of the access group to create. If you are creating an access group and a name is not passed, the name will become `-access-group` +- `access_group_roles` (optional, default = `null`) - The list of roles to give to the created access group. If `create_access_group` is true, there must be a value here. Valid values: ["Reader", "Writer", "Manager", "SecretsReader", "Viewer", "Operator", "Editor", "Administrator", "Service Configuration Reader", "Key Manager"] +- `access_group_tags` (optional, default = `[]`) - Tags that should be applied to the access group. diff --git a/solutions/fully-configurable/variables.tf b/solutions/fully-configurable/variables.tf index 55df6bb1..d2469259 100644 --- a/solutions/fully-configurable/variables.tf +++ b/solutions/fully-configurable/variables.tf @@ -105,6 +105,43 @@ variable "allowed_network" { } } +variable "secret_groups" { + type = 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)) + })) + description = "Secret Manager secret group and access group configurations. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-secrets-manager/tree/main/solutions/fully-configurable/provisioning_secrets_groups.md)." + nullable = false + default = [ + { + secret_group_name = "General" + secret_group_description = "A general purpose secrets group with an associated access group which has a secrets reader role" + create_access_group = true + access_group_name = "general-secrets-group-access-group" + access_group_roles = ["SecretsReader"] + } + ] + validation { + error_message = "The name of the secret group cannot be null or empty string." + condition = length([ + for group in var.secret_groups : + true if(group.secret_group_name == "" || group.secret_group_name == null) + ]) == 0 + } + validation { + error_message = "When creating an access group, a list of roles must be specified." + condition = length([ + for group in var.secret_groups : + true if(group.create_access_group && group.access_group_roles == null) + ]) == 0 + } +} + + ######################################################################################################################## # Key Protect ######################################################################################################################## diff --git a/solutions/security-enforced/README.md b/solutions/security-enforced/README.md index 0932c4e6..2d14eca7 100644 --- a/solutions/security-enforced/README.md +++ b/solutions/security-enforced/README.md @@ -42,6 +42,7 @@ No resources. | [kms\_key\_ring\_name](#input\_kms\_key\_ring\_name) | The name for the new key ring to store the key. Applies only if `existing_secrets_manager_kms_key_crn` is not specified. If a prefix input variable is passed, it is added to the value in the `-value` format. . | `string` | `"secrets-manager-key-ring"` | no | | [prefix](#input\_prefix) | The prefix to add to all resources created by this solution. To not use any prefix value, you can set this value to `null` or an empty string. | `string` | n/a | yes | | [region](#input\_region) | The region to provision resources to. | `string` | `"us-south"` | no | +| [secret\_groups](#input\_secret\_groups) | Secret Manager secret group and access group configurations. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-secrets-manager/tree/main/solutions/fully-configurable/provisioning_secrets_groups.md). |
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))
}))
|
[
{
"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"
}
]
| 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) |
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 `-value` format. Applies only if `existing_secrets_manager_crn` is not provided. | `string` | `"secrets-manager"` | no | | [secrets\_manager\_resource\_tags](#input\_secrets\_manager\_resource\_tags) | The list of resource tags you want to associate with your Secrets Manager instance. Applies only if `existing_secrets_manager_crn` is not provided. | `list(any)` | `[]` | no | diff --git a/solutions/security-enforced/main.tf b/solutions/security-enforced/main.tf index b7174343..5f6172b0 100644 --- a/solutions/security-enforced/main.tf +++ b/solutions/security-enforced/main.tf @@ -26,4 +26,5 @@ module "secrets_manager" { event_notifications_from_email = var.event_notifications_from_email event_notifications_reply_to_email = var.event_notifications_reply_to_email secrets_manager_cbr_rules = var.secrets_manager_cbr_rules + secret_groups = var.secret_groups } diff --git a/solutions/security-enforced/variables.tf b/solutions/security-enforced/variables.tf index ad308e4a..0a0f6275 100644 --- a/solutions/security-enforced/variables.tf +++ b/solutions/security-enforced/variables.tf @@ -74,6 +74,42 @@ variable "secrets_manager_resource_tags" { default = [] } +variable "secret_groups" { + type = 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)) + })) + description = "Secret Manager secret group and access group configurations. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-secrets-manager/tree/main/solutions/fully-configurable/provisioning_secrets_groups.md)." + nullable = false + default = [ + { + secret_group_name = "General" + secret_group_description = "A general purpose secrets group with an associated access group which has a secrets reader role" + create_access_group = true + access_group_name = "general-secrets-group-access-group" + access_group_roles = ["SecretsReader"] + } + ] + validation { + error_message = "The name of the secret group cannot be null or empty string." + condition = length([ + for group in var.secret_groups : + true if(group.secret_group_name == "" || group.secret_group_name == null) + ]) == 0 + } + validation { + error_message = "When creating an access group, a list of roles must be specified." + condition = length([ + for group in var.secret_groups : + true if(group.create_access_group && group.access_group_roles == null) + ]) == 0 + } +} + ######################################################################################################################## # Key Protect ######################################################################################################################## diff --git a/tests/pr_test.go b/tests/pr_test.go index d2300c18..2db4b055 100644 --- a/tests/pr_test.go +++ b/tests/pr_test.go @@ -40,6 +40,18 @@ var validRegions = []string{ // "au-syd", } +func _secret_group_config(prefix string) []map[string]interface{} { + var secretGroupConfig = []map[string]interface{}{ + { + "secret_group_name": "General", + "secret_group_description": "default description", + "create_access_group": true, + "access_group_name": prefix + "-general-secrets-group-access-group", // this needs to be unique + "access_group_roles": []string{"SecretsReader"}, + }} + return secretGroupConfig +} + // TestMain will be run before any parallel tests, used to read data from yaml for use with tests func TestMain(m *testing.M) { @@ -70,6 +82,7 @@ func setupOptions(t *testing.T, prefix string, checkApplyResultForUpgrade bool) } func TestRunFullyConfigurableSchematics(t *testing.T) { + t.Parallel() // Set up a schematics test options := testschematic.TestSchematicOptionsDefault(&testschematic.TestSchematicOptions{ @@ -95,6 +108,7 @@ func TestRunFullyConfigurableSchematics(t *testing.T) { {Name: "region", Value: validRegions[rand.Intn(len(validRegions))], DataType: "string"}, {Name: "existing_resource_group_name", Value: resourceGroup, DataType: "string"}, {Name: "service_plan", Value: "trial", DataType: "string"}, + {Name: "secret_groups", Value: _secret_group_config(options.Prefix), DataType: "list(object)"}, } err := options.RunSchematicTest() @@ -165,6 +179,7 @@ func TestRunExistingResourcesInstancesFullyConfigurable(t *testing.T) { {Name: "existing_secrets_manager_kms_key_crn", Value: permanentResources["hpcs_south_root_key_crn"], DataType: "string"}, {Name: "kms_encryption_enabled", Value: true, DataType: "bool"}, {Name: "service_plan", Value: "trial", DataType: "string"}, + {Name: "secret_groups", Value: _secret_group_config(options.Prefix), DataType: "list(object)"}, } err := options.RunSchematicTest() @@ -185,6 +200,8 @@ func TestRunExistingResourcesInstancesFullyConfigurable(t *testing.T) { } func TestRunExistingSMInstanceFullyConfigurable(t *testing.T) { + t.Parallel() + options := testschematic.TestSchematicOptionsDefault(&testschematic.TestSchematicOptions{ Testing: t, TarIncludePatterns: []string{ @@ -208,6 +225,7 @@ func TestRunExistingSMInstanceFullyConfigurable(t *testing.T) { {Name: "existing_resource_group_name", Value: resourceGroup, DataType: "string"}, {Name: "existing_secrets_manager_crn", Value: permanentResources["secretsManagerCRN"], DataType: "string"}, {Name: "service_plan", Value: "trial", DataType: "string"}, + {Name: "secret_groups", Value: _secret_group_config(options.Prefix), DataType: "list(object)"}, } err := options.RunSchematicTest() @@ -215,6 +233,7 @@ func TestRunExistingSMInstanceFullyConfigurable(t *testing.T) { } func TestRunSecurityEnforcedSchematics(t *testing.T) { + t.Parallel() // Set up a schematics test options := testschematic.TestSchematicOptionsDefault(&testschematic.TestSchematicOptions{ @@ -239,16 +258,17 @@ func TestRunSecurityEnforcedSchematics(t *testing.T) { {Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true}, {Name: "prefix", Value: options.Prefix, DataType: "string"}, {Name: "region", Value: validRegions[rand.Intn(len(validRegions))], DataType: "string"}, - {Name: "existing_resource_group_name", Value: "geretain-test-secrets-manager", DataType: "string"}, + {Name: "existing_resource_group_name", Value: resourceGroup, DataType: "string"}, {Name: "service_plan", Value: "trial", DataType: "string"}, {Name: "existing_kms_instance_crn", Value: permanentResources["hpcs_south_crn"], DataType: "string"}, + {Name: "secret_groups", Value: _secret_group_config(options.Prefix), DataType: "list(object)"}, } - err := options.RunSchematicTest() assert.NoError(t, err, "Schematic Test had unexpected error") } func TestRunSecretsManagerSecurityEnforcedUpgradeSchematic(t *testing.T) { + t.Parallel() // Set up a schematics test options := testschematic.TestSchematicOptionsDefault(&testschematic.TestSchematicOptions{ @@ -275,6 +295,7 @@ func TestRunSecretsManagerSecurityEnforcedUpgradeSchematic(t *testing.T) { {Name: "existing_resource_group_name", Value: "geretain-test-secrets-manager", DataType: "string"}, {Name: "service_plan", Value: "trial", DataType: "string"}, {Name: "existing_kms_instance_crn", Value: permanentResources["hpcs_south_crn"], DataType: "string"}, + {Name: "secret_groups", Value: _secret_group_config(options.Prefix), DataType: "list(object)"}, } err := options.RunSchematicUpgradeTest() diff --git a/variables.tf b/variables.tf index 11da4ec8..caa97ef8 100644 --- a/variables.tf +++ b/variables.tf @@ -145,6 +145,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)