diff --git a/docs/airgap/developer/terraform/main.tf b/docs/airgap/developer/terraform/main.tf new file mode 100644 index 0000000000000000000000000000000000000000..856f92c057f6f2fa4a0d07a0ebdab82340e88e6c --- /dev/null +++ b/docs/airgap/developer/terraform/main.tf @@ -0,0 +1,107 @@ +# Locals +locals { + az = "${format("%s%s", var.region_id, "a")}" +} + +# Provider +provider "aws" { + profile = "${var.profile_id}" + region = "${var.region_id}" +} + +# Vpc +resource "aws_vpc" "airgap_vpc" { + cidr_block = "10.0.0.0/16" + enable_dns_hostnames = true + + tags = { + Name = "${var.cluster_id}-vpc" + } +} + +# Public subnet +resource "aws_subnet" "public" { + vpc_id = "${aws_vpc.airgap_vpc.id}" + cidr_block = "10.0.0.0/24" + availability_zone = "${local.az}" + + tags = { + Name = "airgap-public-subnet" + } +} + +# Igw +resource "aws_internet_gateway" "airgap_vpc_igw" { + vpc_id = "${aws_vpc.airgap_vpc.id}" + + tags = { + Name = "airgap-igw" + } +} + +# Public route table +resource "aws_route_table" "airgap_vpc_region_public" { + vpc_id = "${aws_vpc.airgap_vpc.id}" + + route { + cidr_block = "0.0.0.0/0" + gateway_id = "${aws_internet_gateway.airgap_vpc_igw.id}" + } + + tags = { + Name = "airgap-public-rt" + } +} + +# Public route table associations +resource "aws_route_table_association" "airgap_vpc_region_public" { + subnet_id = "${aws_subnet.public.id}" + route_table_id = "${aws_route_table.airgap_vpc_region_public.id}" +} + +# Private subnet +resource "aws_subnet" "private" { + vpc_id = "${aws_vpc.airgap_vpc.id}" + cidr_block = "10.0.2.0/24" + availability_zone = "${local.az}" + + tags = { + Name = "airgap-private-subnet" + } +} + +# Private routing table +resource "aws_route_table" "airgap_vpc_region_private" { + vpc_id = "${aws_vpc.airgap_vpc.id}" + + tags = { + Name = "airgap-private-rt" + } +} + +# Private routing table association +resource "aws_route_table_association" "airgap_vpc_region_private" { + subnet_id = "${aws_subnet.private.id}" + route_table_id = "${aws_route_table.airgap_vpc_region_private.id}" +} + +# Output +output "connection_details" { + value = <<EOF + + Use the following to connect to the bootstrap node and enjoy the ride... + + ssh -J ${var.image_username}@${aws_instance.staging_instance.public_ip} ${var.image_username}@${aws_instance.bootstrap_instance.private_ip} + + EOF +} + +output "public_ip" { + description = "List of public IP addresses assigned to the instances, if applicable" + value = "${aws_instance.staging_instance.*.public_ip}" +} + +output "private_ip" { + description = "List of private IP addresses assigned to the instances, if applicable" + value = "${aws_instance.bootstrap_instance.*.private_ip}" +} diff --git a/docs/airgap/developer/terraform/variables.tf b/docs/airgap/developer/terraform/variables.tf new file mode 100644 index 0000000000000000000000000000000000000000..a2dc8a03d55e25b1e231abe4d568d66dae615d76 --- /dev/null +++ b/docs/airgap/developer/terraform/variables.tf @@ -0,0 +1,64 @@ + +# Provider id based on Mesosphere account information +variable "profile_id" { + description = "" + # Default region is default + default = "default" +} + +# AWS Region id +variable "region_id" { + description = "" + # Default region is us-gov-west-1 + default = "us-gov-west-1" +} + +# Cluster UUID +resource "random_string" "random" { + length = 4 + special = false + lower = true + upper = false +} + +# Cluster id +variable "cluster_id" { + description = "" + # Default region is airgap-???? + default = "airgap-" +} + +# ec2.tf +variable "image_id" { + description = "Amazon AWS AMI" + # default = "ami-06eeaf749779ed329" + default = "ami-06eeaf749779ed329" +} + +# ec2.tf +variable "image_username" { + description = "Amazon AWS AMI username" + default = "centos" +} + +# ec2.tf +variable "ec2_instance_type" { + description = "AWS EC2 Instance type" + # Default instance type m5.xlarge + default = "m5.xlarge" +} + +# Ssh keyname +variable "ssh_key_name" { + description = "" + # Comment + default = "airgap" +} + +# Cluster owner +#variable "owner" { +# description = "Owner of the cluster" +# # Comment +# default = "egoode" +#} +