Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9e7a763
feat: added support to enable the secrets manager public cert engine
Jul 30, 2024
94742e8
fix: add secret_manager_public_engine_enabled in pr_test
Jul 30, 2024
82f8dc1
Merge branch 'main' into 9714-pblc
iamar7 Jul 30, 2024
ae5d3c2
Merge branch 'main' into 9714-pblc
iamar7 Aug 2, 2024
a4befc8
fix: fmt issue
Aug 2, 2024
849ec6d
Merge branch 'main' into 9714-pblc
iamar7 Aug 2, 2024
dc5f3a0
fix: added public engine dependency
Aug 2, 2024
1f65269
Merge branch 'main' into 9714-pblc
iamar7 Aug 4, 2024
22c7b66
fix: skip test tear down
Aug 6, 2024
0c6829d
Merge branch '9714-pblc' of https://github.com/terraform-ibm-modules/…
Aug 6, 2024
8577a4e
fix: update SM plan
Aug 7, 2024
5f89b36
resolve pre-commit error
Aug 7, 2024
1c97f3e
fix: add existing endpoint
Aug 7, 2024
c3373bd
fix: remove skip tear down
Aug 7, 2024
e8e97fb
fix: update pr_test
Aug 9, 2024
3ea30c8
Merge branch 'main' into 9714-pblc
iamar7 Aug 12, 2024
886055c
update common-dev-assets
Aug 12, 2024
59a7d8a
update branch
Aug 12, 2024
19f9c7a
fix: update SM plan
Aug 13, 2024
6e5f319
Merge branch 'main' of https://github.com/terraform-ibm-modules/stack…
Aug 18, 2024
87724ea
fix: resolve comments
Aug 19, 2024
b0d4264
Merge branch 'main' into 9714-pblc
iamar7 Aug 19, 2024
3c97bff
Merge branch 'main' into 9714-pblc
iamar7 Aug 21, 2024
c8300aa
fix: resolve comments
Aug 21, 2024
9869b55
fix: resolve comments
Aug 23, 2024
6d5d310
Merge branch 'main' into 9714-pblc
iamar7 Aug 26, 2024
0e15f69
fix: update ibm_catalog.json
iamar7 Aug 26, 2024
fdbfc07
Merge branch 'main' into 9714-pblc
iamar7 Sep 3, 2024
9b94a00
Merge branch 'main' into 9714-pblc
iamar7 Sep 13, 2024
04b090d
fix: pre-commit errors
Sep 13, 2024
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
54 changes: 54 additions & 0 deletions ibm_catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,24 @@
"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": "private",
"description": "The endpoint type to use if `existing_secrets_manager_crn` is specified.",
"required": false,
"options": [
{
"displayname": "public",
"value": "public"
},
{
"displayname": "private",
"value": "private"
}
]

},
{
"key": "sm_service_plan",
"type": "string",
Expand All @@ -260,6 +278,42 @@
"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": "Whether to configure a Secrets Manager public certificate engine for an existing Secrets Manager instance. If `false`, no public certificate engine is configured for your instance.",
"required": false
},
{
"key": "cis_id",
"type": "string",
"default_value": "__NULL__",
"description": "Cloud Internet Service ID. Required if `secret_manager_public_engine_enabled` is set to true.",
"required": false
},
{
"key": "ca_name",
"type": "string",
"default_value": "__NULL__",
"description": "The name of the certificate authority for Secrets Manager. Required if `secret_manager_public_engine_enabled` is set to true.",
"required": false
},
{
"key": "dns_provider_name",
"type": "string",
"default_value": "__NULL__",
"description": "The name of the DNS provider for the public certificate secrets engine configuration. Required if `secret_manager_public_engine_enabled` is set to true.",
"required": false
},
{
"key": "acme_letsencrypt_private_key",
"type": "string",
"default_value": "__NULL__",
"description": "The private key generated by the ACME protocol. For more information, see [Preparing to order public certificates](https://cloud.ibm.com/docs/secrets-manager?topic=secrets-manager-prepare-order-certificates).",
"required": false,
"sensitive": true
},
{
"key": "scc_service_plan",
"type": "string",
Expand Down
75 changes: 72 additions & 3 deletions stack_definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,56 @@
"required": false,
"type": "boolean",
"hidden": false,
"default": false
"default": false,
"custom_config": {}
},
{
"name": "secret_manager_public_engine_enabled",
"required": false,
"type": "boolean",
"hidden": false,
"default": false,
"custom_config": {}
},
{
"name": "existing_secrets_endpoint_type",
"required": false,
"type": "string",
"hidden": false,
"default": "private",
"custom_config": {}
},
{
"name": "cis_id",
"required": false,
"type": "string",
"hidden": false,
"default": "__NULL__",
"custom_config": {}
},
{
"name": "ca_name",
"required": false,
"type": "string",
"hidden": false,
"default": "__NULL__",
"custom_config": {}
},
{
"name": "dns_provider_name",
"required": false,
"type": "string",
"hidden": false,
"default": "__NULL__",
"custom_config": {}
},
{
"name": "acme_letsencrypt_private_key",
"required": false,
"type": "string",
"hidden": true,
"default": "__NULL__",
"custom_config": {}
}
],
"members": [
Expand Down Expand Up @@ -325,10 +374,30 @@
{
"name": "service_plan",
"value": "ref:../../inputs/sm_service_plan"
},
{
"name": "iam_engine_enabled",
"value": "ref:../../inputs/secret_manager_iam_engine_enabled"
},
{
"name": "public_engine_enabled",
"value": "ref:../../inputs/secret_manager_public_engine_enabled"
},
{
"name": "cis_id",
"value": "ref:../../inputs/cis_id"
},
{
"name": "ca_name",
"value": "ref:../../inputs/ca_name"
},
{
"name": "dns_provider_name",
"value": "ref:../../inputs/dns_provider_name"
},
{
"name": "iam_engine_enabled",
"value": "ref:../../inputs/secret_manager_iam_engine_enabled"
"name": "acme_letsencrypt_private_key",
"value": "ref:../../inputs/acme_letsencrypt_private_key"
},
{
"name": "enable_event_notification",
Expand Down
1 change: 1 addition & 0 deletions tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ require (
github.com/IBM/go-sdk-core/v5 v5.17.5 // indirect
github.com/IBM/platform-services-go-sdk v0.69.0 // indirect
github.com/IBM/project-go-sdk v0.3.0 // indirect
github.com/IBM/secrets-manager-go-sdk/v2 v2.0.4
github.com/IBM/vpc-go-sdk v0.57.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
Expand Down
2 changes: 2 additions & 0 deletions tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ github.com/IBM/platform-services-go-sdk v0.69.0 h1:SYpLydPWawyhfFxgDTAc5JqWHywkr
github.com/IBM/platform-services-go-sdk v0.69.0/go.mod h1:6rYd3stLSnotYmZlxclw45EJPaQuLmh5f7c+Mg7rOg4=
github.com/IBM/project-go-sdk v0.3.0 h1:lZR4wT6UCsOZ8QkEBITrfM6OZkLlL70/HXiPxF/Olt4=
github.com/IBM/project-go-sdk v0.3.0/go.mod h1:FOJM9ihQV3EEAY6YigcWiTNfVCThtdY8bLC/nhQHFvo=
github.com/IBM/secrets-manager-go-sdk/v2 v2.0.4 h1:xa9e+POVqaXxXHXkSMCOVAbKdUNEu86jQmo5hcpd+L4=
github.com/IBM/secrets-manager-go-sdk/v2 v2.0.4/go.mod h1:5gq8D8uWOIbqOm1uztay6lpOysgJaxxEsaVZLWGWb40=
github.com/IBM/vpc-go-sdk v0.57.0 h1:E8CPDpUE4z0cvvmFZzqUthMtGJx71Fne6vdvkjZdXfg=
github.com/IBM/vpc-go-sdk v0.57.0/go.mod h1:swmxiYLT+OfBsBYqJWGeRd6NPmBk4u/het2PZdtzIaw=
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
Expand Down
80 changes: 63 additions & 17 deletions tests/pr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -26,6 +28,8 @@ const yamlLocation = "../common-dev-assets/common-go-assets/common-permanent-res

var permanentResources map[string]interface{}

var acme_letsencrypt_private_key *string

// Current supported regions (NOTE: eu-es is not being used as we don't have extended trial plan quota in that region currently)
var validRegions = []string{
"us-south",
Expand All @@ -36,6 +40,13 @@ func TestMain(m *testing.M) {
// Read the YAML file contents
var err error
permanentResources, err = common.LoadMapFromYaml(yamlLocation)

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),
)

if err != nil {
log.Fatal(err)
}
Expand All @@ -45,21 +56,28 @@ func TestMain(m *testing.M) {

func TestProjectsFullTest(t *testing.T) {
t.Parallel()

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()
Expand All @@ -70,6 +88,28 @@ 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()

Expand Down Expand Up @@ -115,15 +155,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()
Expand Down