├── provider.tf
├── outputs.tf
├── images
├── ec2.png
├── pool.png
├── xmr.png
└── cpu_usage.png
├── vars.tf
├── .gitignore
├── license
├── main.tf
├── .terraform.lock.hcl
├── README.md
└── xmrig
└── run-xmrig.sh
/provider.tf:
--------------------------------------------------------------------------------
1 | provider "aws" {
2 | region = var.region
3 | }
--------------------------------------------------------------------------------
/outputs.tf:
--------------------------------------------------------------------------------
1 | output "xmr_miners" {
2 | value = aws_instance.xmr-miner.*.arn
3 | }
--------------------------------------------------------------------------------
/images/ec2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/R3DRUN3/aws-monero-mining/HEAD/images/ec2.png
--------------------------------------------------------------------------------
/images/pool.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/R3DRUN3/aws-monero-mining/HEAD/images/pool.png
--------------------------------------------------------------------------------
/images/xmr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/R3DRUN3/aws-monero-mining/HEAD/images/xmr.png
--------------------------------------------------------------------------------
/images/cpu_usage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/R3DRUN3/aws-monero-mining/HEAD/images/cpu_usage.png
--------------------------------------------------------------------------------
/vars.tf:
--------------------------------------------------------------------------------
1 |
2 | variable "ec2_ami" {
3 | type = map
4 |
5 | default = {
6 | # change ami here if you want
7 | eu-central-1 = "ami-0caef02b518350c8b"
8 | }
9 | }
10 |
11 | # Change default region here if you want
12 |
13 | variable "region" {
14 | default = "eu-central-1"
15 | }
16 |
17 |
18 | # Creating a Variable for instance_type
19 | variable "instance_type" {
20 | type = string
21 | }
22 |
23 | variable "instance_count" {
24 | # change the number of instances here
25 | default = "2"
26 | }
27 |
28 | variable "ip_list" {
29 | description = "Allowed IPs"
30 | type = list(string)
31 | default = [
32 | "0.0.0.0/0",
33 | ]
34 | }
35 |
36 | variable "port_list" {
37 | description = "Allowed ports"
38 | type = list(number)
39 | default = [
40 | 22, # only allow ssh connection
41 | ]
42 | }
43 |
44 | variable "sec_group_name" {
45 | default = "XMR Miners"
46 | }
47 |
48 | variable "sec_group_description" {
49 | default = "XMR Miners Security Group"
50 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Local .terraform directories
2 | **/.terraform/*
3 |
4 | # .tfstate files
5 | *.tfstate
6 | *.tfstate.*
7 |
8 | # Crash log files
9 | crash.log
10 | crash.*.log
11 |
12 | # Exclude all .tfvars files, which are likely to contain sensitive data, such as
13 | # password, private keys, and other secrets. These should not be part of version
14 | # control as they are data points which are potentially sensitive and subject
15 | # to change depending on the environment.
16 | *.tfvars
17 | *.tfvars.json
18 |
19 | # Ignore override files as they are usually used to override resources locally and so
20 | # are not checked in
21 | override.tf
22 | override.tf.json
23 | *_override.tf
24 | *_override.tf.json
25 |
26 | # Include override files you do wish to add to version control using negated pattern
27 | # !example_override.tf
28 |
29 | # Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
30 | # example: *tfplan*
31 |
32 | # Ignore CLI configuration files
33 | .terraformrc
34 | terraform.rc
--------------------------------------------------------------------------------
/license:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 R3DRUN3
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/main.tf:
--------------------------------------------------------------------------------
1 | resource "aws_instance" "xmr-miner" {
2 | # Creates n identical aws ec2 instances for xmr mining
3 | count = var.instance_count
4 |
5 | ami = lookup(var.ec2_ami,var.region)
6 | instance_type = var.instance_type
7 | tags = {
8 |
9 | Name = "xmr-miner-${count.index}"
10 | }
11 | security_groups = [
12 | var.sec_group_name,
13 | ]
14 | vpc_security_group_ids = [
15 | aws_security_group.miners.id,
16 | ]
17 | user_data = "${file("./xmrig/run-xmrig.sh")}"
18 | }
19 |
20 | resource "aws_security_group" "miners" {
21 | description = var.sec_group_description
22 | egress = [
23 | {
24 | cidr_blocks = [
25 | "0.0.0.0/0",
26 | ]
27 | description = ""
28 | from_port = 0
29 | ipv6_cidr_blocks = []
30 | prefix_list_ids = []
31 | protocol = "-1"
32 | security_groups = []
33 | self = false
34 | to_port = 0
35 | },
36 | ]
37 | ingress = [
38 | for _port in var.port_list:
39 | {
40 | cidr_blocks = [
41 | for _ip in var.ip_list:
42 | _ip
43 | ]
44 | description = ""
45 | from_port = _port
46 | ipv6_cidr_blocks = []
47 | prefix_list_ids = []
48 | protocol = "tcp"
49 | security_groups = []
50 | self = false
51 | to_port = _port
52 | }
53 | ]
54 | name = var.sec_group_name
55 | }
--------------------------------------------------------------------------------
/.terraform.lock.hcl:
--------------------------------------------------------------------------------
1 | # This file is maintained automatically by "terraform init".
2 | # Manual edits may be lost in future updates.
3 |
4 | provider "registry.terraform.io/hashicorp/aws" {
5 | version = "4.39.0"
6 | hashes = [
7 | "h1:tM2mSfH03Ert/Qd+EUMIavtwjPCM/no91VBH/8vobCE=",
8 | "zh:08e3d453bbeaccda3f4ab7ae45f81d515ab49a765ce2d43f060842bb2e653846",
9 | "zh:238a460231e9e6ca786b2cb2088a98edfc48f0e36c433edd7d65a250980f7566",
10 | "zh:4d5663c2cf521e91caddd5508b13759110bc21b2e9543ff6a9f8cf8d02af1aeb",
11 | "zh:5b397e46aac6db155b4b9162ac168010473d6309ae363301f0335184c1f50be6",
12 | "zh:7178536cfebc6423336798aead72fe774f4d8118ae19ffe6a6a1108fe60608d7",
13 | "zh:867c5269cea2fe15f7ea837507ad0fe97e8913be4348868b284c12217d689457",
14 | "zh:88db4bb188f68011cb05eefb3ea7e5741da1d9acdb3c7bd517e715dfc8c0cfc3",
15 | "zh:95b4da4bdbb2eb02333e52c2ced0c5f133d854f730e3744c0c239268c21feee6",
16 | "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425",
17 | "zh:9bbe67eaa03bfb293913431b39879385e42473bdb61be842fd78b3c89333f1ba",
18 | "zh:a06b9b5fbe8c84a0da431a22d9dd583143406846c1d8febe06f62fc89aeccd1d",
19 | "zh:cb925338b164e916f289e717f8ecaacf5fd5df56790ec6296158e76d6131b914",
20 | "zh:d9dbf68b0defc220085eda1348f439f724ce83a0636bec18dc83aa73fe2385d5",
21 | "zh:eb59e6234e73bd0d48fe372201155802c9b920711a1da078e5b07508271312ee",
22 | "zh:f68b2685ee86bcf314d74a20e97b5cbe0c63741827143f7a4ba7ec56555329dc",
23 | ]
24 | }
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AWS MONERO MINING
2 |
3 | `Terraform` script to start one or more *EC2* monero-mining (`XMRIG`) instances. ⛏️ 🪙 ☁️
4 |
5 |