Skip to content

Commit 85f5b5a

Browse files
committed
init
1 parent e657787 commit 85f5b5a

9 files changed

Lines changed: 124 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>
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.

examples/simple/main.tf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module "security_group" {
2+
source = "../../"
3+
name = "example"
4+
description = "Instance Rules Project"
5+
rules = "${var.instance-rules-sg}"
6+
}
7+
8+
variable "instance-rules-sg" {
9+
default = [
10+
{
11+
direction = "ingress"
12+
ethertype = "IPv4"
13+
protocol = "tcp"
14+
port_range_min = 22
15+
port_range_max = 22
16+
remote_ip_prefix = "0.0.0.0/0"
17+
},
18+
{
19+
direction = "ingress"
20+
ethertype = "IPv4"
21+
protocol = "icmp"
22+
port_range_min = 0
23+
port_range_max = 0
24+
remote_ip_prefix = "0.0.0.0/0"
25+
},
26+
]
27+
}

examples/simple/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "security_group_id" {
2+
description = "The security group id"
3+
value = ["${module.security_group.id}"]
4+
}

main.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
resource "openstack_networking_secgroup_v2" "this" {
2+
name = "${var.name}-sg"
3+
description = "${var.description}"
4+
delete_default_rules = "${var.delete_default_rules}"
5+
}
6+
7+
resource "openstack_networking_secgroup_rule_v2" "this" {
8+
count = "${length(var.rules)}"
9+
port_range_min = "${lookup(var.rules[count.index], "port_range_min")}"
10+
port_range_max = "${lookup(var.rules[count.index], "port_range_max")}"
11+
protocol = "${lookup(var.rules[count.index], "protocol")}"
12+
direction = "${lookup(var.rules[count.index], "direction")}"
13+
ethertype = "${lookup(var.rules[count.index], "ethertype")}"
14+
remote_ip_prefix = "${lookup(var.rules[count.index], "remote_ip_prefix")}"
15+
security_group_id = "${element(openstack_networking_secgroup_v2.this.*.id,count.index)}"
16+
}

outputs.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
output "id" {
2+
value = "${openstack_networking_secgroup_v2.this.*.id}"
3+
}

variables.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
variable "name" {
2+
type = "string"
3+
default = "default"
4+
}
5+
6+
variable "description" {
7+
type = "string"
8+
default = "desc"
9+
}
10+
11+
variable "delete_default_rules" {
12+
type = "string"
13+
default = "true"
14+
}
15+
16+
17+
variable "rules" {
18+
type = "list"
19+
default = []
20+
}

0 commit comments

Comments
 (0)