Skip to content

Event Notification DA Fully configurable #395

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Conversation

whoffler
Copy link
Contributor

@whoffler whoffler commented Mar 4, 2025

Description

for issue - https://github.ibm.com/GoldenEye/issues/issues/12573

Event Notification DA Fully configurable flavor

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.

@whoffler whoffler force-pushed the flexibleVariation branch 4 times, most recently from fd9cef1 to 5c55830 Compare March 5, 2025 11:57
@ocofaigh
Copy link
Member

ocofaigh commented Mar 11, 2025

@whoffler Vipin has a PR open to update the current standard variation with some best practises. Since that variation is going away, can I suggest we just make the changes directly in this PR in the new variation you are adding?

@whoffler whoffler changed the title Event Notification DA Fully configurable - Work In Progress Event Notification DA Fully configurable Mar 13, 2025
Copy link
Member

@ocofaigh ocofaigh left a comment

Choose a reason for hiding this comment

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

Left an initial first round of comments to address - there will be more. Also we need to claify if we really should be using cloud_object_storage and key_management_service in our input names, as opposed to just cos and kms. Discussion started on slack

@@ -0,0 +1,14 @@
terraform {
required_version = ">= 1.3.0"
Copy link
Member

Choose a reason for hiding this comment

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

I suggest you update to >= 1.9.0 so we can use the terraform 1.9 cross variable validation feature.
We will need to use it in many input variables in variables.tf. For an idea of how to use it, see my branch (WIP): https://github.com/terraform-ibm-modules/terraform-ibm-scc/blob/DA/solutions/fully-configurable/variables.tf

@whoffler whoffler force-pushed the flexibleVariation branch 2 times, most recently from abeb33c to dcf9464 Compare March 20, 2025 09:08
@whoffler whoffler requested a review from ocofaigh March 20, 2025 09:25
@whoffler whoffler force-pushed the flexibleVariation branch from 29995b7 to 8d7f1f9 Compare March 20, 2025 11:04
Copy link
Member

@ocofaigh ocofaigh left a comment

Choose a reason for hiding this comment

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

@whoffler still a lot of things to address here. Its not consistent at all with the SCC DA. Please review your variable descriptions, variable validation and other logic to ensure consistency. Some other things that stand out:

}
}

