A Terraform module for Network in VKCS.
This modules makes it easy to setup virtual networking in VKCS.
It supports creating:
- router (optionally connected to the Internet)
- networks
- subnets of the networks (unconditionally attached to the router)
- subnet routes
It does not support:
- virtual networking without a router
- just a single router
- network without subnets
- subnets not attached to the router
- router routes
module "network" {
source = "https://github.com/vk-cs/terraform-vkcs-network/archive/refs/tags/v0.0.3.zip//terraform-vkcs-network-0.0.3"
# Alternatively you may refer right to Hashicorp module repository if you have access to it
# source = "vk-cs/network/vkcs"
# version = "0.0.3"
name = "simple-tf-example"
# Specify network name instead if default sdn contains more than one external network
external_network = true
networks = [{
subnets = [{
cidr = "192.168.199.0/24"
}]
}]
}output "network" {
value = module.network
}You can find examples in the examples directory on GitHub.
Running an example:
- Clone GitHub repository and checkout tag v0.0.3. Or get module archive and unpack it. Or just copy files above to a new folder.
- Install Terraform. Note: You do not need
vkcs_provider.tfto run module example. - Init Terraform from the example folder.
- Run Terraform to create example resources.
- Check example output and explore created resources with
terraform show, management console, CLI and API requests. - Remove example resources with
terraform destroy -auto-approve --refresh=false
The following requirements are needed by this module:
The following resources are used by this module:
- vkcs_networking_network.networks (resource)
- vkcs_networking_router.router (resource)
- vkcs_networking_router_interface.router_interfaces (resource)
- vkcs_networking_subnet.subnets (resource)
- vkcs_networking_subnet_route.subnet_routes (resource)
The following input variables are required:
Description: Default name for module resources. Used when name is not specified for a resource.
Type: string
Description: List of network configurations.
See vkcs_networking_network arguments for networks.
name is inherited from the module name by default.
resource_key default value is resulting name value. Must be defined if more than one network is specified.
See vkcs_networking_subnet arguments for subnets.
name is inherited from the module name by default.
resource_key default value is cidr or name value if specified.
resource_key - an unique key within list to index TF resources. May be used to prevent resource recreation on changing of resource name or simplify access to resources in TF state.
Type:
list(object({
tags = optional(set(string))
name = optional(string)
description = optional(string)
private_dns_domain = optional(string)
port_security_enabled = optional(bool)
vkcs_services_access = optional(bool)
resource_key = optional(string)
subnets = list(object({
tags = optional(set(string))
name = optional(string)
description = optional(string)
cidr = string
allocation_pool = optional(list(object({
start = string
end = string
})))
dns_nameservers = optional(list(string))
enable_dhcp = optional(bool)
enable_private_dns = optional(bool)
gateway_ip = optional(string)
routes = optional(list(object({
destination_cidr = string
next_hop = string
})))
resource_key = optional(string)
}))
}))The following input variables are optional (have default values):
Description: The region in which to create module resources.
Type: string
Default: null
Description: SDN to use for this module. Must be set if more than one sdn are plugged to the project.
Type: string
Default: null
Description: Default set of module resources tags.
Type: set(string)
Default: []
Description: A description for the router.
Type: string
Default: null
Description: Specify external network name or set true if the only external netwrok is available in the project.
Type: any
Default: null
The following outputs are exported:
Description: Router ID.
Description: External IP of the router.
Description: List of networks info.
See vkcs_networking_network and vkcs_networking_subnet for keys meaning.