From 63569df0973ddc0432fc5b91a94b3ba601c8c617 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Fri, 13 Dec 2019 17:07:31 +0200 Subject: [PATCH] Added monkey maker env that's responsible for monkey building islands --- envs/monkey_maker/aws_keys/.gitignore | 4 ++ envs/monkey_maker/terraform/config.tf | 5 ++ envs/monkey_maker/terraform/infra.tf | 68 ++++++++++++++++++++++++ envs/monkey_maker/terraform/instances.tf | 25 +++++++++ 4 files changed, 102 insertions(+) create mode 100644 envs/monkey_maker/aws_keys/.gitignore create mode 100644 envs/monkey_maker/terraform/config.tf create mode 100644 envs/monkey_maker/terraform/infra.tf create mode 100644 envs/monkey_maker/terraform/instances.tf diff --git a/envs/monkey_maker/aws_keys/.gitignore b/envs/monkey_maker/aws_keys/.gitignore new file mode 100644 index 000000000..5e7d2734c --- /dev/null +++ b/envs/monkey_maker/aws_keys/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/envs/monkey_maker/terraform/config.tf b/envs/monkey_maker/terraform/config.tf new file mode 100644 index 000000000..9884c24a2 --- /dev/null +++ b/envs/monkey_maker/terraform/config.tf @@ -0,0 +1,5 @@ +provider "aws" { + version = "~> 2.0" + region = "eu-central-1" + shared_credentials_file = "../aws_keys/accessKeys" +} diff --git a/envs/monkey_maker/terraform/infra.tf b/envs/monkey_maker/terraform/infra.tf new file mode 100644 index 000000000..bae2219c9 --- /dev/null +++ b/envs/monkey_maker/terraform/infra.tf @@ -0,0 +1,68 @@ +resource "aws_vpc" "monkey_maker" { + cidr_block = "10.0.0.0/24" + enable_dns_support = true + tags = { + Name = "monkey_maker_vpc" + } +} + +resource "aws_internet_gateway" "monkey_maker_gateway" { + vpc_id = "${aws_vpc.monkey_maker.id}" + + tags = { + Name = "monkey_maker_gateway" + } +} + +// create routing table which points to the internet gateway +resource "aws_route_table" "monkey_maker_route" { + vpc_id = "${aws_vpc.monkey_maker.id}" + + route { + cidr_block = "0.0.0.0/0" + gateway_id = "${aws_internet_gateway.monkey_maker_gateway.id}" + } + + tags = { + Name = "monkey_maker_route" + } +} + +// associate the routing table with the subnet +resource "aws_route_table_association" "subnet-association" { + subnet_id = "${aws_subnet.main.id}" + route_table_id = "${aws_route_table.monkey_maker_route.id}" +} + +resource "aws_subnet" "main" { + vpc_id = "${aws_vpc.monkey_maker.id}" + cidr_block = "10.0.0.0/24" + + tags = { + Name = "Main" + } +} + +resource "aws_security_group" "monkey_maker_sg" { + name = "monkey_maker_sg" + description = "Allow remote access to the island" + vpc_id = "${aws_vpc.monkey_maker.id}" + + ingress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + } + + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + } + + tags = { + Name = "monkey_maker_sg" + } +} diff --git a/envs/monkey_maker/terraform/instances.tf b/envs/monkey_maker/terraform/instances.tf new file mode 100644 index 000000000..a7dec7ab1 --- /dev/null +++ b/envs/monkey_maker/terraform/instances.tf @@ -0,0 +1,25 @@ +resource "aws_instance" "island_windows" { + ami = "ami-09fe2745618d2af42" + instance_type = "t2.micro" + private_ip = "10.0.0.251" + subnet_id = "${aws_subnet.main.id}" + key_name = "monkey_maker" + tags = { + Name = "monkey_maker_windows" + } + vpc_security_group_ids = ["${aws_security_group.monkey_maker_sg.id}"] + associate_public_ip_address = true +} + +resource "aws_instance" "island_linux_64" { + ami = "ami-050a22b7e0cf85dd0" + instance_type = "t2.micro" + private_ip = "10.0.0.252" + subnet_id = "${aws_subnet.main.id}" + key_name = "monkey_maker" + tags = { + Name = "monkey_maker_linux_64" + } + vpc_security_group_ids = ["${aws_security_group.monkey_maker_sg.id}"] + associate_public_ip_address = true +}