Load project resources from terraform remote state

This commit is contained in:
Jeremy Dormitzer 2020-12-04 09:10:23 -05:00
parent 3db3fa2399
commit cabad59c81
12 changed files with 157 additions and 57 deletions

View File

@ -0,0 +1,44 @@
data "terraform_remote_state" "jdormit_website" {
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 = "prod/jdormit-website.tfstate"
}
}
data "terraform_remote_state" "git_jeremydormitzer_com" {
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 = "prod/git-jeremydormitzer-com.tfstate"
}
}
data "terraform_remote_state" "syncthing" {
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 = "prod/syncthing.tfstate"
}
}

View File

@ -4,51 +4,6 @@ provider "digitalocean" {
spaces_secret_key = var.spaces_secret_key
}
data "terraform_remote_state" "jdormit_website" {
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 = "prod/jdormit-website.tfstate"
}
}
data "terraform_remote_state" "git_jeremydormitzer_com" {
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 = "prod/git-jeremydormitzer-com.tfstate"
}
}
data "terraform_remote_state" "syncthing" {
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 = "prod/syncthing.tfstate"
}
}
# This domain is registered via Google Domains, so the nameservers
# there need to point to DO's nameservers
resource "digitalocean_domain" "jeremydormitzer_com" {

View File

@ -0,0 +1,3 @@
output "jeremydormitzer_com_urn" {
value = digitalocean_domain.jeremydormitzer_com.urn
}

View File

@ -0,0 +1,74 @@
data "terraform_remote_state" "jdormit_website" {
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 = "prod/jdormit-website.tfstate"
}
}
data "terraform_remote_state" "git_jeremydormitzer_com" {
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 = "prod/git-jeremydormitzer-com.tfstate"
}
}
data "terraform_remote_state" "syncthing" {
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 = "prod/syncthing.tfstate"
}
}
data "terraform_remote_state" "justin_ghost_site" {
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 = "prod/justin-ghost-site.tfstate"
}
}
data "terraform_remote_state" "jeremydormitzer_com" {
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-dns.tfstate"
}
}

View File

@ -9,4 +9,12 @@ resource "digitalocean_project" "jeremy_dormitzer" {
environment = "Production"
description = "Personal infrastructure"
purpose = "Personal infrastructure"
resources = [
data.terraform_remote_state.jdormit_website.outputs.jdormit_website_urn,
data.terraform_remote_state.git_jeremydormitzer_com.outputs.git_urn,
data.terraform_remote_state.syncthing.outputs.syncthing_urn,
data.terraform_remote_state.syncthing.outputs.syncthing_volume_urn,
data.terraform_remote_state.justin_ghost_site.outputs.justin_ghost_site_urn,
data.terraform_remote_state.jeremydormitzer_com.outputs.jeremydormitzer_com_urn
]
}

View File

@ -11,7 +11,3 @@ resource "digitalocean_droplet" "git_jeremydormitzer_com" {
size = "s-1vcpu-1gb"
backups = true
}
output "git_ip_address" {
value = digitalocean_droplet.git_jeremydormitzer_com.ipv4_address
}

View File

@ -0,0 +1,7 @@
output "git_ip_address" {
value = digitalocean_droplet.git_jeremydormitzer_com.ipv4_address
}
output "git_urn" {
value = digitalocean_droplet.git_jeremydormitzer_com.urn
}

View File

@ -11,7 +11,3 @@ resource "digitalocean_droplet" "jdormit_website" {
size = "s-1vcpu-1gb"
backups = true
}
output "jdormit_website_ip_address" {
value = digitalocean_droplet.jdormit_website.ipv4_address
}

View File

@ -0,0 +1,7 @@
output "jdormit_website_ip_address" {
value = digitalocean_droplet.jdormit_website.ipv4_address
}
output "jdormit_website_urn" {
value = digitalocean_droplet.jdormit_website.urn
}

View File

@ -0,0 +1,3 @@
output "justin_ghost_site_urn" {
value = digitalocean_droplet.justin_ghost_site.urn
}

View File

@ -18,7 +18,3 @@ resource "digitalocean_volume" "syncthing_volume" {
region = "nyc1"
size = 100
}
output "syncthing_ip_address" {
value = digitalocean_droplet.jdormit_syncthing.ipv4_address
}

11
prod/syncthing/outputs.tf Normal file
View File

@ -0,0 +1,11 @@
output "syncthing_ip_address" {
value = digitalocean_droplet.jdormit_syncthing.ipv4_address
}
output "syncthing_urn" {
value = digitalocean_droplet.jdormit_syncthing.urn
}
output "syncthing_volume_urn" {
value = digitalocean_volume.syncthing_volume.urn
}