Skip to content

cloud-design-dev/dts-mzr-vpc

Repository files navigation

Overview

This module deploys a Multizone Region (MZR) VPC in IBM Cloud with the following characteristics:

  • Ability to deploy a VPC with custom address prefixes
  • Ability to deploy a VPC with public gateways in any of the three zones
  • Ability to deploy a subnet in each regional zone

Diagram

Overview of deployed resources

Module Inputs

Name Description Type Default Required
address_prefix The address prefix to use if address_prefix_management is set to manual. This will be split in to three prefixes, one for each zone. string "172.16.0.0/16" no
classic_access Indicates if the VPC will have Classic Access. bool false no
owner_tag The owner tag to assign to all resources. string n/a yes
project_prefix Prefix to assign to all deployed resources. If not provided a random string will be generated. string "" no
region The IBM Cloud region where the VPC and related resources will be deployed. string n/a yes
resource_group_id The ID of the resource group to use for deployed resources. string n/a yes
tags Tags to assign to all resources. list(string) [] no
use_custom_prefix Indicates if custom address prefixes will be used. bool false no
use_public_gateways Create a public gateway in any of the three zones set to true.
object({
zone-1 = optional(bool)
zone-2 = optional(bool)
zone-3 = optional(bool)
})
{
"zone-1": true,
"zone-2": false,
"zone-3": false
}
no

Module Outputs

Name Description
default_network_acl_id ID of the Default Access Control List for the VPC
default_routing_table_id ID of the Default Routing Table for the VPC
default_security_group_crn Cloud Resource Name (CRN) of the Default Security Group for the VPC
default_security_group_id ID of the Default Security Group for the VPC
local_vpc_zones Public gateway zone mapping to actual IBM Cloud VPC zone names
vpc_address_prefix_ids IBM Cloud VPC Address Prefix IDs
vpc_crn Cloud Resource Name (CRN) of the IBM Cloud VPC
vpc_id ID of the IBM Cloud VPC
vpc_public_gateway_ids ID of the deployed VPC Public Gateways
vpc_subnet_ids ID of the deployed VPC Subnets

Example usage of the module

  1. This example shows how to deploy a VPC with public gateways in zones 1 and 2. Additionally as no project prefix is provided, a random string will be generated.
terraform {
  required_providers {
    ibm = {
      source  = "IBM-Cloud/ibm"
      version = "1.70.1"
    }
  }
}

provider "ibm" {
  ibmcloud_api_key = var.ibmcloud_api_key
  region           = var.ibmcloud_region
}

module "resource_group" {
  source                       = "terraform-ibm-modules/resource-group/ibm"
  version                      = "1.1.5"
  resource_group_name          = var.existing_resource_group == null ? "${var.prefix}-resource-group" : null
  existing_resource_group_name = var.existing_resource_group
}

module "default_vpc" {
  source                  = "git::https://github.com/cloud-design-dev/dts-mzr-vpc.git"
  existing_resource_group = module.resource_group.resource_group_id
  region                  = var.region
  owner_tag               = "supercooldev"
  use_public_gateways = {
    zone-1 = true
    zone-2 = true
    zone-3 = false
  }
}
  1. This example shows how to deploy a VPC with custom address prefixes and a project prefix. Additionally, public gateways are not created in any of the zones.
terraform {
  required_providers {
    ibm = {
      source  = "IBM-Cloud/ibm"
      version = "1.70.1"
    }
  }
}

provider "ibm" {
  ibmcloud_api_key = var.ibmcloud_api_key
  region           = var.ibmcloud_region
}

module "resource_group" {
  source                       = "terraform-ibm-modules/resource-group/ibm"
  version                      = "1.1.5"
  resource_group_name          = var.existing_resource_group == null ? "${var.prefix}-resource-group" : null
  existing_resource_group_name = var.existing_resource_group
}

module "custom_vpc" {
  source                  = "git::https://github.com/cloud-design-dev/dts-mzr-vpc.git"
  existing_resource_group = var.existing_resource_group
  region                  = var.region
  project_prefix          = "custom"
  owner_tag               = "supercooldev"
  use_custom_prefix       = true
  address_prefix          = "192.168.50.0/18"
  use_public_gateways = {
    zone-1 = false
    zone-2 = false
    zone-3 = false
  }
}

About

Terraform module for an MZR VPC in IBM Cloud

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages