Skip to content

Commit 0917d94

Browse files
committed
Add spare subnets module
1 parent 86fe326 commit 0917d94

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

modules/network.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ variable "private_persistence_subnets" {
2626
default = []
2727
}
2828

29+
variable "spare_subnets" {
30+
description = "A list of CIDR blocks for spare subnets inside the VPC."
31+
default = []
32+
}
33+
2934
## VPC-Peering variables
3035
# Default values assigned inorder to mark them optional
3136
variable "peer_vpc_id" {
@@ -112,6 +117,15 @@ module "private_persistence_subnet" {
112117
azs = "${var.azs}"
113118
}
114119

120+
module "spare_subnet" {
121+
source = "./spare-subnet"
122+
123+
name = "${var.name}-spare"
124+
vpc_id = "${module.vpc.vpc_id}"
125+
spare_subnets = "${var.spare_subnets}"
126+
azs = "${var.azs}"
127+
}
128+
115129
module "network_acl" {
116130
source = "./network-acl"
117131

modules/spare-subnet/main.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
resource "aws_subnet" "spare" {
2+
vpc_id = "${var.vpc_id}"
3+
cidr_block = "${var.spare_subnets[count.index]}"
4+
availability_zone = "${var.azs[count.index]}"
5+
count = "${length(var.azs)}"
6+
7+
tags {
8+
Name = "${var.name}-${var.azs[count.index]}"
9+
}
10+
}

modules/spare-subnet/output.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
output "subnet_ids" {
2+
value = "${join(",", aws_subnet.spare.*.id)}"
3+
}

modules/spare-subnet/variables.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
variable "name" {
2+
default = "spare"
3+
}
4+
5+
variable "vpc_id" {}
6+
7+
variable "spare_subnets" {
8+
description = "A list of CIDR blocks for spare subnets inside the VPC."
9+
type = "list"
10+
}
11+
12+
variable "azs" {
13+
description = "A list of Availability zones in the region"
14+
type = "list"
15+
}

0 commit comments

Comments
 (0)