Skip to content

Commit

Permalink
refactoring naming conventions for Digital Ocean
Browse files Browse the repository at this point in the history
  • Loading branch information
benny-v committed Jul 18, 2020
1 parent 7b1b584 commit da52246
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
12 changes: 6 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ resource "random_password" "cookie" {

# VPC
resource "digitalocean_vpc" "vpc" {
name = "${var.github_username}-code-server"
name = var.hostname
region = var.region
}

Expand All @@ -40,7 +40,7 @@ data "template_file" "user_data" {
# Droplet
resource "digitalocean_droplet" "droplet" {
image = "ubuntu-20-04-x64"
name = "${var.github_username}-code-server"
name = var.hostname
region = var.region
size = var.droplet_size
backups = true
Expand All @@ -52,11 +52,11 @@ resource "digitalocean_droplet" "droplet" {

# Volume
resource "digitalocean_volume" "disk" {
name = "${var.github_username}-code-server-home"
name = "${var.hostname}-home-volume"
region = var.region
size = var.storage_size
initial_filesystem_type = "ext4"
description = "persistent storage for /home on ${var.github_username}-code-server"
description = "persistent storage for /home on ${var.hostname}"
}

resource "digitalocean_volume_attachment" "disk_attachment" {
Expand All @@ -82,7 +82,7 @@ resource "digitalocean_domain" "entry" {

# Firewall
resource "digitalocean_firewall" "firewall" {
name = "${var.github_username}-code-server"
name = "${var.hostname}-firewall"

droplet_ids = ["${digitalocean_droplet.droplet.id}"]

Expand Down Expand Up @@ -124,7 +124,7 @@ resource "digitalocean_firewall" "firewall" {

# Project
resource "digitalocean_project" "project" {
name = "${var.github_username}-code-server"
name = var.hostname
resources = [
"do:domain:${digitalocean_domain.entry.id}",
"do:droplet:${digitalocean_droplet.droplet.id}",
Expand Down
6 changes: 0 additions & 6 deletions user_data.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
set -ue

# Functions
update_hostname() {
hostnamectl set-hostname ${HOSTNAME}
}

mount_home_drive() {
echo '/dev/disk/by-id/scsi-0DO_Volume_${GITHUB_USER}-code-server-home /home ext4 defaults,nofail,discard 0 0' \
| sudo tee -a /etc/fstab
Expand Down Expand Up @@ -160,8 +156,6 @@ EOF
}

main () {
update_hostname

mount_home_drive

add_user
Expand Down

0 comments on commit da52246

Please sign in to comment.