Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Conversation

@ocofaigh
Copy link
Contributor

@ocofaigh ocofaigh commented Mar 13, 2025

Description

Migrating the DA from https://github.com/terraform-ibm-modules/terraform-ibm-scc-da into this repo since it no longer creates Workload Protection instance (that is coming in terraform-ibm-modules/terraform-ibm-scc-workload-protection#181).

  • Fully configurable
    • KMS encrypted COS buckets not enforced
  • Security-enforced
    • Wrapper around "Fully configurable" with KMS encryption and private endpoint enforced

Release required?

  • No release
  • Patch release (x.x.X)
  • Minor release (x.X.x)
  • Major release (X.x.x)
Release notes content

Run the pipeline

If the CI pipeline doesn't run when you create the PR, the PR requires a user with GitHub collaborators access to run the pipeline.

Run the CI pipeline when the PR is ready for review and you expect tests to pass. Add a comment to the PR with the following text:

/run pipeline

Checklist for reviewers

  • If relevant, a test for the change is included or updated with this PR.
  • If relevant, documentation for the change is included or updated with this PR.

For mergers

  • Use a conventional commit message to set the release level. Follow the guidelines.
  • Include information that users need to know about the PR in the commit message. The commit message becomes part of the GitHub release notes.
  • Use the Squash and merge option.

@ocofaigh ocofaigh requested a review from toddgiguere as a code owner March 13, 2025 15:58
@ocofaigh ocofaigh marked this pull request as draft March 13, 2025 15:58
@ocofaigh
Copy link
Contributor Author

/run pipeline

@ocofaigh
Copy link
Contributor Author

/run pipeline

@ocofaigh ocofaigh changed the title Add SCC DA (Fully configurable + Security-enforced vairations) Add SCC DA (Fully configurable + Security-enforced variations) Mar 14, 2025
@ocofaigh
Copy link
Contributor Author

/run pipeline

@ocofaigh ocofaigh marked this pull request as ready for review March 14, 2025 12:49
@ocofaigh ocofaigh requested a review from jor2 March 14, 2025 13:17
Comment on lines +73 to +77
// Verify ibmcloud_api_key variable is set
checkVariable := "TF_VAR_ibmcloud_api_key"
val, present := os.LookupEnv(checkVariable)
require.True(t, present, checkVariable+" environment variable not set")
require.NotEqual(t, "", val, checkVariable+" environment variable is empty")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this code is not being used, so can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maheshwarishikha are you talking about line 77? This checks if the TF_VAR_ibmcloud_api_key env var value is set to an empty string, and fails if that is the case

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was talking about line 73-77. Why do we need to check this?
I observed that we use this code if we use region part in tests:

// Verify ibmcloud_api_key variable is set
	checkVariable := "TF_VAR_ibmcloud_api_key"
	val, present := os.LookupEnv(checkVariable)
	require.True(t, present, checkVariable+" environment variable not set")
	require.NotEqual(t, "", val, checkVariable+" environment variable is empty")

	// Programmatically determine region to use based on availability
	region, _ := testhelper.GetBestVpcRegion(val, "../common-dev-assets/common-go-assets/cloudinfo-region-vpc-gen2-prefs.yaml", "eu-de")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 73 - 77 is checking that the TF_VAR_ibmcloud_api_key env var is set as that is needed for the terraform apply to work

It has nothing to do with region selector

@ocofaigh
Copy link
Contributor Author

/run pipeline

@ocofaigh
Copy link
Contributor Author

/run pipeline

},
"configuration": [
{
"key": "ibmcloud_api_key"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the terraform code itself has no default value, you don't need to explicitly mark it as required here

"key": "scc_region",
"required": true,
"options": [
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing au-syd.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kms_service_name = var.existing_kms_instance_crn != null ? module.existing_kms_crn_parser[0].service_name : var.existing_kms_key_crn != null ? module.existing_kms_key_crn_parser[0].service_name : null
kms_account_id = var.existing_kms_instance_crn != null ? module.existing_kms_crn_parser[0].account_id : var.existing_kms_key_crn != null ? module.existing_kms_key_crn_parser[0].account_id : null
kms_key_id = var.existing_kms_instance_crn != null ? module.kms[0].keys[format("%s.%s", local.scc_cos_key_ring_name, local.scc_cos_key_name)].key_id : var.existing_kms_key_crn != null ? module.existing_kms_key_crn_parser[0].resource : null
scc_cos_key_ring_name = try("${local.prefix}-${var.scc_cos_key_ring_name}", var.scc_cos_key_ring_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we still trying to reduce number of try statements? terraform-ibm-modules/terraform-ibm-scc-workload-protection#181 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jor2 good spot - I had just copied the code from SCC DA. This is refactored now

@jor2
Copy link
Member

jor2 commented Mar 18, 2025

Left some small comments, code looks good couldn't find anything else.

@ocofaigh
Copy link
Contributor Author

/run pipeline

@ocofaigh ocofaigh merged commit b8c1634 into main Mar 19, 2025
2 checks passed
@ocofaigh ocofaigh deleted the DA branch March 19, 2025 14:30
@terraform-ibm-modules-ops
Copy link
Contributor

🎉 This PR is included in version 2.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels