-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
80 lines (68 loc) · 1.56 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
resource "aws_instance" "this" {
ami = data.aws_ami.amazon-linux-2.id
instance_type = "c7g.4xlarge"
associate_public_ip_address = true
key_name = var.key_name
vpc_security_group_ids = [aws_security_group.this.id]
root_block_device {
delete_on_termination = true
encrypted = false
volume_size = 100
volume_type = "gp3"
}
user_data = local.cloud_init_content
user_data_replace_on_change = false
lifecycle {
ignore_changes = [
ami
]
}
timeouts {
create = "1m30s"
delete = "2m"
update = "2m"
}
tags = merge(
local.tags,
{
Name = "Earthly namada CI"
Module = "main"
}
)
}
resource "aws_eip_association" "eip_assoc" {
instance_id = aws_instance.this.id
allocation_id = var.eip
}
resource "random_uuid" "this" {}
locals {
cloud_init_content = templatefile("${path.module}/cloud-init.tpl", {
token = var.earthly_token
organization = var.earthly_organization
ip = var.ip
sat_name = random_uuid.this.result
})
}
resource "aws_security_group" "this" {
name = "Earthly Satellite"
description = "Security group for earthly satellite"
vpc_id = var.vpc_id
ingress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = merge(
local.tags,
{
Module = "main"
}
)
}