Skip to content

Terraform module to provision vpc resources

danielbu-ibm/terraform-ibm-vpc

 
 

Repository files navigation

IBM Cloud VPC module

Provisions a VPC instance and related resources. The full list of resources provisioned is as follows:

  • VPC instance
  • VPC network acl
  • VPC security group rules
    • ping - icmp type 8
    • public dns - 161.26.0.10 and 161.26.0.11
    • private dns - 161.26.0.7 and 161.26.0.8

Software dependencies

The module depends on the following software components:

Command-line tools

  • terraform - v13

Terraform providers

  • IBM Cloud provider >= 1.22.0

Module dependencies

  • Resource group - github.com/cloud-native-toolkit/terraform-ibm-resource-group.git

Example usage

module "dev_vpc" {
  source = "github.com/cloud-native-toolkit/terraform-ibm-vpc.git?ref=v1.7.2"
  
  resource_group_id   = module.resource_group.id
  resource_group_name = module.resource_group.name
  region              = var.region
  name_prefix         = var.name_prefix
  ibmcloud_api_key    = var.ibmcloud_api_key
}

Supporting resources

delete-vpc.sh

Cleaning up a VPC instance can be difficult because the resources need to be removed in a particular order. Running a terraform delete from the terraform state that provisioned the VPC instance is the most reliable way to clean up the resources. However, if the terraform state gets corrupted or lost or the VPC resources were provisioned by hand then an alternative approach is required. In order to address this issue, a script has been provided in scripts/delete-vpc.sh.

Prerequisites

Software

The delete-vpc.sh script has the following software requirements:

Environment

The delete-vpc.sh script assumes that you have already logged into the IBM Cloud account where the VPC resources have been deployed using the ibmcloud cli. For more information see https://cloud.ibm.com/docs/cli?topic=cli-ibmcloud_cli#ibmcloud_login

Usage

Assuming the prerequisites have been met, the script can be run by passing the name of the VPC to remove as the only argument. E.g.

./delete-vpc.sh my-vpc

The script will delete all of the resources under the VPC in order then finally delete the VPC instance itself.

About

Terraform module to provision vpc resources

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HCL 59.3%
  • Shell 40.7%