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.root}/${var.packer_manifest}" } 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" "droplet" { name = var.name image = local.packer_image region = var.region size = var.droplet_size backups = var.backups tags = var.tags 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, data.terraform_remote_state.do_ssh_keys.outputs.jdormit_macbook_spotify_ssh_key_id ] }