Commit d13d2792 authored by Alex Hanselka's avatar Alex Hanselka
Browse files

fix up routes, instance variables, and more

parent 741144ba
......@@ -158,6 +158,7 @@ variable "public_ports" {
type = "map"
default = {
"aws-test" = [22]
"api" = []
"bastion" = [22]
"blackbox" = []
......@@ -235,6 +236,14 @@ variable "data_disk_sizes" {
}
}
variable "aws_machine_types" {
type = "map"
default = {
"aws-test" = "t2.medium"
}
}
variable "machine_types" {
type = "map"
......@@ -286,6 +295,7 @@ variable "node_count" {
default = {
"api" = 1
"aws-test" = 1
"bastion" = 1
"blackbox" = 1
"console" = 1
......@@ -328,6 +338,14 @@ variable "node_count" {
}
}
variable "aws_subnetworks" {
type = "map"
default = {
"aws-test" = "10.230.0.0/24"
}
}
variable "subnetworks" {
type = "map"
......@@ -404,3 +422,9 @@ variable "gcs_service_account_email" {
type = "string"
default = "gitlab-object-storage@gitlab-staging-1.iam.gserviceaccount.com"
}
variable "aws_cidr_block" {
type = "string"
description = "The CIDR block to use for AWS VPC"
default = "10.230.0.0/16"
}
resource "aws_network_interface" "default" {
subnet_id = "${aws_subnet.subnetwork.id}"
security_groups = ["${aws_security_group.public.id}", "${var.allow_internal_group}"]
tags {
Name = "${format("%v-%02d-%v-%v", var.name, count.index + 1, var.tier, var.environment)}"
}
count = "${var.node_count}"
subnet_id = "${aws_subnet.subnetwork.id}"
security_groups = ["${aws_security_group.public.id}", "${var.internal_sg}"]
tags {
Name = "${format("%v-%02d-%v-%v", var.name, count.index + 1, var.tier, var.environment)}"
}
}
resource "aws_instance" "default" {
ami = "${var.os_boot_image}"
instance_type = "${var.instance_type}"
network_interface {
network_interface_id = "${aws_network_interface.default.id}"
device_index = 0
}
tags {
Name = "${format("%v-%02d-%v-%v", var.name, count.index + 1, var.tier, var.environment)}"
}
count = "${var.node_count}"
ami = "${var.os_boot_image}"
instance_type = "${var.instance_type}"
key_name = "${var.keypair_name}"
network_interface {
network_interface_id = "${aws_network_interface.default.*.id[count.index]}"
device_index = 0
}
root_block_device {
volume_type = "${var.root_volume_type}"
volume_size = "${var.root_volume_size}"
}
tags {
Name = "${format("%v-%02d-%v-%v", var.name, count.index + 1, var.tier, var.environment)}"
}
}
resource "aws_eip" "external" {
instance = "${aws_instance.default.id}"
count = "${var.node_count}"
instance = "${aws_instance.default.*.id[count.index]}"
vpc = true
tags = {
Name = "${format("%v-%02d-%v-%v", var.name, count.index + 1, var.tier, var.environment)}"
}
}
resource "aws_subnet" "subnetwork" {
vpc_id = "${var.vpc_id}"
cidr_block = "${var.ip_cidr_range}"
tags {
Name = "${format("%v-%v", var.environment, var.name)}"
}
......
variable "environment" {
type = "string"
description = "The environment the instance is in"
}
variable "instance_type" {
type = "string"
description = "size of instance to create"
type = "string"
description = "size of instance to create"
}
variable "os_boot_image" {
type = "string"
description = "The image to use"
default = "ami-04169656fea786776"
variable "internal_sg" {
type = "string"
description = "The internal security group created for the VPC"
}
variable "public_ports" {
type = "list"
description = "The public ports to open to the world"
default = [22]
variable "ip_cidr_range" {
type = "string"
description = "The cidr range for the subnetwork"
}
variable "keypair_name" {
type = "string"
description = "They name of the keypair to associate with the instance"
default = "terraform"
}
variable "name" {
type = "string"
description = "The name of the instance"
type = "string"
description = "The name of the instance"
}
variable "environment" {
type = "string"
description = "The environment the instance is in"
variable "node_count" {
type = "string"
description = "The number of nodes to create"
}
variable "ip_cidr_range" {
type = "string"
description = "The cidr range for the subnetwork"
variable "os_boot_image" {
type = "string"
description = "The image to use"
default = "ami-04169656fea786776"
}
variable "vpc_id" {
type = "string"
description = "The ID of the VPC to attach to the subnet"
variable "public_ports" {
type = "list"
description = "The public ports to open to the world"
default = [22]
}
variable "root_volume_size" {
type = "string"
description = "The size in GB of the root disk"
default = "8"
}
variable "root_volume_type" {
type = "string"
description = "The type of the root disk (standard, gp2, io1)"
default = "gp2"
}
variable "tier" {
type = "string"
description = "The tier for this service"
}
variable "allow_internal_group" {}
\ No newline at end of file
variable "vpc_id" {
type = "string"
description = "The ID of the VPC to attach to the subnet"
}
......@@ -9,11 +9,11 @@ resource "aws_security_group" "allow-internal" {
protocol = "-1"
cidr_blocks = ["10.0.0.0/8"]
}
egress {
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_vpc" "main" {
cidr_block = "${var.cidr_block}"
tags = {
Name = "${var.environment}"
}
}
resource "aws_internet_gateway" "main" {
vpc_id = "${aws_vpc.main.id}"
}
\ No newline at end of file
tags = {
Name = "${var.environment}"
}
}
resource "aws_route_table" "main" {
vpc_id = "${aws_vpc.main.id}"
tags = {
Name = "${var.environment}"
}
}
resource "aws_main_route_table_association" "main" {
vpc_id = "${aws_vpc.main.id}"
route_table_id = "${aws_route_table.main.id}"
}
resource "aws_route" "outbound" {
route_table_id = "${aws_route_table.main.id}"
destination_cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.main.id}"
}
......@@ -7,4 +7,3 @@ output "internal_security_group" {
value = "${aws_security_group.allow-internal.id}"
description = "The URL of the created network"
}
......@@ -2,3 +2,8 @@ variable "cidr_block" {
type = "string"
description = "The cidr block used for the VPC"
}
variable "environment" {
type = "string"
description = "Name of the environment"
}
......@@ -40,6 +40,12 @@ module "network" {
source = "../../modules/google/vpc"
}
module "aws-network" {
source = "../../modules/aws/vpc"
cidr_block = "${var.aws_cidr_block}"
environment = "${var.environment}"
}
##################################
#
# Network Peering
......@@ -1206,3 +1212,16 @@ module "gitlab_object_storage" {
gcs_storage_analytics_group_email = "${var.gcs_storage_analytics_group_email}"
source = "../../modules/google/storage-buckets"
}
module "aws-test" {
environment = "${var.environment}"
source = "../../modules/aws/generic-sv"
name = "aws-test"
tier = "sv"
instance_type = "${var.aws_machine_types["aws-test"]}"
ip_cidr_range = "${var.aws_subnetworks["aws-test"]}"
node_count = "${var.node_count["aws-test"]}"
public_ports = "${var.public_ports["aws-test"]}"
vpc_id = "${module.aws-network.vpc_id}"
internal_sg = "${module.aws-network.internal_security_group}"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment