-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
97 lines (90 loc) · 2.3 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.27"
}
}
}
variable "your_region" {
type = string
description = "Which AWS Region. The options are here https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions."
}
variable "your_public_key" {
type = string
description = "This will be in ~/.ssh/id_rsa.pub by default."
}
provider "aws" {
profile = "default"
region = var.your_region
}
resource "aws_security_group" "ragedb" {
ingress {
description = "Receive SSH from everywhere."
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
description = "Receive RageDB 7243 from everywhere."
from_port = 7243
to_port = 7243
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
description = "Send everywhere."
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = "RageDB"
}
}
resource "aws_key_pair" "home" {
key_name = "Home"
public_key = var.your_public_key
}
resource "aws_instance" "ragedb" {
ami = "ami-0883f2d26628ad0cf"
associate_public_ip_address = true
cpu_core_count = 4
cpu_threads_per_core = 1
instance_type = "r5.2xlarge"
key_name = aws_key_pair.home.key_name
user_data = <<-EOF
#!/bin/bash
sudo dnf update -y
sudo dnf install -y git-all luajit perl pip
git clone https://github.com/scylladb/seastar.git
cd seastar
sudo ./install-dependencies.sh
./configure.py --mode=release --prefix=/usr/local
sudo ninja -C build/release install
cd ..
pip install --user conan
sudo ln -s ~/.local/bin/conan /usr/bin/conan
git clone https://github.com/ragedb/ragedb.git
cd ragedb
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --target ragedb
cd bin
sudo ./ragedb
EOF
tags = {
Name = "RageDB"
}
root_block_device {
volume_type = "gp2"
volume_size = 100
}
vpc_security_group_ids = [aws_security_group.ragedb.id]
}
output "instance_ip_addr" {
value = aws_instance.ragedb.public_ip
}