-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* rename aws folder to resources * update readme.md folder name
- Loading branch information
1 parent
7cefd17
commit 37bf5a6
Showing
48 changed files
with
586 additions
and
5 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,26 @@ | ||
# Data for AWS module | ||
data "aws_ami" "ubuntu_amd64" { | ||
most_recent = true | ||
|
||
filter { | ||
name = "name" | ||
values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"] | ||
} | ||
|
||
filter { | ||
name = "virtualization-type" | ||
values = ["hvm"] | ||
} | ||
|
||
filter { | ||
name = "architecture" | ||
values = ["x86_64"] | ||
} | ||
|
||
filter { | ||
name = "root-device-type" | ||
values = ["ebs"] | ||
} | ||
|
||
owners = ["099720109477"] | ||
} |
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,9 @@ | ||
terraform { | ||
cloud { | ||
organization = "subspace-sre" | ||
|
||
workspaces { | ||
name = "telemetry-aws" | ||
} | ||
} | ||
} |
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,11 @@ | ||
data "cloudflare_zone" "cloudflare_zone" { | ||
name = "subspace.network" | ||
} | ||
|
||
resource "cloudflare_record" "telemetry_subspace_node" { | ||
zone_id = data.cloudflare_zone.cloudflare_zone.id | ||
name = "${var.domain_prefix}-new" | ||
value = module.telemetry_subspace_node.public_ip | ||
type = "A" | ||
ttl = "3600" | ||
} |
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,49 @@ | ||
resource "aws_instance" "telemetry_subspace_node" { | ||
ami = data.aws_ami.ubuntu_amd64.image_id | ||
instance_type = var.instance_type | ||
subnet_id = aws_subnet.public_subnets.id | ||
availability_zone = var.azs | ||
# Security Group | ||
vpc_security_group_ids = ["${aws_security_group.telemetry-subspace-sg.id}"] | ||
# the Public SSH key | ||
key_name = var.aws_key_name | ||
associate_public_ip_address = true | ||
ebs_optimized = true | ||
ebs_block_device { | ||
device_name = "/dev/sda1" | ||
volume_size = var.telemetry-subspace-node-config.disk-volume-size | ||
volume_type = var.telemetry-subspace-node-config.disk-volume-type | ||
iops = 3000 | ||
throughput = 250 | ||
} | ||
|
||
tags = { | ||
name = "telemetry-subspace-node" | ||
role = "telemetry server" | ||
os_name = "ubuntu" | ||
os_version = "22.04" | ||
arch = "x86_64" | ||
} | ||
|
||
depends_on = [ | ||
aws_subnet.public_subnets, | ||
aws_internet_gateway.gw | ||
] | ||
|
||
lifecycle { | ||
|
||
create_before_destroy = true | ||
|
||
} | ||
|
||
# Setting up the ssh connection | ||
connection { | ||
type = "ssh" | ||
host = self.public_ip | ||
user = "ubuntu" | ||
agent = true | ||
private_key = file("${var.private_key_path}") | ||
timeout = "90s" | ||
} | ||
|
||
} |
File renamed without changes.
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,23 @@ | ||
// Output Variables | ||
|
||
output "telemetry_subspace_node_server_id" { | ||
value = aws_instance.telemetry_subspace_node.id | ||
} | ||
|
||
output "telemetry_subspace_node_public_ip" { | ||
value = aws_instance.telemetry_subspace_node.public_ip | ||
} | ||
|
||
output "telemetry_subspace_node_private_ip" { | ||
value = aws_instance.telemetry_subspace_node.private_ip | ||
} | ||
|
||
output "telemetry_subspace_node_ami" { | ||
value = aws_instance.telemetry_subspace_node.ami | ||
} | ||
|
||
output "dns-records" { | ||
value = [ | ||
cloudflare_record.telemetry_subspace_node.hostname, | ||
] | ||
} |
File renamed without changes.
File renamed without changes.
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,27 @@ | ||
#!/bin/sh | ||
|
||
# updates | ||
export DEBIAN_FRONTEND=noninteractive | ||
sudo apt update -y | ||
|
||
#install nginx, certbot and base packages | ||
sudo apt install curl git openssl gnupg --no-install-recommends -y | ||
|
||
# install docker & Docker Compose | ||
sudo install -m 0755 -d /etc/apt/keyrings | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --yes --dearmor -o /etc/apt/keyrings/docker.gpg | ||
sudo chmod a+r /etc/apt/keyrings/docker.gpg | ||
|
||
echo \ | ||
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ | ||
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ | ||
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | ||
sudo apt update -y | ||
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y | ||
|
||
# set max socket connections | ||
if ! (grep -iq "net.core.somaxconn" /etc/sysctl.conf && sed -i 's/.*net.core.somaxconn.*/net.core.somaxconn=65535/' /etc/sysctl.conf); then | ||
sudo echo "net.core.somaxconn=65535" >> /etc/sysctl.conf | ||
fi | ||
|
||
sudo sysctl -p /etc/sysctl.conf |
File renamed without changes.
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,24 @@ | ||
module "telemetry" { | ||
source = "../../base/" | ||
path_to_scripts = "../../base/scripts" | ||
path_to_configs = "../../base/config" | ||
|
||
telemetry-subspace-node-config = { | ||
domain-prefix = "telemetry" | ||
instance-type = var.instance_type | ||
deployment-version = 1 | ||
regions = var.aws_region | ||
instance-count = var.instance_count | ||
disk-volume-size = var.disk_volume_size | ||
disk-volume-type = var.disk_volume_type | ||
} | ||
|
||
cloudflare_api_token = var.cloudflare_api_token | ||
cloudflare_email = var.cloudflare_email | ||
access_key = var.access_key | ||
secret_key = var.secret_key | ||
vpc_id = var.vpc_id | ||
instance_type = var.instance_type | ||
vpc_cidr_block = var.vpc_cidr_block | ||
public_subnet_cidrs = var.public_subnet_cidrs | ||
} |
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,9 @@ | ||
output "telemetry_subspace_node_ipv4_addresses" { | ||
value = module.telemetry.*.telemetry_subspace_node_public_ip | ||
description = "telemetry node IPv4 Addresses" | ||
} | ||
|
||
output "dns-records" { | ||
value = module.telemetry.*.dns-records | ||
description = "DNS records" | ||
} |
File renamed without changes.
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,80 @@ | ||
variable "instance_type" { | ||
default = "m6a.4xlarge" | ||
type = string | ||
} | ||
|
||
variable "vpc_id" { | ||
default = "telemetry-vpc" | ||
type = string | ||
} | ||
|
||
variable "vpc_cidr_block" { | ||
type = string | ||
} | ||
|
||
variable "azs" { | ||
type = string | ||
description = "Availability Zones" | ||
default = "us-west-2c" | ||
} | ||
|
||
variable "instance_count" { | ||
type = number | ||
default = 1 | ||
} | ||
|
||
variable "aws_region" { | ||
description = "aws region" | ||
type = string | ||
default = "us-west-2" | ||
} | ||
|
||
variable "public_subnet_cidrs" { | ||
type = string | ||
description = "Public Subnet CIDR values" | ||
default = "172.31.1.0/24" | ||
} | ||
|
||
variable "disk_volume_size" { | ||
type = number | ||
} | ||
|
||
variable "disk_volume_type" { | ||
type = string | ||
default = "gp3" | ||
} | ||
|
||
variable "secret_key" { | ||
type = string | ||
sensitive = true | ||
} | ||
|
||
variable "access_key" { | ||
type = string | ||
sensitive = true | ||
} | ||
|
||
variable "aws_key_name" { | ||
default = "deployer" | ||
type = string | ||
} | ||
|
||
variable "ssh_user" { | ||
default = "ubuntu" | ||
type = string | ||
} | ||
|
||
variable "private_key_path" { | ||
type = string | ||
default = "~/.ssh/deployer.pem" | ||
} | ||
|
||
variable "cloudflare_email" { | ||
type = string | ||
description = "cloudflare email address" | ||
} | ||
|
||
variable "cloudflare_api_token" { | ||
type = string | ||
description = "cloudflare api token" | ||
} |
File renamed without changes.
Oops, something went wrong.