-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
151 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# Keeping atlas variable without prefix as it's been shared by consul and tf at the moment. | ||
export ATLAS_TOKEN=${ATLAS_TOKEN:?"Need to set ATLAS_TOKEN non-empty"} | ||
export ATLAS_INFRASTRUCTURE=${ATLAS_INFRASTRUCTURE:-capgemini/apollo} | ||
|
||
export TF_VAR_user=${TF_VAR_user:?"Need to set User non-empty"} | ||
export TF_VAR_access_key=${TF_VAR_access_key:?"Need to set TF_VAR_access_key non-empty"} | ||
export TF_VAR_secret_key=${TF_VAR_secret_key:?"Need to set TF_VAR_secret_key non-empty"} | ||
export TF_VAR_key_file=${TF_VAR_key_file:-$HOME/.ssh/apollo_aws_rsa} | ||
export TF_VAR_key_name=${TF_VAR_key_name:-apollo} | ||
|
||
# Overrides default folder in Terraform.py inventory. | ||
export TF_VAR_STATE_ROOT="${APOLLO_ROOT}/terraform/${APOLLO_PROVIDER}" | ||
|
||
export ANSIBLE_SSH_ARGS="-F ${APOLLO_ROOT}/terraform/${APOLLO_PROVIDER}/ssh.config -q" | ||
|
||
export TF_VAR_region=${TF_VAR_region:-eu-west-1} | ||
export TF_VAR_master_instance_type=${TF_VAR_master_instance_type:-m3.medium} | ||
export TF_VAR_slave_instance_type=${TF_VAR_slave_instance_type:-m3.medium} | ||
export TF_VAR_slaves=${TF_VAR_slaves:-1} | ||
export TF_VAR_availability_zones=${TF_VAR_availability_zones:-'eu-west-1a,eu-west-1b,eu-west-1c'} | ||
export TF_VAR_public_subnet_availability_zone=${TF_VAR_public_subnet_availability_zone:-'eu-west-1a'} | ||
export APOLLO_consul_dc=${APOLLO_consul_dc:-$TF_VAR_region} | ||
export APOLLO_mesos_cluster_name=${APOLLO_mesos_cluster_name:-$TF_VAR_region} |
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
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
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 was deleted.
Oops, something went wrong.
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,98 @@ | ||
variable "name" { } | ||
variable "cidr" { } | ||
variable "public_subnets" { default = "" } | ||
variable "private_subnets" { default = "" } | ||
variable "bastion_instance_id" { } | ||
variable "azs" { } | ||
variable "enable_dns_hostnames" { | ||
description = "should be true if you want to use private DNS within the VPC" | ||
default = false | ||
} | ||
variable "enable_dns_support" { | ||
description = "should be true if you want to use private DNS within the VPC" | ||
default = false | ||
} | ||
|
||
# resources | ||
resource "aws_vpc" "mod" { | ||
cidr_block = "${var.cidr}" | ||
enable_dns_hostnames = "${var.enable_dns_hostnames}" | ||
enable_dns_support = "${var.enable_dns_support}" | ||
tags { | ||
Name = "${var.name}" | ||
} | ||
} | ||
|
||
resource "aws_internet_gateway" "mod" { | ||
vpc_id = "${aws_vpc.mod.id}" | ||
} | ||
|
||
resource "aws_route_table" "public" { | ||
vpc_id = "${aws_vpc.mod.id}" | ||
route { | ||
cidr_block = "0.0.0.0/0" | ||
gateway_id = "${aws_internet_gateway.mod.id}" | ||
} | ||
tags { | ||
Name = "${var.name}-public" | ||
} | ||
} | ||
|
||
resource "aws_route_table" "private" { | ||
vpc_id = "${aws_vpc.mod.id}" | ||
route { | ||
cidr_block = "0.0.0.0/0" | ||
instance_id = "${var.bastion_instance_id}" | ||
} | ||
tags { | ||
Name = "${var.name}-private" | ||
} | ||
} | ||
|
||
resource "aws_subnet" "private" { | ||
vpc_id = "${aws_vpc.mod.id}" | ||
cidr_block = "${element(split(",", var.private_subnets), count.index)}" | ||
availability_zone = "${element(split(",", var.azs), count.index)}" | ||
count = "${length(compact(split(",", var.private_subnets)))}" | ||
tags { | ||
Name = "${var.name}-private" | ||
} | ||
} | ||
|
||
resource "aws_subnet" "public" { | ||
vpc_id = "${aws_vpc.mod.id}" | ||
cidr_block = "${element(split(",", var.public_subnets), count.index)}" | ||
availability_zone = "${element(split(",", var.azs), count.index)}" | ||
count = "${length(compact(split(",", var.public_subnets)))}" | ||
tags { | ||
Name = "${var.name}-public" | ||
} | ||
|
||
map_public_ip_on_launch = true | ||
} | ||
|
||
resource "aws_route_table_association" "private" { | ||
count = "${length(compact(split(",", var.private_subnets)))}" | ||
subnet_id = "${element(aws_subnet.private.*.id, count.index)}" | ||
route_table_id = "${aws_route_table.private.id}" | ||
} | ||
|
||
resource "aws_route_table_association" "public" { | ||
count = "${length(compact(split(",", var.public_subnets)))}" | ||
subnet_id = "${element(aws_subnet.public.*.id, count.index)}" | ||
route_table_id = "${aws_route_table.public.id}" | ||
} | ||
|
||
# outputs | ||
output "private_subnets" { | ||
value = "${join(",", aws_subnet.private.*.id)}" | ||
} | ||
output "public_subnets" { | ||
value = "${join(",", aws_subnet.public.*.id)}" | ||
} | ||
output "vpc_id" { | ||
value = "${aws_vpc.mod.id}" | ||
} | ||
output "vpc_cidr_block" { | ||
value = "${aws_vpc.mod.cidr_block}" | ||
} |
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