-
Notifications
You must be signed in to change notification settings - Fork 0
/
01-ec2.tf
74 lines (59 loc) · 1.64 KB
/
01-ec2.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
data "aws_ami" "ubuntu_22" {
most_recent = true
owners = ["099720109477"]
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-arm64-server-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
}
resource "aws_eip" "n3uron" {
instance = aws_instance.n3uron.id
}
resource "aws_instance" "n3uron" {
ami = data.aws_ami.ubuntu_22.id
instance_type = "t4g.medium"
key_name = var.key_name
vpc_security_group_ids = [aws_security_group.n3uron.id]
tags = {
Name = "sunn3rgy-eu-prod-01/n3uron"
}
root_block_device {
volume_type = "gp3"
volume_size = 10
delete_on_termination = true
}
user_data = <<-EOF
#!/bin/bash
curl -fsSL https://get.n3uron.com/install.sh | sudo bash
EOF
}
resource "aws_instance" "mongodb" {
ami = data.aws_ami.ubuntu_22.id
instance_type = "t4g.medium"
key_name = var.key_name
vpc_security_group_ids = [aws_security_group.mongodb.id]
tags = {
Name = "sunn3rgy-eu-prod-01/mongo"
}
root_block_device {
volume_type = "gp3"
volume_size = 30
delete_on_termination = true
}
user_data = <<-EOF
#!/bin/bash
# Install Docker Engine
curl -fsSL https://get.docker.com | sudo bash
docker run -d --name mongodb-1 -p 27017:27017 mongo:7
EOF
}
output "n3uron_public_address" {
value = "https://${aws_eip.n3uron.public_dns}:8443"
}
output "mongodb_connection_url" {
value = "mongodb://${aws_instance.mongodb.private_dns}:27017/history?retryWrites=true"
}