jdormit-infra/prod/wallabag/terraform/main.tf
2021-01-06 12:46:47 -05:00

44 lines
1.4 KiB
HCL

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" "wallabag" {
name = "wallabag"
image = local.packer_image
region = "nyc1"
size = "s-1vcpu-1gb"
backups = true
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
]
}