Skip to content

terraform-ibm-modules/terraform-ibm-vpc

Repository files navigation

IBM Cloud VPC module

Stable (With quality checks) latest release pre-commit Renovate enabled semantic-release

Terraform Module for IBM Cloud VPC Infrastructure

This module provides a comprehensive solution for managing IBM Cloud Virtual Private Cloud (VPC) infrastructure. It includes a main module and several submodules, enabling you to create, configure, and manage VPC components either individually or through the main module.

This module is designed to provide a scalable, secure, and flexible VPC environment tailored to meet various use cases within IBM Cloud, supporting a broad range of infrastructure needs from basic networking setups to complex multi-zone architectures.

Overview

terraform-ibm-vpc

Usage

module "vpc" {
  source            = "terraform-ibm-modules/vpc/ibm"
  version           = "X.X.X" # Replace "X.X.X" with a release version to lock into a specific release

  vpc_name          = "stage-vpc"
  resource_group_id = module.resource_group.resource_group_id
  locations         = ["us-south-1", "us-south-2", "us-south-3"]
  vpc_tags          = var.resource_tags
  address_prefixes = [
    {
      name     = "stage-us-south-1"
      location = "us-south-1"
      ip_range = "10.10.10.0/24"
    },
    {
      name     = "stage-us-south-2"
      location = "us-south-2"
      ip_range = "10.10.20.0/24"
    },
    {
      name     = "stage-us-south-3"
      location = "us-south-3"
      ip_range = "10.10.30.0/24"
    }
  ]

  subnet_name_prefix          = "stage-subnet"
  default_network_acl_name    = "stage-nacl"
  default_routing_table_name  = "stage-routing-table"
  default_security_group_name = "stage-sg"
  create_gateway              = true
  public_gateway_name_prefix  = "stage-pw"
  number_of_addresses         = 16
}

Required IAM access policies

You need the following permissions to run this module.

  • IAM services
    • VPC Infrastructure services
      • Editor platform access
    • No service access
      • Resource Group <your resource group>
      • Viewer resource group access

Requirements

Name Version
terraform >= 1.3.0
ibm >= 1.64.0, <2.0.0

Modules

Name Source Version
vpc ./modules/vpc n/a

Resources

No resources.

Inputs

Name Description Type Default Required
address_prefixes List of Prefixes for the vpc
list(object({
name = string
location = string
ip_range = string
}))
[] no
auto_assign_address_prefix Set to true to create a default address prefix automatically for each zone in the VPC. bool true no
clean_default_sg_acl Remove all rules from the default VPC security group and VPC ACL (less permissive) bool false no
create_gateway True to create new Gateway bool false no
create_vpc True to create new VPC. False if VPC is already existing and subnets or address prefixies are to be added bool true no
default_network_acl_name Name of the Default ACL string "default-network-acl" no
default_routing_table_name Name of the Default Routing Table string "default_routing_table" no
default_security_group_name Name of the Default Security Group string "default_security_group" no
existing_vpc_name Name of the Existing VPC to which subnets, gateways are to be attached, only used when var.create_vpc is false string null no
floating_ip Floating IP id's or address'es that you want to assign to the public gateway map(any) {} no
gateway_tags List of Tags for the gateway list(string) [] no
locations zones per region list(string) [] no
number_of_addresses Number of IPV4 Addresses number null no
public_gateway_name_prefix Prefix to the names of the Public Gateways string "public_gateway" no
resource_group_id ID of resource group. string null no
subnet_name_prefix Prefix to the names of subnets string "subnet" no
vpc_name Name of the vpc string null no
vpc_tags List of Tags for the vpc list(string) [] no

Outputs

Name Description
vpc Configuration of newly created or existing VPC instance.

Contributing

You can report issues and request features for this module in GitHub issues in the module repo. See Report an issue or request a feature.

To set up your local development environment, see Local development setup in the project documentation.