Skip to content

Commit 8349d2a

Browse files
authored
feat: initial release
1 parent c44926f commit 8349d2a

38 files changed

+999
-326
lines changed

.github/settings.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ repository:
1515
# By changing this field, you rename the repository.
1616

1717
# Uncomment this name property and set the name to the current repo name.
18-
# name: ""
18+
name: "terraform-ibm-event-streams"
1919

2020
# The description is displayed under the repository name on the
2121
# organization page and in the 'About' section of the repository.
2222

2323
# Uncomment this description property
2424
# and update the description to the current repo description.
25-
# description: ""
25+
description: "Implements an event streams instance with topics and schema."

.github/workflows/ci.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
branches: [main]
88
pull_request:
99
branches: [main]
10+
types: [opened, synchronize, reopened, ready_for_review]
1011

1112
# Allows you to run this workflow manually from the Actions tab
1213
workflow_dispatch:
@@ -16,5 +17,7 @@ jobs:
1617
uses: terraform-ibm-modules/common-pipeline-assets/.github/workflows/[email protected]
1718
secrets: inherit
1819
with:
19-
craTarget: "examples/default"
20-
craGoalIgnoreFile: "cra-tf-validate-ignore-goals.json"
20+
craSCCv2: true
21+
craTarget: "examples/complete"
22+
craRuleIgnoreFile: "cra-tf-validate-ignore-rules.json"
23+
craEnvironmentVariables: "TF_VAR_existing_at_instance_crn=${{ vars.AT_INSTANCE_CRN }}"

.gitmodules

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
[submodule "common-dev-assets"]
22
path = common-dev-assets
3-
url = https://github.com/terraform-ibm-modules/common-dev-assets
4-
branch = main
3+
url = https://github.com/terraform-ibm-modules/common-dev-assets.git

.secrets.baseline

+1-13
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,14 @@
33
"files": "go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2023-05-05T07:42:59Z",
6+
"generated_at": "2023-05-05T09:58:47Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
1010
},
1111
{
1212
"name": "ArtifactoryDetector"
1313
},
14-
{
15-
"name": "AzureStorageKeyDetector"
16-
},
1714
{
1815
"base64_limit": 4.5,
1916
"name": "Base64HighEntropyString"
@@ -31,9 +28,6 @@
3128
"ghe_instance": "github.ibm.com",
3229
"name": "GheDetector"
3330
},
34-
{
35-
"name": "GitHubTokenDetector"
36-
},
3731
{
3832
"hex_limit": 3,
3933
"name": "HexHighEntropyString"
@@ -54,9 +48,6 @@
5448
{
5549
"name": "MailchimpDetector"
5650
},
57-
{
58-
"name": "NpmDetector"
59-
},
6051
{
6152
"name": "PrivateKeyDetector"
6253
},
@@ -66,9 +57,6 @@
6657
{
6758
"name": "SoftlayerDetector"
6859
},
69-
{
70-
"name": "SquareOAuthDetector"
71-
},
7260
{
7361
"name": "StripeDetector"
7462
},

README.md

+131-115
Large diffs are not rendered by default.

cra-tf-validate-ignore-goals.json

-3
This file was deleted.

cra-tf-validate-ignore-rules.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"scc_rules": [
3+
{
4+
"scc_rule_id": "rule-3b2768e5-d783-4b0c-a47f-81479af34689",
5+
"description": " Check whether Event Streams is accessible only by using private endpoints Found in: resource_address: module.event_streams.ibm_resource_instance.es_instance",
6+
"ignore_reason": "Private endpoint option is not available in Standard plan which the complete example uses. When we create an FSCloud profile example for this module, the CRA scan will be done against that, and that should use private endpoint only. (Tracked at https://github.com/terraform-ibm-modules/terraform-ibm-event-streams/issues/5)",
7+
"is_valid": true
8+
}
9+
]
10+
}

examples/complete/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Complete example with key protect
2+
3+
An end-to-end example that creates an event streams instance with key protect.
4+
This example uses the IBM Cloud terraform provider to:
5+
- Create a new resource group if one is not passed in.
6+
- Create a new event streams instance with topics and schemas provided, and a new key protect instance in the resource group and region provided.
7+
8+
<!-- Add your example and link to it from the module's main readme file. -->

