-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve ENG-8 "Update terraform on github to reference latest kasm ve…
…rsion (1.12)"
- Loading branch information
1 parent
db4fea9
commit 9dad1f8
Showing
128 changed files
with
5,443 additions
and
1,608 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
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 |
---|---|---|
@@ -1,29 +1,25 @@ | ||
resource "aws_instance" "kasm-agent" { | ||
count = "${var.num_agents}" | ||
ami = "${var.ec2_ami}" | ||
instance_type = "${var.agent_instance_type}" | ||
vpc_security_group_ids = ["${aws_security_group.kasm-agent-sg.id}"] | ||
subnet_id = "${aws_subnet.kasm-agent-subnet.id}" | ||
key_name = "${var.aws_key_pair}" | ||
count = var.num_agents | ||
ami = var.ec2_ami | ||
instance_type = var.agent_instance_type | ||
vpc_security_group_ids = [data.aws_security_group.data-kasm_agent_sg.id] | ||
subnet_id = data.aws_subnet.data-kasm_agent_subnet.id | ||
key_name = var.aws_key_pair | ||
|
||
root_block_device { | ||
volume_size = "50" | ||
volume_size = var.agent_hdd_size_gb | ||
} | ||
|
||
user_data = <<-EOF | ||
#!/bin/bash | ||
fallocate -l 4g /mnt/kasm.swap | ||
chmod 600 /mnt/kasm.swap | ||
mkswap /mnt/kasm.swap | ||
swapon /mnt/kasm.swap | ||
echo '/mnt/kasm.swap swap swap defaults 0 0' | tee -a /etc/fstab | ||
cd /tmp | ||
wget ${var.kasm_build} | ||
tar xvf kasm_*.tar.gz | ||
PUBLIC_DNS=(`curl -s http://169.254.169.254/latest/meta-data/public-ipv4`) | ||
bash kasm_release/install.sh -S agent -e -p $PUBLIC_DNS -m ${var.zone_name}-lb.${var.aws_domain_name} -M ${var.manager_token} | ||
EOF | ||
user_data = templatefile("${path.module}/../userdata/agent_bootstrap.sh", | ||
{ | ||
kasm_build_url = var.kasm_build | ||
swap_size = var.swap_size | ||
manager_address = var.aws_domain_name | ||
manager_token = var.manager_token | ||
} | ||
) | ||
|
||
tags = { | ||
Name = "${var.project_name}-${var.zone_name}-kasm-agent" | ||
} | ||
} | ||
} |
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,3 @@ | ||
data "aws_availability_zones" "available" { | ||
state = "available" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
#version = "4.56.0" | ||
} | ||
} | ||
} |
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,21 @@ | ||
resource "aws_route_table" "internet_access" { | ||
vpc_id = data.aws_vpc.data-kasm_agent_vpc.id | ||
|
||
route { | ||
cidr_block = var.anywhere | ||
gateway_id = data.aws_internet_gateway.data-kasm_agent_default_ig.id | ||
} | ||
|
||
tags = { | ||
Name = "${var.project_name}-kasm-agent-default-route" | ||
} | ||
} | ||
|
||
data "aws_route_table" "data-agent_internet_gateway_route_table" { | ||
route_table_id = aws_route_table.internet_access.id | ||
} | ||
|
||
resource "aws_route_table_association" "agent_table_association" { | ||
subnet_id = data.aws_subnet.data-kasm_agent_subnet.id | ||
route_table_id = data.aws_route_table.data-agent_internet_gateway_route_table.id | ||
} |
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,26 +1,30 @@ | ||
resource "aws_security_group" "kasm-agent-sg" { | ||
name = "${var.project_name}-${var.zone_name}-kasm-agent-access" | ||
description = "Allow access to agents" | ||
vpc_id = "${aws_vpc.kasm-default-vpc.id}" | ||
vpc_id = data.aws_vpc.data-kasm_agent_vpc.id | ||
|
||
ingress { | ||
from_port = 22 | ||
to_port = 22 | ||
protocol = "tcp" | ||
cidr_blocks = ["${var.ssh_access_cidr}"] | ||
cidr_blocks = var.ssh_access_cidrs | ||
} | ||
|
||
ingress { | ||
from_port = 443 | ||
to_port = 443 | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
cidr_blocks = [var.anywhere] | ||
} | ||
|
||
egress { | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
cidr_blocks = [var.anywhere] | ||
} | ||
} | ||
} | ||
|
||
data "aws_security_group" "data-kasm_agent_sg" { | ||
id = aws_security_group.kasm-agent-sg.id | ||
} |
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,9 +1,19 @@ | ||
locals { | ||
kasm_agent_vpc_subnet_cidr_mask = split("/", var.agent_vpc_cidr)[1] | ||
kasm_agent_subnet_cidr_calculation = (8 - (local.kasm_agent_vpc_subnet_cidr_mask - 16)) | ||
kasm_agent_subnet_cidr_size = local.kasm_agent_subnet_cidr_calculation < 0 ? 0 : local.kasm_agent_subnet_cidr_calculation | ||
} | ||
|
||
resource "aws_subnet" "kasm-agent-subnet" { | ||
vpc_id = "${aws_vpc.kasm-default-vpc.id}" | ||
cidr_block = "10.0.40.0/24" | ||
vpc_id = data.aws_vpc.data-kasm_agent_vpc.id | ||
cidr_block = cidrsubnet(var.agent_vpc_cidr, local.kasm_agent_subnet_cidr_size, 0) | ||
availability_zone = data.aws_availability_zones.available.names[0] | ||
map_public_ip_on_launch = true | ||
tags = { | ||
Name = "${var.project_name}-${var.zone_name}-kasm-agent-subnet" | ||
} | ||
} | ||
} | ||
|
||
data "aws_subnet" "data-kasm_agent_subnet" { | ||
id = aws_subnet.kasm-agent-subnet.id | ||
} |
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,51 +1,76 @@ | ||
variable "aws_access_key" { | ||
description = "The AWS access key used for deployment" | ||
} | ||
|
||
variable "aws_secret_key" { | ||
description = "The AWS secret key used for deployment" | ||
} | ||
|
||
variable "project_name" { | ||
description = "The name of the deployment (e.g dev, staging). A short single word" | ||
type = string | ||
} | ||
|
||
variable "aws_domain_name" { | ||
description = "The Route53 Zone used for the dns entries. This must already exist in the AWS account. (e.g dev.kasm.contoso.com). The deployment will be accessed via this zone name via https" | ||
type = string | ||
} | ||
|
||
variable "agent_vpc_cidr" { | ||
description = "Subnet CIDR range for Agent VPC" | ||
type = string | ||
} | ||
|
||
variable "swap_size" { | ||
description = "The amount of swap (in MB) to configure inside the compute instances" | ||
type = number | ||
} | ||
|
||
variable "num_agents" { | ||
description = "The number of Agent Role Servers to create in the deployment" | ||
type = number | ||
} | ||
|
||
variable "agent_instance_type" { | ||
description = "the instance type for the agents" | ||
description = "The instance type for the agents" | ||
type = string | ||
} | ||
|
||
variable "agent_hdd_size_gb" { | ||
description = "The HDD size for agents" | ||
type = number | ||
} | ||
|
||
variable "aws_region" { | ||
description = "The AWS region for the deployment. (e.g us-east-1)" | ||
type = string | ||
} | ||
|
||
variable "kasm_build" { | ||
description = "The URL for the Kasm Workspaces build" | ||
type = string | ||
} | ||
|
||
variable "zone_name" { | ||
description = "A name given to the Kasm deployment Zone" | ||
type = string | ||
} | ||
|
||
variable "aws_key_pair" { | ||
description = "The name of an aws keypair to use." | ||
type = string | ||
} | ||
|
||
variable "ec2_ami" { | ||
description = "The AMI used for the EC2 nodes. Recommended Ubuntu 18.04 LTS." | ||
description = "The AMI used for the EC2 nodes. Recommended Ubuntu 20.04 LTS." | ||
type = string | ||
} | ||
|
||
variable "manager_token" { | ||
description = "The password for the database. No special characters" | ||
type = string | ||
sensitive = true | ||
} | ||
|
||
variable "ssh_access_cidr" { | ||
variable "ssh_access_cidrs" { | ||
description = "CIDR notation of the bastion host allowed to SSH in to the machines" | ||
type = list(string) | ||
} | ||
|
||
variable "anywhere" { | ||
description = "Anywhere subnet for routing and load ingress from all IPs" | ||
type = string | ||
default = "0.0.0.0/0" | ||
} |
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,19 +1,23 @@ | ||
resource "aws_vpc" "kasm-default-vpc" { | ||
cidr_block = "10.0.0.0/16" | ||
resource "aws_vpc" "kasm-agent-vpc" { | ||
cidr_block = var.agent_vpc_cidr | ||
enable_dns_hostnames = true | ||
enable_dns_support = true | ||
tags = { | ||
Name = "${var.project_name}-${var.zone_name}-kasm-vpc" | ||
} | ||
} | ||
|
||
data "aws_vpc" "data-kasm_agent_vpc" { | ||
id = aws_vpc.kasm-agent-vpc.id | ||
} | ||
|
||
resource "aws_internet_gateway" "kasm-default-ig" { | ||
vpc_id = "${aws_vpc.kasm-default-vpc.id}" | ||
vpc_id = data.aws_vpc.data-kasm_agent_vpc.id | ||
tags = { | ||
Name = "${var.project_name}-${var.zone_name}-kasm-ig" | ||
} | ||
} | ||
|
||
resource "aws_route" "internet_access" { | ||
route_table_id = "${aws_vpc.kasm-default-vpc.main_route_table_id}" | ||
destination_cidr_block = "0.0.0.0/0" | ||
gateway_id = "${aws_internet_gateway.kasm-default-ig.id}" | ||
} | ||
data "aws_internet_gateway" "data-kasm_agent_default_ig" { | ||
internet_gateway_id = aws_internet_gateway.kasm-default-ig.id | ||
} |
Oops, something went wrong.