Skip to content

Commit 8d91a2d

Browse files
chore: Add new full end to end example (#883)
1 parent de1e125 commit 8d91a2d

File tree

10 files changed

+1580
-0
lines changed

10 files changed

+1580
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ By default, the module automatically downloads the required dependencies if they
3434
* <div style="display: inline-block;"><a href="./examples/add_rules_to_sg">Cluster security group rules example</a></div> <div style="display: inline-block; vertical-align: middle;"><a href="https://cloud.ibm.com/schematics/workspaces/create?workspace_name=bov-add_rules_to_sg-example&repository=https://github.com/terraform-ibm-modules/terraform-ibm-base-ocp-vpc/tree/main/examples/add_rules_to_sg" target="_blank"><img src="https://cloud.ibm.com/media/docs/images/icons/Deploy_to_cloud.svg" alt="Deploy to IBM Cloud button"></a></div>
3535
* <div style="display: inline-block;"><a href="./examples/advanced">Advanced example (mzr, auto-scale, kms, taints)</a></div> <div style="display: inline-block; vertical-align: middle;"><a href="https://cloud.ibm.com/schematics/workspaces/create?workspace_name=bov-advanced-example&repository=https://github.com/terraform-ibm-modules/terraform-ibm-base-ocp-vpc/tree/main/examples/advanced" target="_blank"><img src="https://cloud.ibm.com/media/docs/images/icons/Deploy_to_cloud.svg" alt="Deploy to IBM Cloud button"></a></div>
3636
* <div style="display: inline-block;"><a href="./examples/basic">Basic single zone cluster with allowed outbound traffic</a></div> <div style="display: inline-block; vertical-align: middle;"><a href="https://cloud.ibm.com/schematics/workspaces/create?workspace_name=bov-basic-example&repository=https://github.com/terraform-ibm-modules/terraform-ibm-base-ocp-vpc/tree/main/examples/basic" target="_blank"><img src="https://cloud.ibm.com/media/docs/images/icons/Deploy_to_cloud.svg" alt="Deploy to IBM Cloud button"></a></div>
37+
* <div style="display: inline-block;"><a href="./examples/containerized_app_landing_zone">Landing zone for containerized applications with OpenShift example</a></div> <div style="display: inline-block; vertical-align: middle;"><a href="https://cloud.ibm.com/schematics/workspaces/create?workspace_name=bov-containerized_app_landing_zone-example&repository=https://github.com/terraform-ibm-modules/terraform-ibm-base-ocp-vpc/tree/main/examples/containerized_app_landing_zone" target="_blank"><img src="https://cloud.ibm.com/media/docs/images/icons/Deploy_to_cloud.svg" alt="Deploy to IBM Cloud button"></a></div>
3738
* <div style="display: inline-block;"><a href="./examples/cross_kms_support">Cross account KMS encryption example</a></div> <div style="display: inline-block; vertical-align: middle;"><a href="https://cloud.ibm.com/schematics/workspaces/create?workspace_name=bov-cross_kms_support-example&repository=https://github.com/terraform-ibm-modules/terraform-ibm-base-ocp-vpc/tree/main/examples/cross_kms_support" target="_blank"><img src="https://cloud.ibm.com/media/docs/images/icons/Deploy_to_cloud.svg" alt="Deploy to IBM Cloud button"></a></div>
3839
* <div style="display: inline-block;"><a href="./examples/custom_sg">Attaching custom security groups</a></div> <div style="display: inline-block; vertical-align: middle;"><a href="https://cloud.ibm.com/schematics/workspaces/create?workspace_name=bov-custom_sg-example&repository=https://github.com/terraform-ibm-modules/terraform-ibm-base-ocp-vpc/tree/main/examples/custom_sg" target="_blank"><img src="https://cloud.ibm.com/media/docs/images/icons/Deploy_to_cloud.svg" alt="Deploy to IBM Cloud button"></a></div>
3940
* <div style="display: inline-block;"><a href="./examples/fscloud">Financial Services compliant example</a></div> <div style="display: inline-block; vertical-align: middle;"><a href="https://cloud.ibm.com/schematics/workspaces/create?workspace_name=bov-fscloud-example&repository=https://github.com/terraform-ibm-modules/terraform-ibm-base-ocp-vpc/tree/main/examples/fscloud" target="_blank"><img src="https://cloud.ibm.com/media/docs/images/icons/Deploy_to_cloud.svg" alt="Deploy to IBM Cloud button"></a></div>

examples/containerized_app_landing_zone/README.md

Lines changed: 145 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Ignore everything
2+
*
3+
4+
# But not these files...
5+
!.gitignore
6+
!README.md
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This directory must exist in source control so the `ibm_container_cluster_config` data lookup can use it to place the
2+
config.yml used to connect to a kubernetes cluster.

examples/containerized_app_landing_zone/main.tf

Lines changed: 982 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 294 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
##############################################################################
2+
# Cluster Outputs
3+
##############################################################################
4+
5+
output "cluster_name" {
6+
value = module.ocp_base.cluster_name
7+
description = "The name of the provisioned OpenShift cluster."
8+
}
9+
10+
output "cluster_id" {
11+
value = module.ocp_base.cluster_id
12+
description = "The unique identifier assigned to the provisioned OpenShift cluster."
13+
}
14+
15+
output "cluster_crn" {
16+
description = "The Cloud Resource Name (CRN) of the provisioned OpenShift cluster."
17+
value = module.ocp_base.cluster_crn
18+
}
19+
20+
output "workerpools" {
21+
description = "A list of worker pools associated with the provisioned cluster"
22+
value = module.ocp_base.workerpools
23+
}
24+
25+
output "ocp_version" {
26+
description = "The version of OpenShift running on the provisioned cluster."
27+
value = module.ocp_base.ocp_version
28+
}
29+
30+
31+
##############################################################################
32+
# VPC
33+
##############################################################################
34+
35+
output "vpc_name" {
36+
description = "Name of the VPC created."
37+
value = module.vpc.vpc_name
38+
}
39+
40+
output "vpc_id" {
41+
description = "ID of the VPC created."
42+
value = module.vpc.vpc_id
43+
}
44+
45+
output "vpc_crn" {
46+
description = "CRN of the VPC created."
47+
value = module.vpc.vpc_crn
48+
}
49+
50+
##############################################################################
51+
# Public Gateways
52+
##############################################################################
53+
54+
output "public_gateways" {
55+
description = "Map of the public gateways by zone."
56+
value = module.vpc.public_gateways
57+
}
58+
59+
##############################################################################
60+
# VPC flow logs
61+
##############################################################################
62+
63+
output "vpc_flow_logs" {
64+
description = "Details of the VPC flow logs collector."
65+
value = module.vpc.vpc_flow_logs
66+
}
67+
68+
##############################################################################
69+
# Network ACLs
70+
##############################################################################
71+
72+
output "network_acls" {
73+
description = "List of shortnames and IDs of network ACLs."
74+
value = module.vpc.network_acls
75+
}
76+
77+
##############################################################################
78+
# Subnet Outputs
79+
##############################################################################
80+
81+
output "subnet_ids" {
82+
description = "The IDs of the subnets."
83+
value = module.vpc.subnet_ids
84+
}
85+
86+
output "private_path_subnet_id" {
87+
description = "The IDs of the subnets."
88+
value = length(module.vpc.subnet_ids) > 0 ? module.vpc.subnet_ids[0] : null
89+
}
90+
91+
output "subnet_detail_list" {
92+
description = "A list of subnets containing names, CIDR blocks, and zones."
93+
value = module.vpc.subnet_detail_list
94+
}
95+
96+
output "subnet_zone_list" {
97+
description = "A list of subnet IDs and subnet zones."
98+
value = module.vpc.subnet_zone_list
99+
}
100+
101+
output "subnet_detail_map" {
102+
description = "A map of subnets containing IDs, CIDR blocks, and zones."
103+
value = module.vpc.subnet_detail_map
104+
}
105+
106+
##############################################################################
107+
# VPN Gateways Outputs
108+
##############################################################################
109+
110+
output "vpn_gateways_name" {
111+
description = "List of names of VPN gateways."
112+
value = module.vpc.vpn_gateways_name
113+
}
114+
115+
output "vpn_gateways_data" {
116+
description = "Details of VPN gateways data."
117+
value = module.vpc.vpn_gateways_data
118+
}
119+
120+
##############################################################################
121+
# VPE Outputs
122+
##############################################################################
123+
124+
output "vpe_ips" {
125+
description = "The reserved IPs for endpoint gateways."
126+
value = module.vpe_gateway.vpe_ips
127+
}
128+
129+
output "vpe_crn" {
130+
description = "The CRN of the endpoint gateway."
131+
value = module.vpe_gateway.crn
132+
}
133+
134+
##############################################################################
135+
# KMS Outputs
136+
##############################################################################
137+
138+
output "kms_guid" {
139+
description = "KMS instance GUID"
140+
value = module.kms.kms_guid
141+
}
142+
143+
output "kms_account_id" {
144+
description = "The account ID of the KMS instance."
145+
value = module.kms.kms_account_id
146+
}
147+
148+
output "kms_instance_crn" {
149+
value = module.kms.key_protect_crn
150+
description = "The CRN of the KMS instance"
151+
}
152+
153+
##############################################################################
154+
# Events Notification Outputs
155+
##############################################################################
156+
157+
output "events_notification_crn" {
158+
description = "Event Notification crn"
159+
value = module.event_notifications.crn
160+
}
161+
162+
output "events_notification_guid" {
163+
description = "Event Notification guid"
164+
value = module.event_notifications.guid
165+
}
166+
167+
##############################################################################
168+
# Secrets Manager Outputs
169+
##############################################################################
170+
171+
output "secrets_manager_guid" {
172+
description = "GUID of Secrets Manager instance"
173+
value = module.secrets_manager.secrets_manager_guid
174+
}
175+
176+
output "secrets_manager_crn" {
177+
value = module.secrets_manager.secrets_manager_crn
178+
description = "CRN of the Secrets Manager instance"
179+
}
180+
181+
output "secrets_manager_region" {
182+
value = module.secrets_manager.secrets_manager_region
183+
description = "Region of the Secrets Manager instance"
184+
}
185+
186+
##############################################################################
187+
# COS Outputs
188+
##############################################################################
189+
190+
output "cos_instance_crn" {
191+
description = "COS instance crn"
192+
value = module.cos.cos_instance_crn
193+
}
194+
195+
output "cos_instance_guid" {
196+
description = "COS instance guid"
197+
value = module.cos.cos_instance_guid
198+
}
199+
200+
##############################################################################
201+
# Cloud Monitoring Outputs
202+
##############################################################################
203+
204+
output "cloud_monitoring_crn" {
205+
value = module.cloud_monitoring.crn
206+
description = "The id of the provisioned IBM Cloud Monitoring instance."
207+
}
208+
output "cloud_monitoring_name" {
209+
value = module.cloud_monitoring.name
210+
description = "The name of the provisioned IBM Cloud Monitoring instance."
211+
}
212+
213+
output "cloud_monitoring_guid" {
214+
value = module.cloud_monitoring.guid
215+
description = "The guid of the provisioned IBM Cloud Monitoring instance."
216+
}
217+
218+
output "cloud_monitoring_access_key_name" {
219+
value = module.cloud_monitoring.access_key_name
220+
description = "The name of the IBM Cloud Monitoring access key for agents to use"
221+
}
222+
223+
output "cloud_monitoring_access_key" {
224+
value = module.cloud_monitoring.access_key
225+
description = "The IBM Cloud Monitoring access key for agents to use"
226+
sensitive = true
227+
}
228+
229+
##############################################################################
230+
# Cloud Logs Outputs
231+
##############################################################################
232+
233+
output "cloud_logs_crn" {
234+
value = module.cloud_logs.crn
235+
description = "The id of the provisioned IBM Cloud Logs instance."
236+
}
237+
238+
output "cloud_logs_guid" {
239+
value = module.cloud_logs.guid
240+
description = "The guid of the provisioned IBM Cloud Logs instance."
241+
}
242+
243+
output "cloud_logs_name" {
244+
value = module.cloud_logs.name
245+
description = "The name of the provisioned IBM Cloud Logs instance."
246+
}
247+
248+
output "logs_bucket_crn" {
249+
description = "Logs Cloud Object Storage bucket CRN"
250+
value = module.cloud_logs_buckets.buckets[local.data_bucket_name].bucket_crn
251+
}
252+
253+
output "metrics_bucket_crn" {
254+
description = "Metrics Cloud Object Storage bucket CRN"
255+
value = module.cloud_logs_buckets.buckets[local.metrics_bucket_name].bucket_crn
256+
}
257+
258+
##############################################################################
259+
# Activity Tracker Event Routing Outputs
260+
##############################################################################
261+
262+
output "activity_tracker_cos_target_bucket_name" {
263+
value = module.at_cos_bucket.buckets[local.activity_tracker_cos_target_bucket_name].bucket_name
264+
description = "he name of the object storage bucket which is set as activity tracker event routing target to collect audit events."
265+
}
266+
267+
output "activity_tracker_targets" {
268+
value = module.activity_tracker.activity_tracker_targets
269+
description = "The map of created Activity Tracker Event Routing targets"
270+
}
271+
272+
output "activity_tracker_routes" {
273+
value = module.activity_tracker.activity_tracker_routes
274+
description = "The map of created Activity Tracker Event Routing routes"
275+
}
276+
277+
##############################################################################
278+
# SCC-WP Outputs
279+
##############################################################################
280+
281+
output "scc_workload_protection_id" {
282+
description = "SCC Workload Protection instance ID"
283+
value = module.scc_wp.id
284+
}
285+
286+
output "scc_workload_protection_crn" {
287+
description = "SCC Workload Protection instance CRN"
288+
value = module.scc_wp.crn
289+
}
290+
291+
output "scc_workload_protection_name" {
292+
description = "SCC Workload Protection instance name"
293+
value = module.scc_wp.name
294+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
provider "ibm" {
2+
ibmcloud_api_key = var.ibmcloud_api_key
3+
region = var.region
4+
}
5+
6+
data "ibm_iam_auth_token" "auth_token" {}
7+
8+
provider "restapi" {
9+
uri = "https://resource-controller.cloud.ibm.com"
10+
headers = {
11+
Authorization = data.ibm_iam_auth_token.auth_token.iam_access_token
12+
}
13+
write_returns_object = true
14+
}
15+
16+
provider "helm" {
17+
kubernetes = {
18+
host = data.ibm_container_cluster_config.cluster_config.host
19+
token = data.ibm_container_cluster_config.cluster_config.token
20+
cluster_ca_certificate = data.ibm_container_cluster_config.cluster_config.ca_certificate
21+
}
22+
}
23+
24+
provider "kubernetes" {
25+
host = data.ibm_container_cluster_config.cluster_config.host
26+
token = data.ibm_container_cluster_config.cluster_config.token
27+
cluster_ca_certificate = data.ibm_container_cluster_config.cluster_config.ca_certificate
28+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
########################################################################################################################
2+
# Input variables
3+
########################################################################################################################
4+
5+
variable "ibmcloud_api_key" {
6+
type = string
7+
description = "The IBM Cloud api token"
8+
sensitive = true
9+
}
10+
11+
variable "prefix" {
12+
type = string
13+
description = "Prefix for name of all resource created by this example"
14+
default = "ocp-lz"
15+
validation {
16+
error_message = "Prefix must begin and end with a letter and contain only letters, numbers, and - characters."
17+
condition = can(regex("^([A-z]|[a-z][-a-z0-9]*[a-z0-9])$", var.prefix))
18+
}
19+
}
20+
21+
variable "region" {
22+
type = string
23+
description = "Region where resources are created"
24+
default = "us-south"
25+
}
26+
27+
variable "provider_visibility" {
28+
description = "Set the visibility value for the IBM terraform provider. Supported values are `public`, `private`, `public-and-private`."
29+
type = string
30+
default = "private"
31+
validation {
32+
condition = contains(["public", "private", "public-and-private"], var.provider_visibility)
33+
error_message = "Invalid visibility option. Allowed values are `public`, `private`, or `public-and-private`."
34+
}
35+
}
36+
37+
variable "existing_resource_group_name" {
38+
type = string
39+
description = "The name of an existing resource group to provision the resources."
40+
default = "Default"
41+
}
42+
43+
variable "event_notifications_email_list" {
44+
type = list(string)
45+
description = "The list of email address to target out when an event is triggered"
46+
default = []
47+
}

0 commit comments

Comments
 (0)