Skip to content

Commit d577f79

Browse files
committed
WIP prototyping access to the clones over SSL
1 parent 76ae105 commit d577f79

File tree

4 files changed

+65
-4
lines changed

4 files changed

+65
-4
lines changed

api_ssl_endpoint.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
# Create the Load Balancer for only the main DLE API
1111
resource "aws_lb" "dle_api_lb" {
12-
name = "dle-api-lb"
12+
name = "dle-api-lb-${var.dns_api_subdomain}"
1313
load_balancer_type = "application"
1414
security_groups = [aws_security_group.dle_api_sg.id]
1515

clones_dns.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
resource "aws_route53_record" "dblab_clones_subdomain" {
2+
name = "${var.dns_api_subdomain}-engine"
3+
type = "CNAME"
4+
5+
# TODO -- Allocate an Elastic IP address for the instance rather than using the
6+
# default assigned public DNS which can rotate
7+
records = [
8+
aws_instance.aws_ec2.public_dns
9+
]
10+
11+
zone_id = data.aws_route53_zone.dblab_zone.zone_id
12+
ttl = "60"
13+
}

dle-logical-init.sh.tpl

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -x
44

5-
disks=(${dle_disks})
5+
disks=(${dle_disks})
66
for i in $${!disks[@]}; do
77
sudo zpool create -f \
88
-O compression=on \
@@ -11,10 +11,10 @@ for i in $${!disks[@]}; do
1111
-O logbias=throughput \
1212
-m /var/lib/dblab/dblab_pool_0$i\
1313
dblab_pool_0$i \
14-
$${disks[$i]}
14+
$${disks[$i]}
1515
done
1616

17-
mkdir ~/.dblab
17+
mkdir ~/.dblab
1818
cp /home/ubuntu/.dblab/config.example.logical_generic.yml ~/.dblab/server.yml
1919
sed -ri "s/^(\s*)(debug:.*$)/\1debug: ${dle_debug}/" ~/.dblab/server.yml
2020
sed -ri "s/^(\s*)(timetable:.*$)/\1timetable: \"${dle_timetable}\"/" ~/.dblab/server.yml
@@ -47,6 +47,36 @@ for i in {1..300}; do
4747
sleep 1
4848
done
4949

50+
### Setup cert for SSH login
51+
sudo snap install --classic certbot
52+
sudo ln -s /snap/bin/certbot /usr/bin/certbot
53+
sudo certbot certonly --standalone -d ${var.dns_api_subdomain}-engine
54+
55+
####################################################################
56+
## This file should be written to:
57+
## /etc/letsencrypt/renewal-hooks/deploy/postgresql.deploy
58+
####################################################################
59+
# #!/bin/bash
60+
# umask 0177
61+
# export DOMAIN=example.com
62+
# export DATA_DIR=/var/lib/pgsql/data
63+
# cp /etc/letsencrypt/live/$DOMAIN/fullchain.pem $DATA_DIR/server.crt
64+
# cp /etc/letsencrypt/live/$DOMAIN/privkey.pem $DATA_DIR/server.key
65+
# chown postgres:postgres $DATA_DIR/server.crt $DATA_DIR/server.key
66+
67+
# Then make the above file executable so that certbot copies over new certs
68+
# sudo chmod +x /etc/letsencrypt/renewal-hooks/deploy/postgresql.deploy
69+
70+
## change postgresql.conf to have:
71+
# # - SSL -
72+
# ssl = on
73+
# ssl_cert_file = 'server.crt'
74+
# ssl_key_file = 'server.key'
75+
# ssl_prefer_server_ciphers = on
76+
77+
## change pg_hba.conf to have:
78+
# hostssl all all 0.0.0.0/0 md5
79+
5080
dblab init \
5181
--environment-id=tutorial \
5282
--url=http://localhost:2345 \

security.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,24 @@ resource "aws_security_group_rule" "dle_instance_api" {
3939
source_security_group_id = aws_security_group.dle_api_sg.id
4040
}
4141

42+
resource "aws_security_group_rule" "dle_instance_http_cert_auth" {
43+
security_group_id = aws_security_group.dle_instance_sg.id
44+
type = "ingress"
45+
from_port = 80
46+
to_port = 80
47+
protocol = "tcp"
48+
cidr_blocks = ["0.0.0.0/0"]
49+
}
50+
51+
resource "aws_security_group_rule" "dle_instance_clones" {
52+
security_group_id = aws_security_group.dle_instance_sg.id
53+
type = "ingress"
54+
from_port = 6000
55+
to_port = 6999
56+
protocol = "tcp"
57+
cidr_blocks = "${var.allow_ssh_from_cidrs}"
58+
}
59+
4260
resource "aws_security_group_rule" "dle_instance_egress" {
4361
security_group_id = aws_security_group.dle_instance_sg.id
4462
type = "egress"

0 commit comments

Comments
 (0)