provider "digitalocean" { token = var.do_token spaces_access_id = var.spaces_access_id spaces_secret_key = var.spaces_secret_key } data "terraform_remote_state" "do_ssh_keys" { backend = "s3" config = { skip_credentials_validation = true skip_metadata_api_check = true access_key = var.spaces_access_id secret_key = var.spaces_secret_key region = "us-east-1" endpoint = "nyc3.digitaloceanspaces.com" bucket = "jdormit-tf-state" key = "mgmt/do-ssh-keys.tfstate" } } data "local_file" "packer_manifest" { filename = "${path.module}/../packer/packer-manifest.json" } locals { packer_manifest = jsondecode(data.local_file.packer_manifest.content) packer_builds = local.packer_manifest.builds packer_image_str = element(local.packer_builds, length(local.packer_builds) - 1).artifact_id packer_image = split(":", local.packer_image_str)[1] } resource "digitalocean_droplet" "syncthing" { name = "syncthing" image = local.packer_image region = "nyc1" size = "s-1vcpu-1gb" backups = true volume_ids = [digitalocean_volume.syncthing_volume.id] ssh_keys = [ data.terraform_remote_state.do_ssh_keys.outputs.jdormit_laptop_ssh_key_id, data.terraform_remote_state.do_ssh_keys.outputs.jdormit_macbook_lola_ssh_key_id ] } resource "digitalocean_volume" "syncthing_volume" { name = "syncthing-volume" description = "The volume to hold the default Sync folder" region = "nyc1" size = 100 initial_filesystem_label = "syncthing-volume" initial_filesystem_type = "ext4" lifecycle { prevent_destroy = true } }