examples/complete/main.tf

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
##############################################################################
2+
# Resource Group
3+
##############################################################################
4+
5+
module "resource_group" {
6+
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-resource-group.git?ref=v1.0.5"
7+
# if an existing resource group is not set (null) create a new one using prefix
8+
resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null
9+
existing_resource_group_name = var.resource_group
10+
}
11+
12+
##############################################################################
13+
# Key Protect All Inclusive
14+
##############################################################################
15+
16+
module "key_protect_all_inclusive" {
17+
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-key-protect-all-inclusive.git?ref=v4.0.0"
18+
key_protect_instance_name = "${var.prefix}-kp"
19+
resource_group_id = module.resource_group.resource_group_id
20+
region = var.region
21+
resource_tags = var.resource_tags
22+
key_map = { "es" = ["${var.prefix}-es"] }
23+
enable_metrics = false
24+
}
25+
26+
##############################################################################
27+
# Events-streams-instance
28+
##############################################################################
29+
30+
module "event_streams" {
31+
source = "../../"
32+
resource_group_id = module.resource_group.resource_group_id
33+
es_name = "${var.prefix}-es"
34+
plan = var.plan
35+
kms_key_crn = module.key_protect_all_inclusive.keys["es.${var.prefix}-es"].crn
36+
existing_kms_instance_guid = module.key_protect_all_inclusive.key_protect_guid
37+
schemas = var.schemas
38+
tags = var.resource_tags
39+
topics = var.topics
40+
service_endpoints = var.service_endpoints
41+
}

examples/complete/outputs.tf

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
##############################################################################
2+
# Outputs
3+
##############################################################################
4+
5+
output "resource_group_name" {
6+
description = "Resource group name"
7+
value = module.resource_group.resource_group_name
8+
}
9+
10+
output "resource_group_id" {
11+
description = "Resource group ID"
12+
value = module.resource_group.resource_group_id
13+
}
14+
15+
output "crn" {
16+
description = "Event Streams instance crn"
17+
value = module.event_streams.crn
18+
}
19+
20+
output "guid" {
21+
description = "Event Streams instance guid"
22+
value = module.event_streams.guid
23+
}
24+
25+
output "kafka_brokers_sasl" {
26+
description = "(Array of Strings) Kafka brokers use for interacting with Kafka native API"
27+
value = module.event_streams.kafka_brokers_sasl
28+
}
29+
30+
output "kafka_http_url" {
31+
description = "The API endpoint to interact with Event Streams REST API"
32+
value = module.event_streams.kafka_http_url
33+
}
File renamed without changes.

examples/complete/variables.tf

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
variable "ibmcloud_api_key" {
2+
type = string
3+
description = "The IBM Cloud API Key"
4+
sensitive = true
5+
}
6+
7+
variable "region" {
8+
type = string
9+
description = "Region to provision all resources created by this example"
10+
default = "us-south"
11+
}
12+
13+
variable "plan" {
14+
type = string
15+
description = "Plan for the event stream instance. lite, standard or enterprise-3nodes-2tb"
16+
default = "standard"
17+
}
18+
19+
variable "prefix" {
20+
type = string
21+
description = "Prefix to append to all resources created by this example"
22+
default = "event_streams"
23+
}
24+
25+
variable "resource_group" {
26+
type = string
27+
description = "An existing resource group name to use for this example, if unset a new resource group will be created"
28+
default = null
29+
}
30+
31+
variable "resource_tags" {
32+
type = list(string)
33+
description = "List of tags associated with the Event Steams instance"
34+
default = []
35+
}
36+
37+
variable "service_endpoints" {
38+
type = string
39+
description = "The type of service endpoint(public,private or public-and-private) to be used for connection. Default is public for Standard and lite plans"
40+
default = "public"
41+
}
42+
43+
variable "schemas" {
44+
type = list(object(
45+
{
46+
schema_id = string
47+
schema = object({
48+
type = string
49+
name = string
50+
})
51+
}
52+
))
53+
description = "The list of schema object which contains schema id and format of the schema"
54+
default = [{
55+
schema_id = "my-es-schema_1"
56+
schema = {
57+
type = "string"
58+
name = "name_1"
59+
}
60+
},
61+
{
62+
schema_id = "my-es-schema_2"
63+
schema = {
64+
type = "string"
65+
name = "name_2"
66+
}
67+
},
68+
{
69+
schema_id = "my-es-schema_3"
70+
schema = {
71+
type = "string"
72+
name = "name_3"
73+
}
74+
}
75+
]
76+
}
77+
78+
variable "topics" {
79+
type = list(object(
80+
{
81+
name = string
82+
partitions = number
83+
config = object({})
84+
}
85+
))
86+
description = "List of topics. For lite plan only one topic is allowed."
87+
default = [
88+
{
89+
name = "topic-1"
90+
partitions = 1
91+
config = {
92+
"cleanup.policy" = "delete"
93+
"retention.ms" = "86400000"
94+
"retention.bytes" = "10485760"
95+
"segment.bytes" = "10485760"
96+
}
97+
},
98+
{
99+
name = "topic-2"
100+
partitions = 1
101+
config = {
102+
"cleanup.policy" = "compact,delete"
103+
"retention.ms" = "86400000"
104+
"retention.bytes" = "1073741824"
105+
"segment.bytes" = "536870912"
106+
}
107+
}
108+
]
109+
}

