generated from terraform-ibm-modules/terraform-ibm-module-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.tf
150 lines (139 loc) · 5.22 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
##############################################################################
# Resource Group
##############################################################################
module "resource_group" {
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-resource-group.git?ref=v1.1.6"
# if an existing resource group is not set (null) create a new one using prefix
resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null
existing_resource_group_name = var.resource_group
}
##############################################################################
# Get Cloud Account ID
##############################################################################
data "ibm_iam_account_settings" "iam_account_settings" {
}
##############################################################################
# VPC
##############################################################################
resource "ibm_is_vpc" "example_vpc" {
name = "${var.prefix}-vpc"
resource_group = module.resource_group.resource_group_id
tags = var.resource_tags
}
resource "ibm_is_subnet" "testacc_subnet" {
name = "${var.prefix}-subnet"
vpc = ibm_is_vpc.example_vpc.id
zone = "${var.region}-1"
total_ipv4_address_count = 256
resource_group = module.resource_group.resource_group_id
}
##############################################################################
# Create CBR Zone
##############################################################################
module "cbr_vpc_zone" {
source = "terraform-ibm-modules/cbr/ibm//modules/cbr-zone-module"
version = "1.29.0"
name = "${var.prefix}-VPC-network-zone"
zone_description = "CBR Network zone representing VPC"
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
addresses = [{
type = "vpc", # to bind a specific vpc to the zone
value = ibm_is_vpc.example_vpc.crn,
}]
}
module "cbr_zone_schematics" {
source = "terraform-ibm-modules/cbr/ibm//modules/cbr-zone-module"
version = "1.29.0"
name = "${var.prefix}-schematics-zone"
zone_description = "CBR Network zone containing Schematics"
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
addresses = [{
type = "serviceRef",
ref = {
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
service_name = "schematics"
}
}]
}
# #############################################################################
# Events-streams-instance
# #############################################################################
module "event_streams" {
source = "../../modules/fscloud"
resource_group_id = module.resource_group.resource_group_id
es_name = "${var.prefix}-es-fs"
kms_key_crn = var.kms_key_crn
schemas = var.schemas
tags = var.resource_tags
topics = var.topics
metrics = ["topic", "partition", "consumers"]
mirroring_topic_patterns = ["topic-1", "topic-2"]
mirroring = {
source_crn = var.event_streams_source_crn # Required for mirroring
source_alias = "source-alias" # Required for mirroring
target_alias = "target-alias" # Required for mirroring
# 'options' are optional. Valid values for 'type' are 'rename', 'none', or 'use_alias'.
# If 'type' is set to 'rename', then 'rename' object must include the following fields: 'add_prefix', 'add_suffix', 'remove_prefix', and 'remove_suffix'.
options = {
topic_name_transform = {
type = "rename"
rename = {
add_prefix = "add_prefix"
add_suffix = "add_suffix"
remove_prefix = "remove_prefix"
remove_suffix = "remove_suffix"
}
}
group_id_transform = {
type = "rename"
rename = {
add_prefix = "add_prefix"
add_suffix = "add_suffix"
remove_prefix = "remove_prefix"
remove_suffix = "remove_suffix"
}
}
}
}
quotas = [
{
"entity" = "iam-ServiceId-00000000-0000-0000-0000-000000000000",
"producer_byte_rate" = 100000,
"consumer_byte_rate" = 200000
}
]
schema_global_rule = "FORWARD"
service_credential_names = {
"es_writer" : "Writer",
"es_reader" : "Reader",
"es_manager" : "Manager"
}
cbr_rules = [
{
description = "${var.prefix}-event streams access from vpc and schematics"
enforcement_mode = "enabled"
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
rule_contexts = [{
attributes = [
{
"name" : "endpointType",
"value" : "private"
},
{
name = "networkZoneId"
value = module.cbr_vpc_zone.zone_id
}]
}, {
attributes = [
{
"name" : "endpointType",
"value" : "private"
},
{
name = "networkZoneId"
value = module.cbr_zone_schematics.zone_id
}]
}]
}
]
}