-
Notifications
You must be signed in to change notification settings - Fork 40
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 #169 from kubenow/feature/aws-optional-vpc-subnet
Restructure amazon vpc module into submodules
- Loading branch information
Showing
7 changed files
with
163 additions
and
118 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
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
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,47 @@ | ||
variable name_prefix {} | ||
variable vpc_id {} | ||
|
||
resource "aws_security_group" "main" { | ||
name = "${var.name_prefix}" | ||
description = "kubenow default security group" | ||
vpc_id = "${var.vpc_id}" | ||
|
||
ingress { # SSH | ||
from_port = 22 | ||
to_port = 22 | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
|
||
ingress { # HTTP | ||
from_port = 80 | ||
to_port = 80 | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
|
||
ingress { # HTTPS | ||
from_port = 443 | ||
to_port = 443 | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
|
||
ingress { # Allow ALL internal (self) | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = -1 | ||
self = true | ||
} | ||
|
||
egress { # Allow ALL outbound | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
} | ||
|
||
output "id" { | ||
value = ["${aws_security_group.main.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,59 @@ | ||
variable vpc_id {} | ||
variable subnet_id {} | ||
variable subnet_cidr { default = "10.0.0.0/16"} | ||
variable availability_zone {} | ||
variable name_prefix {} | ||
|
||
resource "aws_subnet" "created" { | ||
# create subnet only if not specified in var.subnet_id | ||
count = "${var.subnet_id == "" ? 1 : 0}" | ||
vpc_id = "${var.vpc_id}" | ||
cidr_block = "${var.subnet_cidr}" | ||
availability_zone = "${var.availability_zone}" | ||
tags { | ||
Name = "${var.name_prefix}" | ||
} | ||
} | ||
|
||
resource "aws_internet_gateway" "main" { | ||
# create subnet only if not specified in var.subnet_id | ||
count = "${var.subnet_id == "" ? 1 : 0}" | ||
vpc_id = "${var.vpc_id}" | ||
tags { | ||
Name = "${var.name_prefix}" | ||
} | ||
} | ||
|
||
resource "aws_route_table" "main" { | ||
# create subnet only if not specified in var.subnet_id | ||
count = "${var.subnet_id == "" ? 1 : 0}" | ||
vpc_id = "${var.vpc_id}" | ||
|
||
route { | ||
cidr_block = "0.0.0.0/0" | ||
gateway_id = "${aws_internet_gateway.main.id}" | ||
} | ||
|
||
tags { | ||
Name = "${var.name_prefix}" | ||
} | ||
} | ||
|
||
resource "aws_main_route_table_association" "main" { | ||
# create subnet only if not specified in var.subnet_id | ||
count = "${var.subnet_id == "" ? 1 : 0}" | ||
vpc_id = "${var.vpc_id}" | ||
route_table_id = "${aws_route_table.main.id}" | ||
} | ||
|
||
resource "aws_route_table_association" "main" { | ||
# create subnet only if not specified in var.subnet_id | ||
count = "${var.subnet_id == "" ? 1 : 0}" | ||
subnet_id = "${var.subnet_id != "" ? var.subnet_id : aws_subnet.created.id }" | ||
route_table_id = "${aws_route_table.main.id}" | ||
} | ||
|
||
output "id" { | ||
value = "${ var.subnet_id != "" ? var.subnet_id : aws_subnet.created.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 |
---|---|---|
@@ -1,113 +1,18 @@ | ||
variable vpc_id {} | ||
variable vpc_cidr { default = "10.0.0.0/16"} | ||
variable name_prefix {} | ||
variable availability_zone {} | ||
variable subnet_id { default = "" } | ||
|
||
|
||
resource "aws_vpc" "main" { | ||
cidr_block = "10.0.0.0/16" | ||
resource "aws_vpc" "created" { | ||
# create vpc only if not specified in var.vpc_id | ||
count = "${var.vpc_id == "" ? 1 : 0}" | ||
cidr_block = "${var.vpc_cidr}" | ||
enable_dns_support = true | ||
enable_dns_hostnames = true | ||
tags { | ||
Name = "${var.name_prefix}" | ||
} | ||
} | ||
|
||
resource "aws_subnet" "main" { | ||
# create subnet only if not specified in var.subnet_id | ||
count = "${ var.subnet_id == "" ? 1 : 0 }" | ||
vpc_id = "${aws_vpc.main.id}" | ||
cidr_block = "${aws_vpc.main.cidr_block}" | ||
availability_zone = "${var.availability_zone}" | ||
tags { | ||
Name = "${var.name_prefix}" | ||
} | ||
} | ||
|
||
resource "aws_internet_gateway" "main" { | ||
# create only if subnet is being created | ||
count = "${ var.subnet_id == "" ? 1 : 0 }" | ||
vpc_id = "${aws_vpc.main.id}" | ||
tags { | ||
Name = "${var.name_prefix}" | ||
} | ||
} | ||
|
||
resource "aws_route_table" "main" { | ||
# create only if subnet is being created | ||
count = "${ var.subnet_id == "" ? 1 : 0 }" | ||
vpc_id = "${aws_vpc.main.id}" | ||
|
||
route { | ||
cidr_block = "0.0.0.0/0" | ||
gateway_id = "${aws_internet_gateway.main.id}" | ||
} | ||
|
||
tags { | ||
Name = "${var.name_prefix}" | ||
} | ||
} | ||
|
||
resource "aws_main_route_table_association" "main" { | ||
# create only if subnet is being created | ||
count = "${ var.subnet_id == "" ? 1 : 0 }" | ||
vpc_id = "${aws_vpc.main.id}" | ||
route_table_id = "${aws_route_table.main.id}" | ||
} | ||
|
||
resource "aws_route_table_association" "main" { | ||
# create only if subnet is being created | ||
count = "${ var.subnet_id == "" ? 1 : 0 }" | ||
subnet_id = "${ var.subnet_id == "" ? aws_subnet.main.id : var.subnet_id}" | ||
route_table_id = "${aws_route_table.main.id}" | ||
} | ||
|
||
resource "aws_security_group" "main" { | ||
name = "${var.name_prefix}" | ||
description = "kubenow default security group" | ||
vpc_id = "${aws_vpc.main.id}" | ||
|
||
|
||
ingress { # SSH | ||
from_port = 22 | ||
to_port = 22 | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
|
||
ingress { # HTTP | ||
from_port = 80 | ||
to_port = 80 | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
|
||
ingress { # HTTPS | ||
from_port = 443 | ||
to_port = 443 | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
|
||
ingress { # Allow ALL internal (self) | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = -1 | ||
self = true | ||
} | ||
|
||
egress { # Allow ALL outbound | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
|
||
} | ||
|
||
output "subnet_id" { | ||
value = "${ var.subnet_id == "" ? aws_subnet.main.id : var.subnet_id }" | ||
} | ||
|
||
output "security_group_id" { | ||
value = "${aws_security_group.main.id}" | ||
output "id" { | ||
value = "${ var.vpc_id != "" ? var.vpc_id : aws_vpc.created.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
Submodule secrets-kubenow
updated
from 11ddba to ffa50e