Skip to content

Commit f060709

Browse files
authored
feat: initial release (#3)
1 parent 19b0193 commit f060709

File tree

18 files changed

+950
-240
lines changed

18 files changed

+950
-240
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Primary owner should be listed first in list of global owners, followed by any secondary owners
2-
* @ocofaigh @daniel-butler-irl
2+
* @kierramarie @ocofaigh

.github/settings.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ repository:
2222

2323
# Uncomment this description property
2424
# and update the description to the current repo description.
25-
# description: ""
25+
description: "This module supports configuring an IBM Cloud Logs instance, log routing tenants to enable platform logs and cloud logs policies."
2626

2727
# Use a comma-separated list of topics to set on the repo (ensure not to use any caps in the topic string).
2828
topics: terraform, ibm-cloud, terraform-module, core-team, cloud-logs, logging, logs, observability

.secrets.baseline

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2024-11-22T17:36:38Z",
6+
"generated_at": "2025-03-10T19:32:13Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -76,18 +76,7 @@
7676
"name": "TwilioKeyDetector"
7777
}
7878
],
79-
"results": {
80-
"README.md": [
81-
{
82-
"hashed_secret": "ff9ee043d85595eb255c05dfe32ece02a53efbb2",
83-
"is_secret": false,
84-
"is_verified": false,
85-
"line_number": 74,
86-
"type": "Secret Keyword",
87-
"verified_result": null
88-
}
89-
]
90-
},
79+
"results": {},
9180
"version": "0.13.1+ibm.62.dss",
9281
"word_list": {
9382
"file": null,

README.md

Lines changed: 92 additions & 109 deletions
Large diffs are not rendered by default.

examples/advanced/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,10 @@
22

33
<!-- There is a pre-commit hook that will take the title of each example add include it in the repos main README.md -->
44
<!-- Add text below should describe exactly what resources are provisioned / configured by the example -->
5+
6+
Example that configures:
7+
8+
- COS instance and KMS encrypted COS buckets
9+
- Cloud Logs with Event Notifications integration
10+
- Cloud Logs policies
11+
- Key Protect instance and root key

examples/advanced/main.tf

Lines changed: 149 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,163 @@ module "resource_group" {
1010
existing_resource_group_name = var.resource_group
1111
}
1212

13+
##############################################################################
14+
# Key Protect Instance + Key (used to encrypt bucket)
15+
##############################################################################
16+
17+
locals {
18+
key_ring_name = "${var.prefix}-cloud-logs"
19+
key_name = "${var.prefix}-cloud-logs-key"
20+
}
21+
22+
module "key_protect" {
23+
source = "terraform-ibm-modules/kms-all-inclusive/ibm"
24+
version = "4.20.0"
25+
resource_group_id = module.resource_group.resource_group_id
26+
region = var.region
27+
resource_tags = var.resource_tags
28+
keys = [
29+
{
30+
key_ring_name = local.key_ring_name
31+
keys = [
32+
{
33+
key_name = local.key_name
34+
}
35+
]
36+
}
37+
]
38+
key_protect_instance_name = "${var.prefix}-kp"
39+
}
40+
41+
##############################################################################
42+
# Event Notification
43+
##############################################################################
44+
45+
module "event_notification_1" {
46+
source = "terraform-ibm-modules/event-notifications/ibm"
47+
version = "1.18.8"
48+
resource_group_id = module.resource_group.resource_group_id
49+
name = "${var.prefix}-en-1"
50+
tags = var.resource_tags
51+
plan = "standard"
52+
service_endpoints = "public"
53+
region = var.region
54+
}
55+
56+
module "event_notification_2" {
57+
source = "terraform-ibm-modules/event-notifications/ibm"
58+
version = "1.18.8"
59+
resource_group_id = module.resource_group.resource_group_id
60+
name = "${var.prefix}-en-2"
61+
tags = var.resource_tags
62+
plan = "standard"
63+
service_endpoints = "public"
64+
region = var.region
65+
}
66+
67+
##############################################################################
68+
# COS instance + buckets
69+
##############################################################################
70+
71+
module "cos" {
72+
source = "terraform-ibm-modules/cos/ibm"
73+
version = "8.19.5"
74+
resource_group_id = module.resource_group.resource_group_id
75+
cos_instance_name = "${var.prefix}-cos"
76+
cos_tags = var.resource_tags
77+
create_cos_bucket = false
78+
}
79+
80+
locals {
81+
logs_bucket_name = "${var.prefix}-logs-data"
82+
metrics_bucket_name = "${var.prefix}-metrics-data"
83+
}
84+
85+
module "buckets" {
86+
source = "terraform-ibm-modules/cos/ibm//modules/buckets"
87+
version = "8.19.5"
88+
bucket_configs = [
89+
{
90+
bucket_name = local.logs_bucket_name
91+
kms_encryption_enabled = true
92+
region_location = var.region
93+
resource_instance_id = module.cos.cos_instance_id
94+
kms_guid = module.key_protect.kms_guid
95+
kms_key_crn = module.key_protect.keys["${local.key_ring_name}.${local.key_name}"].crn
96+
skip_iam_authorization_policy = false
97+
},
98+
{
99+
bucket_name = local.metrics_bucket_name
100+
kms_encryption_enabled = true
101+
region_location = var.region
102+
resource_instance_id = module.cos.cos_instance_id
103+
kms_guid = module.key_protect.kms_guid
104+
kms_key_crn = module.key_protect.keys["${local.key_ring_name}.${local.key_name}"].crn
105+
skip_iam_authorization_policy = true # Auth policy created in first bucket
106+
}
107+
]
108+
}
109+
13110
########################################################################################################################
14-
# COS
111+
# Cloud Logs
15112
########################################################################################################################
16113

17114
#
18115
# Developer tips:
19116
# - Call the local module / modules in the example to show how they can be consumed
20-
# - Include the actual module source as a code comment like below so consumers know how to consume from correct location
117+
# - include the actual module source as a code comment like below so consumers know how to consume from correct location
21118
#
22119

23-
module "cos" {
24-
source = "../.."
25-
# remove the above line and uncomment the below 2 lines to consume the module from the registry
26-
# source = "terraform-ibm-modules/<replace>/ibm"
27-
# version = "X.Y.Z" # Replace "X.Y.Z" with a release version to lock into a specific release
28-
name = "${var.prefix}-cos"
120+
locals {
121+
cloud_logs_instance_name = "${var.prefix}-cloud-logs"
122+
}
123+
124+
module "cloud_logs" {
125+
source = "../../"
126+
# delete line above and use below syntax to pull module source from hashicorp when consuming this module
127+
# source = "terraform-ibm-modules/cloud-logs/ibm"
128+
# version = "X.Y.Z" # Replace "X.X.X" with a release version to lock into a specific release
29129
resource_group_id = module.resource_group.resource_group_id
130+
region = var.region
131+
instance_name = local.cloud_logs_instance_name
30132
resource_tags = var.resource_tags
31-
plan = "cos-one-rate-plan"
133+
access_tags = var.access_tags
134+
data_storage = {
135+
# logs and metrics buckets must be different
136+
logs_data = {
137+
enabled = true
138+
bucket_crn = module.buckets.buckets[local.logs_bucket_name].bucket_crn
139+
bucket_endpoint = module.buckets.buckets[local.logs_bucket_name].s3_endpoint_direct
140+
},
141+
metrics_data = {
142+
enabled = true
143+
bucket_crn = module.buckets.buckets[local.metrics_bucket_name].bucket_crn
144+
bucket_endpoint = module.buckets.buckets[local.metrics_bucket_name].s3_endpoint_direct
145+
}
146+
}
147+
policies = [{
148+
logs_policy_name = "${var.prefix}-logs-policy-1"
149+
logs_policy_priority = "type_low"
150+
application_rule = [{
151+
name = "test-system-app"
152+
rule_type_id = "start_with"
153+
}]
154+
log_rules = [{
155+
severities = ["info", "debug"]
156+
}]
157+
subsystem_rule = [{
158+
name = "test-sub-system"
159+
rule_type_id = "start_with"
160+
}]
161+
}]
162+
existing_event_notifications_instances = [{
163+
en_instance_id = module.event_notification_1.guid
164+
en_region = var.region
165+
en_integration_name = "${var.prefix}-en-1"
166+
},
167+
{
168+
en_instance_id = module.event_notification_2.guid
169+
en_region = var.region
170+
en_integration_name = "${var.prefix}-en-2"
171+
}]
32172
}

examples/advanced/outputs.tf

Lines changed: 53 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,67 @@
77
# - Include all relevant outputs from the modules being called in the example
88
#
99

10-
output "account_id" {
11-
description = "An alpha-numeric value identifying the account ID."
12-
value = module.cos.account_id
10+
output "cloud_logs_crn" {
11+
value = module.cloud_logs.crn
12+
description = "The id of the provisioned Cloud Logs instance."
1313
}
1414

15-
output "guid" {
16-
description = "The GUID of the resource instance."
17-
value = module.cos.account_id
15+
output "cloud_logs_guid" {
16+
value = module.cloud_logs.guid
17+
description = "The guid of the provisioned Cloud Logs instance."
1818
}
1919

20-
output "id" {
21-
description = "The unique identifier of the resource instance."
22-
value = module.cos.id
20+
output "cloud_logs_name" {
21+
value = module.cloud_logs.name
22+
description = "The name of the provisioned Cloud Logs instance."
2323
}
2424

25-
output "crn" {
26-
description = "The CRN of the resource instance."
27-
value = module.cos.crn
25+
output "resource_group_id" {
26+
value = module.cloud_logs.resource_group_id
27+
description = "The resource group where Cloud Logs instance resides."
2828
}
2929

30-
output "resource_group_name" {
31-
description = "Resource group name."
32-
value = module.resource_group.resource_group_name
30+
output "cloud_logs_ingress_endpoint" {
31+
value = module.cloud_logs.ingress_endpoint
32+
description = "The public ingress endpoint of the provisioned Cloud Logs instance."
3333
}
3434

35-
output "resource_group_id" {
36-
description = "Resource group ID."
37-
value = module.resource_group.resource_group_id
35+
output "cloud_logs_ingress_private_endpoint" {
36+
value = module.cloud_logs.ingress_private_endpoint
37+
description = "The private ingress endpoint of the provisioned Cloud Logs instance."
38+
}
39+
40+
output "cos_crn" {
41+
value = module.cos.cos_instance_id
42+
description = "The id of the provisioned Cloud Object Storage instance."
43+
}
44+
45+
output "logs_bucket_crn" {
46+
value = module.buckets.buckets[local.logs_bucket_name].bucket_crn
47+
description = "The id of the provisioned Cloud Object Storage bucket for logs."
48+
}
49+
50+
output "logs_bucket_name" {
51+
value = local.logs_bucket_name
52+
description = "The name of the provisioned Cloud Object Storage bucket for logs."
53+
}
54+
55+
output "metrics_bucket_crn" {
56+
value = module.buckets.buckets[local.metrics_bucket_name].bucket_crn
57+
description = "The id of the provisioned Cloud Object Storage bucket for metrics."
58+
}
59+
60+
output "metrics_bucket_name" {
61+
value = local.metrics_bucket_name
62+
description = "The name of the provisioned Cloud Object Storage bucket for metrics."
63+
}
64+
65+
output "event_notification_1_crn" {
66+
value = module.event_notification_1.crn
67+
description = "The id of the provisioned Event Notifications 1 instance."
68+
}
69+
70+
output "event_notification_2_crn" {
71+
value = module.event_notification_2.crn
72+
description = "The id of the provisioned Event Notifications 2 instance."
3873
}

examples/advanced/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,9 @@ variable "resource_tags" {
3737
description = "List of resource tag to associate with all resource instances created by this example."
3838
default = []
3939
}
40+
41+
variable "access_tags" {
42+
type = list(string)
43+
description = "Optional list of access management tags to add to resources that are created."
44+
default = []
45+
}

examples/basic/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ The text below should describe exactly what resources are provisioned / configur
88

99
An end-to-end basic example that will provision the following:
1010
- A new resource group if one is not passed in.
11-
- A new standard plan Cloud Object Storage instance using the root level module.
11+
- A new standard plan Cloud Object Storage instance.
12+
- Two Cloud Object Storage buckets.
13+
- A Cloud Logs instance using root module, attached to provisioned Cloud Object Storage buckets.

0 commit comments

Comments
 (0)