Skip to content

Commit 70c1eba

Browse files
committed
Initial commit
0 parents  commit 70c1eba

10 files changed

Lines changed: 170 additions & 0 deletions

File tree

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Set the default behavior, in case people don't have core.autocrlf set.
2+
* text=lf

.gitignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# .tfvars files
2+
*.tfvars
3+
4+
# Exclude for testing stuff.
5+
!testing.tfvars
6+
7+
# .tfstate files
8+
*.tfstate
9+
*.tfstate.*
10+
11+
# Go vendor directory
12+
vendor/
13+
14+
# Files generated by terratest
15+
.test-data/
16+
17+
# Local .terraform directory
18+
**/.terraform/*
19+
20+
# IDE config files
21+
**/.idea/*
22+
**/.vscode/*
23+
24+
# MacOS files
25+
.DS_Store
26+
27+
# Ruby downloaded package lock file.
28+
Gemfile.lock
29+
30+
# Local test-kitchen files.
31+
**/.kitchen/*

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2019 Rachide <rachide.ouattara@runadium.fr> (runadium.fr)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

Makefile

Whitespace-only changes.

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# My new created Terraform module
2+
3+
Introduce your module briefly.
4+
5+
## Usage
6+
7+
Provide the sample code to use your module.
8+
9+
## Scenarios
10+
11+
Provide advanced use cases here.
12+
13+
## Examples
14+
15+
Paste the links to your sample code in `examples` folder.
16+
17+
## Inputs
18+
19+
List all input variables of your module.
20+
21+
## Outputs
22+
23+
List all output variables of your module.

examples/simple/main.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module "network" {
2+
source = "../../"
3+
network_name = "my-network"
4+
network_tags = ["mytag", "project"]
5+
network_description = "MyNetwork description"
6+
7+
subnets = [
8+
{
9+
subnet_name = "subnet-01"
10+
subnet_cidr = "10.10.10.0/24"
11+
subnet_ip_version = 4
12+
subnet_tags = "mysubnet, myproject, mytag"
13+
},
14+
]
15+
}

examples/simple/outputs.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
output "network" {
2+
value = "${module.network.network}"
3+
description = "The name of the Network being created"
4+
}
5+
6+
output "subnets" {
7+
value = "${module.network.subnets}"
8+
description = "The name of all subnets being created"
9+
}

main.tf

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/******************************************
2+
VPC configuration
3+
*****************************************/
4+
5+
resource "openstack_networking_network_v2" "this" {
6+
name = "${var.network_name}"
7+
description = "${var.network_description}"
8+
admin_state_up = "${var.network_admin_state_up}"
9+
tags = "${var.network_tags}"
10+
}
11+
12+
/******************************************
13+
Subnet configuration
14+
*****************************************/
15+
16+
resource "openstack_networking_subnet_v2" "this" {
17+
count = "${length(var.subnets)}"
18+
19+
name = "${lookup(var.subnets[count.index], "subnet_name")}"
20+
description = "${lookup(var.subnets[count.index], "subnet_description", "")}"
21+
network_id = "${openstack_networking_network_v2.this.id}"
22+
cidr = "${lookup(var.subnets[count.index], "subnet_cidr")}"
23+
enable_dhcp = "${lookup(var.subnets[count.index], "subnet_enable_dhcp", true)}"
24+
ip_version = "${lookup(var.subnets[count.index], "subnet_ip_version")}"
25+
26+
// FIXME Tags not supported for subnet in OpenStack?
27+
// tags = "${split(",",lookup(var.subnets[count.index], "subnet_tags"))}"
28+
}
29+
30+
data "openstack_networking_subnet_v2" "created_subnets" {
31+
count = "${length(var.subnets)}"
32+
33+
name = "${element(openstack_networking_subnet_v2.this.*.name, count.index)}"
34+
}

outputs.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
output "network" {
2+
value = "${format("%s [id= %s]",openstack_networking_network_v2.this.name, openstack_networking_network_v2.this.id)}"
3+
description = "The Network being created"
4+
}
5+
6+
output "subnets" {
7+
value = "${formatlist("%s with CIRD %s [id= %s]",data.openstack_networking_subnet_v2.created_subnets.*.name,data.openstack_networking_subnet_v2.created_subnets.*.cidr, data.openstack_networking_subnet_v2.created_subnets.*.id)}"
8+
description = "The name of all subnets being created"
9+
}

variables.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
variable "network_name" {
2+
type = "string"
3+
description = "The name of the network"
4+
}
5+
6+
variable "network_description" {
7+
type = "string"
8+
default = ""
9+
description = "Human-readable description of the network."
10+
}
11+
12+
variable "network_admin_state_up" {
13+
type = "string"
14+
default = "true"
15+
description = "The administrative state of the network"
16+
}
17+
18+
variable "network_tags" {
19+
type = "list"
20+
description = "A set of string tags for the network"
21+
}
22+
23+
variable "subnets" {
24+
type = "list"
25+
description = "The list of subnets being created"
26+
}

0 commit comments

Comments
 (0)