Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
3 changes: 1 addition & 2 deletions cra-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@

version: "v1"
CRA_TARGETS:
- CRA_TARGET: "examples/advanced" # 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"
PROFILE_ID: "fe96bd4d-9b37-40f2-b39f-a62760e326a3" # SCC profile ID (currently set to 'IBM Cloud Framework for Financial Services' '1.7.0' profile).
# SCC_INSTANCE_ID: "" # The SCC instance ID to use to download profile for CRA scan. If not provided, a default global value will be used.
# SCC_REGION: "" # The IBM Cloud region that the SCC instance is in. If not provided, a default global value will be used.
CRA_ENVIRONMENT_VARIABLES: # An optional map of environment variables for CRA, where the key is the variable name and value is the value. Useful for providing TF_VARs.
TF_VAR_prefix: "monitoring"
TF_VAR_region: "us-south"
8 changes: 5 additions & 3 deletions examples/advanced/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Example that configures:

- IBM Cloud Monitoring instance
- IBM Cloud Metrics Routing
- A context-based restriction (CBR) rule to only allow cloud monitoring to be accessible from schematics
- A new resource group if one is not passed in.
- A context-based restriction (CBR) zone for the IBM Cloud Schematics service.
- An IBM Cloud Monitoring instance.
- A context-based restriction (CBR) rule to only allow the Cloud Monitoring to be accessible from the Schematics zone.
- A Metrics Routing target for the new IBM Cloud Monitoring instance and a route to route send metrics to it.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- A Metrics Routing target for the new IBM Cloud Monitoring instance and a route to route send metrics to it.
- A Metrics Routing target for the new IBM Cloud Monitoring instance and a route to send metrics to it.

40 changes: 20 additions & 20 deletions examples/advanced/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ module "resource_group" {
existing_resource_group_name = var.resource_group
}

##############################################################################
# CBR zone
##############################################################################

module "cbr_schematics_zone" {
source = "terraform-ibm-modules/cbr/ibm//modules/cbr-zone-module"
version = "1.33.2"
name = "${var.prefix}-schematics-network-zone"
zone_description = "CBR Network zone containing Schematics"
account_id = module.cloud_monitoring.account_id
addresses = [{
type = "serviceRef"
ref = {
account_id = module.cloud_monitoring.account_id
service_name = "schematics"
}
}]
}

##############################################################################
# Cloud Monitoring
##############################################################################
Expand All @@ -28,7 +47,7 @@ module "cloud_monitoring" {
plan = "graduated-tier"
instance_name = local.cloud_monitoring_instance_name
cbr_rules = [{
description = "${var.prefix}-cloud-monitoring access from vpc and schematics"
description = "${var.prefix}-cloud-monitoring access from schematics zone"
account_id = module.cloud_monitoring.account_id
enforcement_mode = "report"
rule_contexts = [{
Expand All @@ -46,25 +65,6 @@ module "cloud_monitoring" {
}]
}

##############################################################################
# CBR
##############################################################################

module "cbr_schematics_zone" {
source = "terraform-ibm-modules/cbr/ibm//modules/cbr-zone-module"
version = "1.33.2"
name = "${var.prefix}-schematics-network-zone"
zone_description = "CBR Network zone containing Schematics"
account_id = module.cloud_monitoring.account_id
addresses = [{
type = "serviceRef"
ref = {
account_id = module.cloud_monitoring.account_id
service_name = "schematics"
}
}]
}

##############################################################################
# IBM Cloud Metrics Routing
# - Cloud Monitoring target
Expand Down
6 changes: 1 addition & 5 deletions examples/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@ module "resource_group" {
# Cloud Monitoring
##############################################################################

locals {
cloud_monitoring_instance_name = "${var.prefix}-cloud-monitoring"
}

module "cloud_monitoring" {
source = "../../"
resource_group_id = module.resource_group.resource_group_id
region = var.region
resource_tags = var.resource_tags
instance_name = local.cloud_monitoring_instance_name
instance_name = "${var.prefix}-cloud-monitoring"
plan = "graduated-tier"
}
2 changes: 1 addition & 1 deletion ibm_catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
"name": "deploy-arch-ibm-account-infra-base",
"description": "Organize your IBM Cloud account with preconfigured resource groups. If not selected, the default resource group is used. Optionally, expand to apply recommended security controls via \"with Account Settings\" variation.",
"id": "63641cec-6093-4b4f-b7b0-98d2f4185cd6-global",
"version": "v3.0.7",
"version": "v3.0.23",
"flavors": [
"resource-group-only",
"resource-groups-with-account-settings"
Expand Down
20 changes: 8 additions & 12 deletions tests/other_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,58 +14,54 @@ import (
const advancedExampleDir = "examples/advanced"
const basicExampleDir = "examples/basic"

func setupOptions(t *testing.T, prefix string, dir string) *testhelper.TestOptions {
func setupExamplesOptions(t *testing.T, prefix string, dir string) *testhelper.TestOptions {
options := testhelper.TestOptionsDefaultWithVars(&testhelper.TestOptions{
Testing: t,
TerraformDir: dir,
Prefix: prefix,
ResourceGroup: resourceGroup,
Region: validRegions[rand.Intn(len(validRegions))],
IgnoreUpdates: testhelper.Exemptions{ // Ignore for consistency check
List: IgnoreUpdates,
},
})

return options
}

// Consistency test for the basic example
func TestRunBasicExample(t *testing.T) {
t.Parallel()

options := setupOptions(t, "icm-basic", basicExampleDir)
options := setupExamplesOptions(t, "icm-basic", basicExampleDir)

output, err := options.RunTestConsistency()
assert.Nil(t, err, "This should not have errored")
assert.NotNil(t, output, "Expected some output")
}

// Consistency test for the advanced example
// NOTE: It is run in Schematics because the example configures a CBR rule to only allow traffic from schematics zone
func TestRunAdvancedExampleInSchematics(t *testing.T) {
t.Parallel()

var region = validRegions[rand.Intn(len(validRegions))]

options := testschematic.TestSchematicOptionsDefault(&testschematic.TestSchematicOptions{
Testing: t,
Prefix: "icm-adv",
Region: validRegions[rand.Intn(len(validRegions))],
TarIncludePatterns: []string{
"*.tf",
"modules/metrics_routing" + "/*.tf",
advancedExampleDir + "/*.tf",
},
ResourceGroup: resourceGroup,
TemplateFolder: advancedExampleDir,
Tags: []string{"test-schematic"},
Tags: tags,
DeleteWorkspaceOnFail: false,
WaitJobCompleteMinutes: 60,
IgnoreUpdates: testhelper.Exemptions{ // Ignore for consistency check
List: IgnoreUpdates,
},
})

options.TerraformVars = []testschematic.TestSchematicTerraformVar{
{Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true},
{Name: "prefix", Value: options.Prefix, DataType: "string"},
{Name: "region", Value: region, DataType: "string"},
{Name: "region", Value: options.Region, DataType: "string"},
}

err := options.RunSchematicTest()
Expand Down
Loading