generated from terraform-ibm-modules/stack-ibm-template
    
        
        - 
                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
  
     Closed
                    Changes from 26 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
              
              
                 94742e8
              
                fix: add secret_manager_public_engine_enabled in pr_test
              
              
                 82f8dc1
              
                Merge branch 'main' into 9714-pblc
              
              
                iamar7 ae5d3c2
              
                Merge branch 'main' into 9714-pblc
              
              
                iamar7 a4befc8
              
                fix: fmt issue
              
              
                 849ec6d
              
                Merge branch 'main' into 9714-pblc
              
              
                iamar7 dc5f3a0
              
                fix: added public engine dependency
              
              
                 1f65269
              
                Merge branch 'main' into 9714-pblc
              
              
                iamar7 22c7b66
              
                fix: skip test tear down
              
              
                 0c6829d
              
                Merge branch '9714-pblc' of https://github.com/terraform-ibm-modules/…
              
              
                 8577a4e
              
                fix: update SM plan
              
              
                 5f89b36
              
                resolve pre-commit error
              
              
                 1c97f3e
              
                fix: add existing endpoint
              
              
                 c3373bd
              
                fix: remove skip tear down
              
              
                 e8e97fb
              
                fix: update pr_test
              
              
                 3ea30c8
              
                Merge branch 'main' into 9714-pblc
              
              
                iamar7 886055c
              
                update common-dev-assets
              
              
                 59a7d8a
              
                update branch
              
              
                 19f9c7a
              
                fix: update SM plan
              
              
                 6e5f319
              
                Merge branch 'main' of https://github.com/terraform-ibm-modules/stack…
              
              
                 87724ea
              
                fix: resolve comments
              
              
                 b0d4264
              
                Merge branch 'main' into 9714-pblc
              
              
                iamar7 3c97bff
              
                Merge branch 'main' into 9714-pblc
              
              
                iamar7 c8300aa
              
                fix: resolve comments
              
              
                 9869b55
              
                fix: resolve comments
              
              
                 6d5d310
              
                Merge branch 'main' into 9714-pblc
              
              
                iamar7 0e15f69
              
                fix: update ibm_catalog.json
              
              
                iamar7 fdbfc07
              
                Merge branch 'main' into 9714-pblc
              
              
                iamar7 9b94a00
              
                Merge branch 'main' into 9714-pblc
              
              
                iamar7 04b090d
              
                fix: pre-commit errors
              
              
                 File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | 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" | ||
| 
        
          
        
         | 
    @@ -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 | ||
| var validRegions = []string{ | ||
| "us-south", | ||
| 
        
          
        
         | 
    @@ -37,6 +41,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) | ||
| } | ||
| 
        
          
        
         | 
    @@ -46,21 +57,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() | ||
| 
        
          
        
         | 
    @@ -71,6 +89,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() | ||
| 
     | 
||
| 
          
            
          
           | 
    @@ -116,15 +156,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() | ||
| 
          
            
          
           | 
    ||
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.