-
Notifications
You must be signed in to change notification settings - Fork 5
feat: added support to enable the secrets manager public cert engine #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 19 commits
9e7a763
94742e8
82f8dc1
ae5d3c2
a4befc8
849ec6d
dc5f3a0
1f65269
22c7b66
0c6829d
8577a4e
5f89b36
1c97f3e
c3373bd
e8e97fb
3ea30c8
886055c
59a7d8a
19f9c7a
6e5f319
87724ea
b0d4264
3c97bff
c8300aa
9869b55
6d5d310
0e15f69
fdbfc07
9b94a00
04b090d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -229,6 +229,13 @@ | |
| "description": "The CRN of an existing Secrets Manager instance to use in this solution. If not set, a new Secrets Manager instance is provisioned.", | ||
| "required": false | ||
| }, | ||
| { | ||
| "key": "existing_secrets_endpoint_type", | ||
| "type": "string", | ||
| "default_value": "__NULL__", | ||
| "description": "The endpoint type to use if existing_secrets_manager_crn is specified.", | ||
iamar7 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "required": false | ||
| }, | ||
| { | ||
| "key": "sm_service_plan", | ||
| "type": "string", | ||
|
|
@@ -253,6 +260,41 @@ | |
| "description": "Set this to true to to configure a Secrets Manager IAM credentials engine. If set to false, no IAM engine will be configured for your instance.", | ||
| "required": false | ||
| }, | ||
| { | ||
| "key": "secret_manager_public_engine_enabled", | ||
| "type": "boolean", | ||
| "default_value": false, | ||
| "description": "Set this to true to configure a Secrets Manager public certificate engine for an existing Secrets Manager instance. If set to false, no public certificate engine will be configured for your instance.", | ||
iamar7 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "required": false | ||
| }, | ||
| { | ||
| "key": "cis_id", | ||
| "type": "string", | ||
| "default_value": "__NULL__", | ||
| "description": "Cloud Internet Service ID.", | ||
|
||
| "required": false | ||
| }, | ||
| { | ||
| "key": "ca_name", | ||
| "type": "string", | ||
| "default_value": "cert-auth", | ||
| "description": "The name of the certificate authority for Secrets Manager.", | ||
iamar7 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "required": false | ||
| }, | ||
| { | ||
| "key": "dns_provider_name", | ||
| "type": "string", | ||
| "default_value": "certificate-dns", | ||
|
||
| "description": "The name of the DNS provider for the public certificate secrets engine configuration.", | ||
| "required": false | ||
| }, | ||
| { | ||
| "key": "acme_letsencrypt_private_key", | ||
| "type": "string", | ||
| "default_value": "__NULL__", | ||
| "description": "The private key generated by the ACME account creation tool.", | ||
|
||
| "required": false | ||
iamar7 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }, | ||
| { | ||
| "key": "scc_service_plan", | ||
| "type": "string", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,8 @@ import ( | |
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/IBM/go-sdk-core/v5/core" | ||
| "github.com/IBM/secrets-manager-go-sdk/v2/secretsmanagerv2" | ||
| "github.com/gruntwork-io/terratest/modules/files" | ||
| "github.com/gruntwork-io/terratest/modules/logger" | ||
| "github.com/gruntwork-io/terratest/modules/random" | ||
|
|
@@ -46,21 +48,34 @@ func TestMain(m *testing.M) { | |
|
|
||
| func TestProjectsFullTest(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| acme_letsencrypt_private_key := GetSecretsManagerKey( // pragma: allowlist secret | ||
| permanentResources["acme_letsencrypt_private_key_sm_id"].(string), | ||
| permanentResources["acme_letsencrypt_private_key_sm_region"].(string), | ||
| permanentResources["acme_letsencrypt_private_key_secret_id"].(string), | ||
| ) | ||
|
|
||
| options := testprojects.TestProjectOptionsDefault(&testprojects.TestProjectsOptions{ | ||
| Testing: t, | ||
| Prefix: "cs", // setting prefix here gets a random string appended to it | ||
| ParallelDeploy: true, | ||
| }) | ||
|
|
||
| options.StackInputs = map[string]interface{}{ | ||
| "prefix": options.Prefix, | ||
| "region": validRegions[rand.Intn(len(validRegions))], | ||
| "existing_resource_group_name": resourceGroup, | ||
| "sm_service_plan": "trial", | ||
| "secret_manager_iam_engine_enabled": true, | ||
| "ibmcloud_api_key": options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], // always required by the stack | ||
| "enable_platform_logs_metrics": false, | ||
| "en_email_list": []string{"[email protected]"}, | ||
| "prefix": options.Prefix, | ||
| "region": validRegions[rand.Intn(len(validRegions))], | ||
| "existing_resource_group_name": resourceGroup, | ||
| "sm_service_plan": "trial", | ||
| "secret_manager_iam_engine_enabled": true, | ||
| "secret_manager_public_engine_enabled": true, | ||
| "existing_secrets_endpoint_type": "private", | ||
| "cis_id": permanentResources["cisInstanceId"], | ||
| "ca_name": permanentResources["certificateAuthorityName"], | ||
| "dns_provider_name": permanentResources["dnsProviderName"], | ||
| "acme_letsencrypt_private_key": *acme_letsencrypt_private_key, // pragma: allowlist secret | ||
| "ibmcloud_api_key": options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], // always required by the stack | ||
| "enable_platform_logs_metrics": false, | ||
| "en_email_list": []string{"[email protected]"}, | ||
| } | ||
|
|
||
| err := options.RunProjectsTest() | ||
|
|
@@ -71,9 +86,37 @@ func TestProjectsFullTest(t *testing.T) { | |
| } | ||
| } | ||
|
|
||
| func GetSecretsManagerKey(sm_id string, sm_region string, sm_key_id string) *string { | ||
| secretsManagerService, err := secretsmanagerv2.NewSecretsManagerV2(&secretsmanagerv2.SecretsManagerV2Options{ | ||
| URL: fmt.Sprintf("https://%s.%s.secrets-manager.appdomain.cloud", sm_id, sm_region), | ||
| Authenticator: &core.IamAuthenticator{ | ||
| ApiKey: os.Getenv("TF_VAR_ibmcloud_api_key"), | ||
| }, | ||
| }) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| getSecretOptions := secretsManagerService.NewGetSecretOptions( | ||
| sm_key_id, | ||
| ) | ||
|
|
||
| secret, _, err := secretsManagerService.GetSecret(getSecretOptions) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| return secret.(*secretsmanagerv2.ArbitrarySecret).Payload | ||
| } | ||
|
|
||
| func TestProjectsExistingResourcesTest(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| acme_letsencrypt_private_key := GetSecretsManagerKey( // pragma: allowlist secret | ||
iamar7 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| permanentResources["acme_letsencrypt_private_key_sm_id"].(string), | ||
| permanentResources["acme_letsencrypt_private_key_sm_region"].(string), | ||
| permanentResources["acme_letsencrypt_private_key_secret_id"].(string), | ||
| ) | ||
|
|
||
| // ------------------------------------------------------------------------------------ | ||
| // Provision RG, EN and SM | ||
| // ------------------------------------------------------------------------------------ | ||
|
|
@@ -116,15 +159,21 @@ func TestProjectsExistingResourcesTest(t *testing.T) { | |
| }) | ||
|
|
||
| options.StackInputs = map[string]interface{}{ | ||
| "prefix": terraform.Output(t, existingTerraformOptions, "prefix"), | ||
| "region": terraform.Output(t, existingTerraformOptions, "region"), | ||
| "existing_resource_group_name": terraform.Output(t, existingTerraformOptions, "resource_group_name"), | ||
| "ibmcloud_api_key": options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], // always required by the stack | ||
| "enable_platform_logs_metrics": false, | ||
| "existing_secrets_manager_crn": terraform.Output(t, existingTerraformOptions, "secrets_manager_instance_crn"), | ||
| "secret_manager_iam_engine_enabled": true, | ||
| "existing_kms_instance_crn": permanentResources["hpcs_south_crn"], | ||
| "en_email_list": []string{"[email protected]"}, | ||
| "prefix": terraform.Output(t, existingTerraformOptions, "prefix"), | ||
| "region": terraform.Output(t, existingTerraformOptions, "region"), | ||
| "existing_resource_group_name": terraform.Output(t, existingTerraformOptions, "resource_group_name"), | ||
| "ibmcloud_api_key": options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], // always required by the stack | ||
| "enable_platform_logs_metrics": false, | ||
| "existing_secrets_manager_crn": terraform.Output(t, existingTerraformOptions, "secrets_manager_instance_crn"), | ||
| "secret_manager_iam_engine_enabled": true, | ||
| "secret_manager_public_engine_enabled": true, | ||
| "existing_secrets_endpoint_type": "private", | ||
| "cis_id": permanentResources["cisInstanceId"], | ||
| "ca_name": permanentResources["certificateAuthorityName"], | ||
| "dns_provider_name": permanentResources["dnsProviderName"], | ||
| "acme_letsencrypt_private_key": *acme_letsencrypt_private_key, // pragma: allowlist secret | ||
| "existing_kms_instance_crn": permanentResources["hpcs_south_crn"], | ||
| "en_email_list": []string{"[email protected]"}, | ||
| } | ||
|
|
||
| err := options.RunProjectsTest() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.