-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaws_ec2.tf
45 lines (38 loc) · 1.4 KB
/
aws_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
# ------------------------------------------------------------------------------
# EC2 configuration
# ------------------------------------------------------------------------------
resource "aws_instance" "main" {
ami = var.ec2_ami_id
instance_type = var.ec2_instance_type
subnet_id = data.terraform_remote_state.vpc.outputs.private_subnets[0] # availability zone: a
vpc_security_group_ids = [
data.terraform_remote_state.vpc.outputs.sg_ssh_id, # SSH access
data.terraform_remote_state.vpc.outputs.sg_btc_19001_id, # bitcoin rpc
data.terraform_remote_state.vpc.outputs.sg_http_3000_id, # electrs rpc
data.terraform_remote_state.vpc.outputs.sg_http_9090_id # electrs batch api
]
iam_instance_profile = aws_iam_instance_profile.default.id
user_data = templatefile("${path.module}/templates/init-ec2.sh", {
CLUSTER_NAME = local.cluster_name
REGION = var.aws_region
CHAIN_DEVICE_NAME = "${var.bitcoin_ebs_volume_device_name}"
ELECTRS_DEVICE_NAME = "${var.electrs_ebs_volume_device_name}"
CHAIN_MOUNT_POINT = "${var.bitcoin_data_path}"
ELECTRS_MOUNT_POINT = "${var.electrs_data_path}"
})
key_name = var.ec2_ssh_key_pair_name
root_block_device {
tags = merge(
local.tags,
{
Name = "${local.node_alias}-root-disk"
}
)
}
tags = merge(
local.tags,
{
Name = local.node_alias
}
)
}