Commit febf7fd6 authored by drechsau's avatar drechsau

well, more initial commits

parent ed80ff5d
resource "aws_eip" "natgw-a" {
vpc = true
}
resource "aws_nat_gateway" "natgw-a" {
allocation_id = "${aws_eip.natgw-a.id}"
subnet_id = "${aws_subnet.drone-deploy-mgmt-a.id}"
}
# create route tables
resource "aws_route_table" "az-a" {
vpc_id = "${module.vpc.vpc_id}"
#propagating_vgws = ["${var.private_propagating_vgws_1}"]
tags {
Name = "${var.name}-rt-natgw-a"
}
}
# create default route for route tables
resource "aws_route" "nategw-a" {
route_table_id = "${aws_route_table.az-a.id}"
destination_cidr_block = "0.0.0.0/0"
nat_gateway_id = "${aws_nat_gateway.natgw-a.id}"
}
# associate AZ routes to AZ NAT route tables
resource "aws_route_table_association" "drone-deploy-mgmt-a" {
subnet_id = "${aws_subnet.drone-deploy-mgmt-a.id}"
route_table_id = "${module.vpc.public_route_table_id}"
}
resource "aws_route_table_association" "c1-elb-a" {
subnet_id = "${aws_subnet.c1-elb-a.id}"
route_table_id = "${module.vpc.public_route_table_id}"
}
#resource "aws_route_table_association" "c1-databases-a" {
# subnet_id = "${aws_subnet.c1-databases-a.id}"
#
# route_table_id = "${aws_route_table.az-a.id}"
#}
#resource "aws_route_table_association" "c1-elasticache-a" {
# subnet_id = "${aws_subnet.c1-elasticache-a.id}"
#
# route_table_id = "${aws_route_table.az-a.id}"
#}
resource "aws_route_table_association" "c1-docker-pub-a" {
subnet_id = "${aws_subnet.c1-docker-pub-a.id}"
#route_table_id = "${module.vpc.public_route_table_id}"
route_table_id = "${aws_route_table.az-a.id}"
}
resource "aws_route_table_association" "c1-docker-priv-a" {
subnet_id = "${aws_subnet.c1-docker-priv-a.id}"
route_table_id = "${aws_route_table.az-a.id}"
}
resource "aws_route_table_association" "c1-app-a" {
subnet_id = "${aws_subnet.c1-app-a.id}"
route_table_id = "${aws_route_table.az-a.id}"
}
resource "aws_route_table_association" "c1-admin-a" {
subnet_id = "${aws_subnet.c1-admin-a.id}"
route_table_id = "${aws_route_table.az-a.id}"
}
resource "aws_route_table_association" "c1-elb-admin-a" {
subnet_id = "${aws_subnet.c1-elb-admin-a.id}"
route_table_id = "${aws_route_table.az-a.id}"
}
resource "aws_route_table_association" "c1-elb-client-a" {
subnet_id = "${aws_subnet.c1-elb-client-a.id}"
route_table_id = "${aws_route_table.az-a.id}"
}
#resource "aws_route_table_association" "c1-efs-a" {
# subnet_id = "${aws_subnet.c1-efs-a.id}"
#
# route_table_id = "${aws_route_table.az-a.id}"
#}
resource "aws_route_table_association" "c1-cmgmt-a" {
subnet_id = "${aws_subnet.c1-cmgmt-a.id}"
route_table_id = "${module.vpc.public_route_table_id}"
}
resource "aws_eip" "natgw-b" {
vpc = true
}
resource "aws_nat_gateway" "natgw-b" {
allocation_id = "${aws_eip.natgw-b.id}"
subnet_id = "${aws_subnet.drone-deploy-mgmt-b.id}"
}
# create route tables
resource "aws_route_table" "az-b" {
vpc_id = "${module.vpc.vpc_id}"
#propagating_vgws = ["${var.private_propagating_vgws_1}"]
tags {
Name = "${var.name}-rt-natgw-b"
}
}
# create default route for route tables
resource "aws_route" "nategw-b" {
route_table_id = "${aws_route_table.az-b.id}"
destination_cidr_block = "0.0.0.0/0"
nat_gateway_id = "${aws_nat_gateway.natgw-b.id}"
}
# associate AZ routes to AZ NAT route tables
resource "aws_route_table_association" "drone-deploy-mgmt-b" {
subnet_id = "${aws_subnet.drone-deploy-mgmt-b.id}"
route_table_id = "${module.vpc.public_route_table_id}"
}
resource "aws_route_table_association" "c1-elb-b" {
subnet_id = "${aws_subnet.c1-elb-b.id}"
route_table_id = "${module.vpc.public_route_table_id}"
}
#resource "aws_route_table_association" "c1-databases-b" {
# subnet_id = "${aws_subnet.c1-databases-b.id}"
#
# route_table_id = "${aws_route_table.az-b.id}"
#}
#resource "aws_route_table_association" "c1-elasticache-b" {
# subnet_id = "${aws_subnet.c1-elasticache-b.id}"
#
# route_table_id = "${aws_route_table.az-b.id}"
#}
resource "aws_route_table_association" "c1-docker-pub-b" {
subnet_id = "${aws_subnet.c1-docker-pub-b.id}"
#route_table_id = "${module.vpc.public_route_table_id}"
route_table_id = "${aws_route_table.az-b.id}"
}
resource "aws_route_table_association" "c1-docker-priv-b" {
subnet_id = "${aws_subnet.c1-docker-priv-b.id}"
route_table_id = "${aws_route_table.az-b.id}"
}
resource "aws_route_table_association" "c1-app-b" {
subnet_id = "${aws_subnet.c1-app-b.id}"
route_table_id = "${aws_route_table.az-b.id}"
}
resource "aws_route_table_association" "c1-admin-b" {
subnet_id = "${aws_subnet.c1-admin-b.id}"
route_table_id = "${aws_route_table.az-b.id}"
}
resource "aws_route_table_association" "c1-elb-admin-b" {
subnet_id = "${aws_subnet.c1-elb-admin-b.id}"
route_table_id = "${aws_route_table.az-b.id}"
}
resource "aws_route_table_association" "c1-elb-client-b" {
subnet_id = "${aws_subnet.c1-elb-client-b.id}"
route_table_id = "${aws_route_table.az-b.id}"
}
#resource "aws_route_table_association" "c1-efs-b" {
# subnet_id = "${aws_subnet.c1-efs-b.id}"
#
# route_table_id = "${aws_route_table.az-b.id}"
#}
resource "aws_route_table_association" "c1-cmgmt-b" {
subnet_id = "${aws_subnet.c1-cmgmt-b.id}"
route_table_id = "${module.vpc.public_route_table_id}"
}
resource "aws_eip" "natgw-c" {
vpc = true
}
resource "aws_nat_gateway" "natgw-c" {
allocation_id = "${aws_eip.natgw-c.id}"
subnet_id = "${aws_subnet.drone-deploy-mgmt-c.id}"
}
# create route tables
resource "aws_route_table" "az-c" {
vpc_id = "${module.vpc.vpc_id}"
#propagating_vgws = ["${var.private_propagating_vgws_1}"]
tags {
Name = "${var.name}-rt-natgw-c"
}
}
# create default route for route tables
resource "aws_route" "nategw-c" {
route_table_id = "${aws_route_table.az-c.id}"
destination_cidr_block = "0.0.0.0/0"
nat_gateway_id = "${aws_nat_gateway.natgw-c.id}"
}
# associate AZ routes to AZ NAT route tables
resource "aws_route_table_association" "drone-deploy-mgmt-c" {
subnet_id = "${aws_subnet.drone-deploy-mgmt-c.id}"
route_table_id = "${module.vpc.public_route_table_id}"
}
resource "aws_route_table_association" "c1-elb-c" {
subnet_id = "${aws_subnet.c1-elb-c.id}"
route_table_id = "${module.vpc.public_route_table_id}"
}
#resource "aws_route_table_association" "c1-databases-c" {
# subnet_id = "${aws_subnet.c1-databases-c.id}"
#
# route_table_id = "${aws_route_table.az-c.id}"
#}
#resource "aws_route_table_association" "c1-elasticache-c" {
# subnet_id = "${aws_subnet.c1-elasticache-c.id}"
#
# route_table_id = "${aws_route_table.az-c.id}"
#}
resource "aws_route_table_association" "c1-docker-pub-c" {
subnet_id = "${aws_subnet.c1-docker-pub-c.id}"
#route_table_id = "${module.vpc.public_route_table_id}"
route_table_id = "${aws_route_table.az-c.id}"
}
resource "aws_route_table_association" "c1-docker-priv-c" {
subnet_id = "${aws_subnet.c1-docker-priv-c.id}"
route_table_id = "${aws_route_table.az-c.id}"
}
resource "aws_route_table_association" "c1-app-c" {
subnet_id = "${aws_subnet.c1-app-c.id}"
route_table_id = "${aws_route_table.az-c.id}"
}
resource "aws_route_table_association" "c1-admin-c" {
subnet_id = "${aws_subnet.c1-admin-c.id}"
route_table_id = "${aws_route_table.az-c.id}"
}
resource "aws_route_table_association" "c1-elb-admin-c" {
subnet_id = "${aws_subnet.c1-elb-admin-c.id}"
route_table_id = "${aws_route_table.az-c.id}"
}
resource "aws_route_table_association" "c1-elb-client-c" {
subnet_id = "${aws_subnet.c1-elb-client-c.id}"
route_table_id = "${aws_route_table.az-c.id}"
}
#resource "aws_route_table_association" "c1-efs-c" {
# subnet_id = "${aws_subnet.c1-efs-c.id}"
#
# route_table_id = "${aws_route_table.az-c.id}"
#}
resource "aws_route_table_association" "c1-cmgmt-c" {
subnet_id = "${aws_subnet.c1-cmgmt-c.id}"
route_table_id = "${module.vpc.public_route_table_id}"
}
output "the_vpc_id" {
value = "${module.vpc.vpc_id}"
}
output "main_route_table_id" {
value = "${module.vpc.main_route_table_id}"
}
output "public_route_table_ids" {
value = "${module.vpc.public_route_table_ids}"
}
output "sn-drone-deploy-mgmt-a" {
value = "${aws_subnet.drone-deploy-mgmt-a.id}"
}
output "sn-drone-deploy-mgmt-b" {
value = "${aws_subnet.drone-deploy-mgmt-b.id}"
}
output "sn-drone-deploy-mgmt-c" {
value = "${aws_subnet.drone-deploy-mgmt-c.id}"
}
output "drone-deploy-mgmt-cidr" {
value = [
"${aws_subnet.drone-deploy-mgmt-a.cidr_block}",
"${aws_subnet.drone-deploy-mgmt-b.cidr_block}",
"${aws_subnet.drone-deploy-mgmt-c.cidr_block}",
]
}
output "sn-drone-deploy-mgmt-a-cidr" {
value = "${aws_subnet.drone-deploy-mgmt-a.cidr_block}"
}
output "sn-drone-deploy-mgmt-b-cidr" {
value = "${aws_subnet.drone-deploy-mgmt-b.cidr_block}"
}
output "sn-drone-deploy-mgmt-c-cidr" {
value = "${aws_subnet.drone-deploy-mgmt-c.cidr_block}"
}
output "sn-c1-elb-a" {
value = "${aws_subnet.c1-elb-a.id}"
}
output "sn-c1-elb-b" {
value = "${aws_subnet.c1-elb-b.id}"
}
output "sn-c1-elb-c" {
value = "${aws_subnet.c1-elb-c.id}"
}
output "sn-c1-efs-a" {
value = "${aws_subnet.c1-efs-a.id}"
}
output "sn-c1-efs-b" {
value = "${aws_subnet.c1-efs-b.id}"
}
output "sn-c1-efs-c" {
value = "${aws_subnet.c1-efs-c.id}"
}
output "sn-c1-databases-a" {
value = "${aws_subnet.c1-databases-a.id}"
}
output "sn-c1-databases-b" {
value = "${aws_subnet.c1-databases-b.id}"
}
output "sn-c1-databases-c" {
value = "${aws_subnet.c1-databases-c.id}"
}
output "sn-c1-elasticache-a" {
value = "${aws_subnet.c1-elasticache-a.id}"
}
output "sn-c1-elasticache-b" {
value = "${aws_subnet.c1-elasticache-b.id}"
}
output "sn-c1-elasticache-c" {
value = "${aws_subnet.c1-elasticache-c.id}"
}
output "sn-c1-docker-pub-a" {
value = "${aws_subnet.c1-docker-pub-a.id}"
}
output "sn-c1-docker-pub-b" {
value = "${aws_subnet.c1-docker-pub-b.id}"
}
output "sn-c1-docker-pub-c" {
value = "${aws_subnet.c1-docker-pub-c.id}"
}
output "sn-c1-docker-priv-a" {
value = "${aws_subnet.c1-docker-priv-a.id}"
}
output "sn-c1-docker-priv-b" {
value = "${aws_subnet.c1-docker-priv-b.id}"
}
output "sn-c1-docker-priv-c" {
value = "${aws_subnet.c1-docker-priv-c.id}"
}
output "sn-c1-app-a" {
value = "${aws_subnet.c1-app-a.id}"
}
output "sn-c1-app-b" {
value = "${aws_subnet.c1-app-b.id}"
}
output "sn-c1-app-c" {
value = "${aws_subnet.c1-app-c.id}"
}
output "sn-c1-admin-a" {
value = "${aws_subnet.c1-admin-a.id}"
}
output "sn-c1-admin-b" {
value = "${aws_subnet.c1-admin-b.id}"
}
output "sn-c1-admin-c" {
value = "${aws_subnet.c1-admin-c.id}"
}
output "sn-c1-cmgmt-a" {
value = "${aws_subnet.c1-cmgmt-a.id}"
}
output "sn-c1-cmgmt-b" {
value = "${aws_subnet.c1-cmgmt-b.id}"
}
output "sn-c1-cmgmt-c" {
value = "${aws_subnet.c1-cmgmt-c.id}"
}
output "c1-cmgmt-cidr" {
value = [
"${aws_subnet.c1-cmgmt-a.cidr_block}",
"${aws_subnet.c1-cmgmt-b.cidr_block}",
"${aws_subnet.c1-cmgmt-c.cidr_block}",
]
}
output "c1-cmgmt-ids" {
value = [
"${aws_subnet.c1-cmgmt-a.id}",
"${aws_subnet.c1-cmgmt-b.id}",
"${aws_subnet.c1-cmgmt-c.id}",
]
}
output "c1-databases-subnets" {
value = [
"${aws_subnet.c1-databases-a.id}",
"${aws_subnet.c1-databases-b.id}",
"${aws_subnet.c1-databases-c.id}",
]
}
output "c1-app-subnets" {
value = [
"${aws_subnet.c1-app-a.id}",
"${aws_subnet.c1-app-b.id}",
"${aws_subnet.c1-app-c.id}",
]
}
output "c1-app-subnets-cidr" {
value = [
"${aws_subnet.c1-app-a.cidr_block}",
"${aws_subnet.c1-app-b.cidr_block}",
"${aws_subnet.c1-app-c.cidr_block}",
]
}
output "c1-admin-subnets" {
value = [
"${aws_subnet.c1-admin-a.id}",
"${aws_subnet.c1-admin-b.id}",
"${aws_subnet.c1-admin-c.id}",
]
}
output "c1-admin-subnets-cidr" {
value = [
"${aws_subnet.c1-admin-a.cidr_block}",
"${aws_subnet.c1-admin-b.cidr_block}",
"${aws_subnet.c1-admin-c.cidr_block}",
]
}
output "c1-docker-pub-subnets-cidr" {
value = [
"${aws_subnet.c1-docker-pub-a.cidr_block}",
"${aws_subnet.c1-docker-pub-b.cidr_block}",
"${aws_subnet.c1-docker-pub-c.cidr_block}",
]
}
output "c1-elb-ids" {
value = [
"${aws_subnet.c1-elb-a.id}",
"${aws_subnet.c1-elb-b.id}",
"${aws_subnet.c1-elb-c.id}",
]
}
output "c1-docker-pub-ids" {
value = [
"${aws_subnet.c1-docker-pub-a.id}",
"${aws_subnet.c1-docker-pub-b.id}",
"${aws_subnet.c1-docker-pub-c.id}",
]
}
output "c1-docker-priv-ids" {
value = [
"${aws_subnet.c1-docker-priv-a.id}",
"${aws_subnet.c1-docker-priv-b.id}",
"${aws_subnet.c1-docker-priv-c.id}",
]
}
output "c1-elb-admin-ids" {
value = [
"${aws_subnet.c1-elb-admin-a.id}",
"${aws_subnet.c1-elb-admin-b.id}",
"${aws_subnet.c1-elb-admin-c.id}",
]
}
output "c1-elb-client-ids" {
value = [
"${aws_subnet.c1-elb-client-a.id}",
"${aws_subnet.c1-elb-client-b.id}",
"${aws_subnet.c1-elb-client-c.id}",
]
}
#####
output "razr_office_ips_cidr" {
value = [
"10.10.25.0/24",
"10.10.125.0/24",
"172.30.0.0/16",
]
}
# the fun begins
# drone-deploy managment for whole VPC
resource "aws_subnet" "drone-deploy-mgmt-a" {
vpc_id = "${module.vpc.vpc_id}"
cidr_block = "${var.first-2-octets}.1.0/24"
availability_zone = "${var.azs[0]}"
map_public_ip_on_launch = false
tags {
Name = "drone-deploy-mgmt-a-${var.azs[0]}"
}
}
resource "aws_subnet" "drone-deploy-mgmt-b" {
vpc_id = "${module.vpc.vpc_id}"
cidr_block = "${var.first-2-octets}.2.0/24"
availability_zone = "${var.azs[1]}"
map_public_ip_on_launch = false
tags {
Name = "drone-deploy-mgmt-b-${var.azs[1]}"
}
}
resource "aws_subnet" "drone-deploy-mgmt-c" {
vpc_id = "${module.vpc.vpc_id}"
cidr_block = "${var.first-2-octets}.3.0/24"
availability_zone = "${var.azs[2]}"
map_public_ip_on_launch = false
tags {
Name = "drone-deploy-mgmt-c-${var.azs[2]}"
}
}
resource "aws_subnet" "c1-elb-a" {
vpc_id = "${module.vpc.vpc_id}"
cidr_block = "${var.first-2-octets}.16.0/24"
availability_zone = "${var.azs[0]}"
map_public_ip_on_launch = false
tags {
Name = "c1-elb-a-${var.azs[0]}"
}
}
resource "aws_subnet" "c1-elb-b" {
vpc_id = "${module.vpc.vpc_id}"
cidr_block = "${var.first-2-octets}.17.0/24"
availability_zone = "${var.azs[1]}"
map_public_ip_on_launch = false
tags {
Name = "c1-elb-b-${var.azs[1]}"
}
}
resource "aws_subnet" "c1-elb-c" {
vpc_id = "${module.vpc.vpc_id}"
cidr_block = "${var.first-2-octets}.18.0/24"
availability_zone = "${var.azs[2]}"
map_public_ip_on_launch = false
tags {
Name = "c1-elb-c-${var.azs[2]}"
}
}
resource "aws_subnet" "c1-efs-a" {
vpc_id = "${module.vpc.vpc_id}"
cidr_block = "${var.first-2-octets}.32.0/24"
availability_zone = "${var.azs[0]}"
map_public_ip_on_launch = false
tags {
Name = "c1-efs-a-${var.azs[0]}"
}
}
resource "aws_subnet" "c1-efs-b" {
vpc_id = "${module.vpc.vpc_id}"
cidr_block = "${var.first-2-octets}.33.0/24"
availability_zone = "${var.azs[1]}"
map_public_ip_on_launch = false
tags {
Name = "c1-efs-b-${var.azs[1]}"
}
}
resource "aws_subnet" "c1-efs-c" {
vpc_id = "${module.vpc.vpc_id}"
cidr_block = "${var.first-2-octets}.34.0/24"
availability_zone = "${var.azs[2]}"
map_public_ip_on_launch = false
tags {
Name = "c1-efs-c-${var.azs[2]}"
}