variable "existing_kms_key_name" {
Copy link
Member

Choose a reason for hiding this comment

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

We will never need a existing KMS key name?? The user will either pass the key using existing_kms_root_key_crn, or we will create the key using existing_kms_instance_crn so I'm confused as to what this is for?

Copy link
Member

Choose a reason for hiding this comment

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

We might need 2 existing KMS key inputs - one for the COS bucket, and one for the Event Notifications instance

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah if a KMS key is provided to the fscloud version it uses it for everything. Adding another KMS key input makes sense.. more configurable

Copy link
Member

@ocofaigh ocofaigh left a comment

Choose a reason for hiding this comment

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

@whoffler Also take a look at terraform-ibm-modules/terraform-ibm-secrets-manager#309 - we will need something similar in this PR

@whoffler
Copy link
Contributor Author

@ocofaigh

was going to do that in a separate PR but will add here instead

@ocofaigh
Copy link
Member

@whoffler A separate Pr is fine if you want - but just remove the security-enforced code from this PR then

@whoffler whoffler force-pushed the flexibleVariation branch 2 times, most recently from 71ea249 to b3f69cf Compare March 27, 2025 10:42
@rajatagarwal-ibm rajatagarwal-ibm marked this pull request as ready for review April 11, 2025 16:19
@rajatagarwal-ibm
Copy link
Member

/run pipeline

4 similar comments
@rajatagarwal-ibm
Copy link
Member

/run pipeline

@rajatagarwal-ibm
Copy link
Member

/run pipeline

@rajatagarwal-ibm
Copy link
Member

/run pipeline

@rajatagarwal-ibm
Copy link
Member

/run pipeline

@rajatagarwal-ibm
Copy link
Member

@ocofaigh working with @whoffler on this, and will try to get that done as soo as we can. Thanks!

@whoffler
Copy link
Contributor Author

whoffler commented Apr 26, 2025

@rajatagarwal-ibm @ocofaigh think I've figured out why that unit test is failing.

For COS bucket when we set kms_encryption_enabled to true then the cos bucket module creates a policy:

# Create IAM Authorization Policy to allow COS to access KMS for the encryption key
resource "ibm_iam_authorization_policy" "policy" {

The existing standard solution does not pass kms_encryption_enabled variable to cos module

In Event Notifications we create policy:

# Create cross account IAM Authorization Policy to allow COS to read the KMS encryption key
resource "ibm_iam_authorization_policy" "cos_kms_policy" {

Which creates the access policy conflict we are seeing.

Removing kms_encryption_enabled and the test passes for me. Maybe we remove the access policy altogether from Event Notifications and let COS module do its thing?

whoffler and others added 11 commits April 28, 2025 16:24
SKIP UPGRADE TEST: breaking changes
SKIP UPGRADE TEST: breaking changes
SKIP UPGRADE TEST: breaking changes
SKIP UPGRADE TEST: breaking changes
SKIP UPGRADE TEST: breaking changes
SKIP UPGRADE TEST: breaking changes
SKIP UPGRADE TEST: breaking changes
SKIP UPGRADE TEST: breaking changes
@whoffler
Copy link
Contributor Author

/run pipeline

@whoffler whoffler force-pushed the flexibleVariation branch from 782ce09 to 4898435 Compare April 28, 2025 15:47
@whoffler
Copy link
Contributor Author

/run pipeline

@whoffler
Copy link
Contributor Author

/run pipeline

4 similar comments
@whoffler
Copy link
Contributor Author

/run pipeline

@whoffler
Copy link
Contributor Author

/run pipeline

@whoffler
Copy link
Contributor Author

/run pipeline

@rajatagarwal-ibm
Copy link
Member

/run pipeline

@@ -1,12 +1,14 @@
# More info about this file at https://github.com/terraform-ibm-modules/common-pipeline-assets/blob/main/.github/workflows/terraform-test-pipeline.md#cra-config-yaml
version: "v1"
CRA_TARGETS:
- CRA_TARGET: "solutions/standard" # Target directory for CRA scan. If not provided, the CRA Scan will not be run.
- CRA_TARGET: "solutions/fully-configurable" # Target directory for CRA scan. If not provided, the CRA Scan will not be run.
CRA_IGNORE_RULES_FILE: "cra-tf-validate-ignore-rules.json" # CRA Ignore file to use. If not provided, it checks the repo root directory for `cra-tf-validate-ignore-rules.json`
PROFILE_ID: "fe96bd4d-9b37-40f2-b39f-a62760e326a3" # SCC profile ID (currently set to 'IBM Cloud Framework for Financial Services' '1.7.0' profile).
CRA_ENVIRONMENT_VARIABLES:
Copy link
Contributor

Choose a reason for hiding this comment

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

should TF_VAR_kms_encryption_enabled: true be added as well?

Copy link
Member

Choose a reason for hiding this comment

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

No, it is not required as the fully-configurable does not enforce KMS encryption.

},
{
"key": "resource_group_name"
"key": "existing_resource_group_name"
Copy link
Contributor

Choose a reason for hiding this comment

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

picker should be used

{
              "key": "existing_resource_group_name",
              "required": true,
              "custom_config": {
                  "type": "resource_group",
                  "grouping": "deployment",
                  "original_grouping": "deployment",
                  "config_constraints": {
                      "identifier": "rg_name"
                  }
              }
            },

@@ -169,10 +357,27 @@
]
},
{
"key": "en_key_ring_name"
"key": "provider_visibility",
Copy link
Contributor

Choose a reason for hiding this comment

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

should be hidden.

"hidden": true

Copy link
Member

Choose a reason for hiding this comment

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

Not sure yet if we are going to hide this - it will be discussed in todays deep dive

Copy link
Member

@ocofaigh ocofaigh left a comment

Choose a reason for hiding this comment

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

Please do a full re-review of the code for consistency between the 2 variations, and between other DAs (for example SCC DA)

variable "kms_encryption_enabled" {
type = bool
description = "Set to true to enable KMS encryption on Event Notifications instance and Cloud Object Storage bucket. When set to true 'kms_endpoint_url' and one of 'existing_kms_instance_crn' or 'existing_kms_root_key_crn' must be set."
default = true
Copy link
Member

Choose a reason for hiding this comment

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

This should not default to true in fully configurable because the user is then required to pass either a KMS instance CRN, or a KMS key. We want fully configurable to be like a one click deploy. This is consistent with all our other fully configurable DAs

variable "enable_collecting_failed_events" {
type = bool
description = "Set to true to enable Cloud Object Storage integration."
default = true
Copy link
Member

Choose a reason for hiding this comment

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

Same as above, I don't think this should be true by default in fully configurable, since it will have a dependency on COS

type = bool
description = "Whether to add a randomly generated 4-character suffix to the newly provisioned Object Storage bucket name. Used only if not using an existing bucket. Set to `false` if you want full control over bucket naming by using the `cos_bucket_name` variable."
description = "Set to true to enable key management service encryption on Cloud Object Storage bucket."
default = true
Copy link
Member

Choose a reason for hiding this comment

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

same as above, this should not default to true for fully configurable

variable "cos_bucket_region" {
type = string
description = "The COS bucket region. If `cos_bucket_region` is set to null, then `region` will be used."
default = "us-south"
Copy link
Member

Choose a reason for hiding this comment

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

Can we take same approach as SCC DA where default value will be null (meaning it will be provisioned in same region as the EN instance). See https://github.com/terraform-ibm-modules/terraform-ibm-scc/blob/6fbd4973c72855920c157848ab9eee0b7cce5439/solutions/fully-configurable/variables.tf#L301-L305

When `existing_en_instance_crn` is not passed, this solution configures the following infrastructure:

- optionally a KMS key ring and key for IBM Event Notifications encryption
- optionally a KMS key ring and key for IBM Cloud Object Storage encryption
Copy link
Member

Choose a reason for hiding this comment

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

KMS is mandated in security enforced. So I would not use the word "optionally" here. The options are the DA either creates the key and key ring, or the DA takes in existing key

variable "existing_cos_instance_crn" {
type = string
nullable = false
description = "The CRN of an IBM Cloud Object Storage instance."
Copy link
Member

Choose a reason for hiding this comment

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

Description should say what its used for


variable "kms_endpoint_url" {
type = string
description = "The KMS endpoint URL to use when you configure KMS encryption. The Hyper Protect Crypto Services endpoint URL format is `https://api.private.<REGION>.hs-crypto.cloud.ibm.com:<port>` and the Key Protect endpoint URL format is `https://<REGION>.kms.cloud.ibm.com`. Not required if passing an existing instance using the `existing_en_instance_crn` input."
Copy link
Member

Choose a reason for hiding this comment

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

existing_en_instance_crn is not a valid input. Do we have variable validation checking the condition mentioned?

type = string
description = "The key CRN of a root key, existing in the KMS instance passed in the `existing_kms_instance_crn` input, which will be used to encrypt the data. If no value passed, a new key will be created in the instance provided in the `existing_kms_instance_crn` input."
default = null
}
Copy link
Member

Choose a reason for hiding this comment

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

variable "event_notifications_name" {
type = string
description = "The name of the Event Notifications instance that is created by this solution. If a `prefix` input variable is specified, it is added to this name in the `<prefix>-value` format."
default = "base-event-notifications"
Copy link
Member

Choose a reason for hiding this comment

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

This does not match the value in fully configurable. Can you please do a full review to ensure consistency


variable "prefix" {
type = string
description = "(Optional) 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."
Copy link
Member

Choose a reason for hiding this comment

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

why is this description different to the fully configurable one? Please ensure consistency

@@ -0,0 +1,82 @@
# Event Notifications solution
Copy link
Contributor

Choose a reason for hiding this comment

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

security-enforced should be added to the title

@@ -0,0 +1,109 @@
# Cloud automation for Event Notifications (Fully configurable)
Copy link
Contributor

Choose a reason for hiding this comment

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

to be in consistent with other DAs, let's follow the structure by defining Prerequisites as well . Same for security-enforced DA

https://github.com/terraform-ibm-modules/terraform-ibm-scc/blob/main/solutions/fully-configurable/README.md#prerequisites

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants