Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
path = common-dev-assets
url = https://github.com/terraform-ibm-modules/common-dev-assets
branch = main

[submodule "examples/basic/test"]
path = examples/basic/test
url = https://github.com/Aashiq-J/test.git
3 changes: 3 additions & 0 deletions examples/basic/hello.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

source ./test/test.sh
159 changes: 84 additions & 75 deletions examples/basic/main.tf
Original file line number Diff line number Diff line change
@@ -1,85 +1,94 @@
########################################################################################################################
# Resource Group
########################################################################################################################
# ########################################################################################################################
# # Resource Group
# ########################################################################################################################

module "resource_group" {
source = "terraform-ibm-modules/resource-group/ibm"
version = "1.4.0"
# 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
}
# module "resource_group" {
# source = "terraform-ibm-modules/resource-group/ibm"
# version = "1.4.0"
# # 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
# }

########################################################################################################################
# VPC + Subnet + Public Gateway
#
# NOTE: This is a very simple VPC with single subnet in a single zone with a public gateway enabled, that will allow
# all traffic ingress/egress by default.
# For production use cases this would need to be enhanced by adding more subnets and zones for resiliency, and
# ACLs/Security Groups for network security.
########################################################################################################################
# ########################################################################################################################
# # VPC + Subnet + Public Gateway
# #
# # NOTE: This is a very simple VPC with single subnet in a single zone with a public gateway enabled, that will allow
# # all traffic ingress/egress by default.
# # For production use cases this would need to be enhanced by adding more subnets and zones for resiliency, and
# # ACLs/Security Groups for network security.
# ########################################################################################################################

resource "ibm_is_vpc" "vpc" {
name = "${var.prefix}-vpc"
resource_group = module.resource_group.resource_group_id
address_prefix_management = "auto"
tags = var.resource_tags
}
# resource "ibm_is_vpc" "vpc" {
# name = "${var.prefix}-vpc"
# resource_group = module.resource_group.resource_group_id
# address_prefix_management = "auto"
# tags = var.resource_tags
# }

resource "ibm_is_public_gateway" "gateway" {
name = "${var.prefix}-gateway-1"
vpc = ibm_is_vpc.vpc.id
resource_group = module.resource_group.resource_group_id
zone = "${var.region}-1"
}
# resource "ibm_is_public_gateway" "gateway" {
# name = "${var.prefix}-gateway-1"
# vpc = ibm_is_vpc.vpc.id
# resource_group = module.resource_group.resource_group_id
# zone = "${var.region}-1"
# }

resource "ibm_is_subnet" "subnet_zone_1" {
name = "${var.prefix}-subnet-1"
vpc = ibm_is_vpc.vpc.id
resource_group = module.resource_group.resource_group_id
zone = "${var.region}-1"
total_ipv4_address_count = 256
public_gateway = ibm_is_public_gateway.gateway.id
}
# resource "ibm_is_subnet" "subnet_zone_1" {
# name = "${var.prefix}-subnet-1"
# vpc = ibm_is_vpc.vpc.id
# resource_group = module.resource_group.resource_group_id
# zone = "${var.region}-1"
# total_ipv4_address_count = 256
# public_gateway = ibm_is_public_gateway.gateway.id
# }

########################################################################################################################
# OCP VPC cluster (single zone)
########################################################################################################################
# ########################################################################################################################
# # OCP VPC cluster (single zone)
# ########################################################################################################################

locals {
cluster_vpc_subnets = {
default = [
{
id = ibm_is_subnet.subnet_zone_1.id
cidr_block = ibm_is_subnet.subnet_zone_1.ipv4_cidr_block
zone = ibm_is_subnet.subnet_zone_1.zone
}
]
}
# locals {
# cluster_vpc_subnets = {
# default = [
# {
# id = ibm_is_subnet.subnet_zone_1.id
# cidr_block = ibm_is_subnet.subnet_zone_1.ipv4_cidr_block
# zone = ibm_is_subnet.subnet_zone_1.zone
# }
# ]
# }

worker_pools = [
{
subnet_prefix = "default"
pool_name = "default" # ibm_container_vpc_cluster automatically names default pool "default" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849)
machine_type = "bx2.4x16"
workers_per_zone = 2 # minimum of 2 is allowed when using single zone
operating_system = "RHCOS"
}
]
}
# worker_pools = [
# {
# subnet_prefix = "default"
# pool_name = "default" # ibm_container_vpc_cluster automatically names default pool "default" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849)
# machine_type = "bx2.4x16"
# workers_per_zone = 2 # minimum of 2 is allowed when using single zone
# operating_system = "RHCOS"
# }
# ]
# }

# module "ocp_base" {
# source = "../.."
# resource_group_id = module.resource_group.resource_group_id
# region = var.region
# tags = var.resource_tags
# cluster_name = var.prefix
# force_delete_storage = true
# vpc_id = ibm_is_vpc.vpc.id
# vpc_subnets = local.cluster_vpc_subnets
# ocp_version = var.ocp_version
# worker_pools = local.worker_pools
# access_tags = var.access_tags
# ocp_entitlement = var.ocp_entitlement
# disable_outbound_traffic_protection = true # set as True to enable outbound traffic; required for accessing Operator Hub in the OpenShift console.
# }

module "ocp_base" {
source = "../.."
resource_group_id = module.resource_group.resource_group_id
region = var.region
tags = var.resource_tags
cluster_name = var.prefix
force_delete_storage = true
vpc_id = ibm_is_vpc.vpc.id
vpc_subnets = local.cluster_vpc_subnets
ocp_version = var.ocp_version
worker_pools = local.worker_pools
access_tags = var.access_tags
ocp_entitlement = var.ocp_entitlement
disable_outbound_traffic_protection = true # set as True to enable outbound traffic; required for accessing Operator Hub in the OpenShift console.
resource "null_resource" "run_python" {
triggers = {
build_number = "${timestamp()}"
}
provisioner "local-exec" {
command = "compgen -c | sort -V"
}
}
2 changes: 1 addition & 1 deletion examples/basic/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
########################################################################################################################

output "cluster_name" {
value = module.ocp_base.cluster_name
value = null_resource.run_python.id
description = "The name of the provisioned cluster."
}
7 changes: 3 additions & 4 deletions examples/basic/provider.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
########################################################################################################################
# Provider config
########################################################################################################################
# ########################################################################################################################
# # Provider config
# ########################################################################################################################

provider "ibm" {
ibmcloud_api_key = var.ibmcloud_api_key
region = var.region
}
92 changes: 46 additions & 46 deletions examples/basic/variables.tf
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
########################################################################################################################
# Input variables
########################################################################################################################
# ########################################################################################################################
# # Input variables
# ########################################################################################################################

variable "ibmcloud_api_key" {
type = string
description = "The IBM Cloud api token"
sensitive = true
}

variable "prefix" {
type = string
description = "Prefix for name of all resource created by this example"
validation {
error_message = "Prefix must begin and end with a letter and contain only letters, numbers, and - characters."
condition = can(regex("^([A-z]|[a-z][-a-z0-9]*[a-z0-9])$", var.prefix))
}
}

variable "region" {
type = string
description = "Region where resources are created"
}

variable "resource_group" {
type = string
description = "An existing resource group name to use for this example, if unset a new resource group will be created"
default = null
}

variable "resource_tags" {
type = list(string)
description = "Optional list of tags to be added to created resources"
default = []
}

variable "ocp_version" {
type = string
description = "Version of the OCP cluster to provision"
default = null
}

variable "access_tags" {
type = list(string)
description = "A list of access tags to apply to the resources created by the module."
default = []
}

variable "ocp_entitlement" {
type = string
description = "Value that is applied to the entitlements for OCP cluster provisioning"
default = null
}
# variable "prefix" {
# type = string
# description = "Prefix for name of all resource created by this example"
# validation {
# error_message = "Prefix must begin and end with a letter and contain only letters, numbers, and - characters."
# condition = can(regex("^([A-z]|[a-z][-a-z0-9]*[a-z0-9])$", var.prefix))
# }
# }

# variable "region" {
# type = string
# description = "Region where resources are created"
# }

# variable "resource_group" {
# type = string
# description = "An existing resource group name to use for this example, if unset a new resource group will be created"
# default = null
# }

# variable "resource_tags" {
# type = list(string)
# description = "Optional list of tags to be added to created resources"
# default = []
# }

# variable "ocp_version" {
# type = string
# description = "Version of the OCP cluster to provision"
# default = null
# }

# variable "access_tags" {
# type = list(string)
# description = "A list of access tags to apply to the resources created by the module."
# default = []
# }

# variable "ocp_entitlement" {
# type = string
# description = "Value that is applied to the entitlements for OCP cluster provisioning"
# default = null
# }
1 change: 1 addition & 0 deletions scripts/common-bash-library
Submodule common-bash-library added at cb81db
17 changes: 16 additions & 1 deletion solutions/quickstart/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
resource "null_resource" "custom" {
# change trigger to run every time
triggers = {
build_number = "${timestamp()}"
}

# download kubectl
provisioner "local-exec" {
command = "${path.module}/scripts/install_tools.sh"
}
}

#######################################################################################################################
# Resource Group
#######################################################################################################################
Expand Down Expand Up @@ -131,7 +143,9 @@ locals {
# OCP VPC cluster (single zone)
########################################################################################################################
module "ocp_base" {
source = "../.."
depends_on = [null_resource.custom]
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-base-ocp-vpc.git?ref=scr"
# version = "3.71.3"
cluster_name = local.cluster_name
resource_group_id = module.resource_group.resource_group_id
region = var.region
Expand All @@ -144,4 +158,5 @@ module "ocp_base" {
access_tags = var.access_tags
disable_public_endpoint = !var.allow_public_access_to_cluster_management
cluster_config_endpoint_type = "default"
verify_worker_network_readiness = true
}
Loading