examples/complete/version.tf

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
terraform {
2+
required_version = ">= 1.3.0"
3+
required_providers {
4+
ibm = {
5+
source = "IBM-Cloud/ibm"
6+
version = "1.49.0"
7+
}
8+
}
9+
}

examples/default/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Default example
1+
# Default example using the modules default inputs
22

3-
An end-to-end example that uses the module's default variable values.
3+
An end-to-end example that creates an event streams instance.
44
This example uses the IBM Cloud terraform provider to:
55
- Create a new resource group if one is not passed in.
6-
- Create a new Cloud Object Storage instance.
6+
- Create a new event streams instance with default inputs in the resource group and region provided.
77

88
<!-- Add your example and link to it from the module's main readme file. -->

examples/default/main.tf

+10-7
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ module "resource_group" {
99
existing_resource_group_name = var.resource_group
1010
}
1111

12-
resource "ibm_resource_instance" "cos_instance" {
13-
name = "${var.prefix}-cos"
14-
resource_group_id = module.resource_group.resource_group_id
15-
service = "cloud-object-storage"
16-
plan = "standard"
17-
location = "global"
18-
tags = var.resource_tags
12+
##############################################################################
13+
# Events-streams-instance
14+
##############################################################################
15+
16+
module "event_streams" {
17+
source = "../../"
18+
resource_group_id = module.resource_group.resource_group_id
19+
es_name = "${var.prefix}-es"
20+
tags = var.resource_tags
21+
skip_iam_authorization_policy = true
1922
}

examples/default/outputs.tf

+20-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
# Outputs
33
##############################################################################
44

5-
output "cos_instance_id" {
6-
description = "COS instance id"
7-
value = ibm_resource_instance.cos_instance.id
8-
}
9-
105
output "resource_group_name" {
116
description = "Resource group name"
127
value = module.resource_group.resource_group_name
@@ -16,3 +11,23 @@ output "resource_group_id" {
1611
description = "Resource group ID"
1712
value = module.resource_group.resource_group_id
1813
}
14+
15+
output "crn" {
16+
description = "Event Streams instance crn"
17+
value = module.event_streams.crn
18+
}
19+
20+
output "guid" {
21+
description = "Event Streams instance guid"
22+
value = module.event_streams.guid
23+
}
24+
25+
output "kafka_brokers_sasl" {
26+
description = "(Array of Strings) Kafka brokers use for interacting with Kafka native API"
27+
value = module.event_streams.kafka_brokers_sasl
28+
}
29+
30+
output "kafka_http_url" {
31+
description = "The API endpoint to interact with Event Streams REST API"
32+
value = module.event_streams.kafka_http_url
33+
}

examples/default/variables.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ variable "region" {
1313
variable "prefix" {
1414
type = string
1515
description = "Prefix to append to all resources created by this example"
16-
default = "terraform"
16+
default = "event_streams"
1717
}
1818

1919
variable "resource_group" {
@@ -24,6 +24,6 @@ variable "resource_group" {
2424

2525
variable "resource_tags" {
2626
type = list(string)
27-
description = "Optional list of tags to be added to created resources"
27+
description = "List of tags associated with the Event Steams instance"
2828
default = []
2929
}

0 commit comments

Comments
 (0)