-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #144 from max-amb/terraform-private-network
This PR was made by a WEX student. It provides a template Terraform script to create a private network.
- Loading branch information
Showing
4 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# terraform_privisioning | ||
* This folder contains terraform scripts to manage openstack configurations | ||
* These require a `clouds.yaml` in `~/.config/openstack/` to provide authentication | ||
|
||
## priv_network.tf | ||
* This terraform scripts creates a private network with a subnet domain of `10.0.0.x` | ||
* It also adds a router to connect the private network to the external network | ||
* You must provide a external_network_id to connect to router to | ||
* The script must be run with `--var-file=vars.tfvars` to pass through the required variables |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Define required providers | ||
terraform { | ||
required_version = ">= 0.14.0" | ||
required_providers { | ||
openstack = { | ||
source = "terraform-provider-openstack/openstack" | ||
version = "~> 1.53.0" | ||
} | ||
} | ||
} | ||
|
||
provider "openstack" { | ||
cloud = "openstack" | ||
} | ||
|
||
resource "openstack_networking_network_v2" "private_network" { | ||
name = "private_network" | ||
admin_state_up = "true" | ||
} | ||
|
||
|
||
resource "openstack_networking_subnet_v2" "subnet" { | ||
name = "subnet" | ||
network_id = openstack_networking_network_v2.private_network.id | ||
cidr = "10.0.0.0/24" | ||
ip_version = 4 | ||
} | ||
|
||
resource "openstack_networking_router_v2" "router" { | ||
name = "router" | ||
external_network_id = var.external_network_id | ||
} | ||
|
||
resource "openstack_networking_router_interface_v2" "router_interface" { | ||
router_id = openstack_networking_router_v2.router.id | ||
subnet_id = openstack_networking_subnet_v2.subnet.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
variable "external_network_id" { | ||
description = "The id of the external network to connect the router to" | ||
type = string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
external_network_id = "" |