From 9b5fd90e9f588f75c9d84d064afde2a5dd0e9a52 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Fri, 22 Jan 2021 11:42:39 -0500 Subject: [PATCH] Add "terraform" tag to terraform-created DO resources --- .../terraform/.terraform.lock.hcl | 23 +++++++++++++++++++ .../git-jeremydormitzer-com/terraform/main.tf | 1 + prod/syncthing/terraform/main.tf | 1 + terraform-modules/packer_droplet/interface.tf | 6 +++++ terraform-modules/packer_droplet/main.tf | 1 + 5 files changed, 32 insertions(+) create mode 100755 prod/git-jeremydormitzer-com/terraform/.terraform.lock.hcl diff --git a/prod/git-jeremydormitzer-com/terraform/.terraform.lock.hcl b/prod/git-jeremydormitzer-com/terraform/.terraform.lock.hcl new file mode 100755 index 0000000..f7f7ed8 --- /dev/null +++ b/prod/git-jeremydormitzer-com/terraform/.terraform.lock.hcl @@ -0,0 +1,23 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/digitalocean/digitalocean" { + version = "2.3.0" + constraints = "~> 2.3.0" + hashes = [ + "h1:Kmcj3ajzt/lSQkbQwcjzUNK2RXXcHNDCs44LfDhZnaM=", + "zh:1c0f68715cf0b84ab40ab08aa59232037325cffc2896ba109cae73c81ab021e9", + "zh:306599aec6637c92349abb069d8fea3ebac58f52f61707956320a405f57e4a84", + "zh:31db532f05e55cb52d61c12c10197dca48dc8809a4f9cc4a935d3161546968ca", + "zh:3dba438c0167e5dcf09115f8d2c33c0a821e6b27e83ec6ccaac5fcb557a50bbb", + "zh:770c906ab3eeb5c24c5b8bbcca3b18f137d5ac817bd73fa5c9146eb4a9d891d6", + "zh:9221f2d275c776382234882d534a1147db04a8be490c023eb08c9a1e579db021", + "zh:a4e25e5dd2ad06de6c7148a270b1178b6298846405ce66b9b4ca51ea35b66907", + "zh:b3c5555e0c55efaa91de245e6d69e7140665554d2365db2f664802a36b59e0a8", + "zh:c510655b6c5de0227babba5a8bb66a8c3d92af94e080ec1c39bde9509a2aa1a6", + "zh:d04a135d9bf32c1a55abaaeb719903f4f67797434dd6d9f3219245f62a9a66be", + "zh:dd5b99bec9425eb670be5d19b17336d0fa9b894649dac77eac532e4c626616f5", + "zh:e57614fb9f3fbf774a9258a197840f40d0f343e8183eef7a842286a87cfc48d7", + "zh:fee52e736edc5ef4088cedae6507790f35e4ee8a078bff1ef894a51dd65d058d", + ] +} diff --git a/prod/git-jeremydormitzer-com/terraform/main.tf b/prod/git-jeremydormitzer-com/terraform/main.tf index 119822f..1c05446 100644 --- a/prod/git-jeremydormitzer-com/terraform/main.tf +++ b/prod/git-jeremydormitzer-com/terraform/main.tf @@ -10,4 +10,5 @@ resource "digitalocean_droplet" "git_jeremydormitzer_com" { region = "nyc3" size = "s-1vcpu-1gb" backups = true + tags = ["terraform"] } diff --git a/prod/syncthing/terraform/main.tf b/prod/syncthing/terraform/main.tf index a89efca..142787f 100644 --- a/prod/syncthing/terraform/main.tf +++ b/prod/syncthing/terraform/main.tf @@ -19,6 +19,7 @@ resource "digitalocean_volume" "syncthing_volume" { size = 100 initial_filesystem_label = "syncthing-volume" initial_filesystem_type = "ext4" + tags = ["terraform"] lifecycle { prevent_destroy = true diff --git a/terraform-modules/packer_droplet/interface.tf b/terraform-modules/packer_droplet/interface.tf index 82c8d31..b56fca8 100644 --- a/terraform-modules/packer_droplet/interface.tf +++ b/terraform-modules/packer_droplet/interface.tf @@ -39,6 +39,12 @@ variable "backups" { default = true } +variable "tags" { + description = "List of tags to be applied to created resources" + type = list(string) + default = ["terraform"] +} + output "droplet_id" { description = "Droplet ID" value = digitalocean_droplet.droplet.id diff --git a/terraform-modules/packer_droplet/main.tf b/terraform-modules/packer_droplet/main.tf index bf437fd..fc439c3 100644 --- a/terraform-modules/packer_droplet/main.tf +++ b/terraform-modules/packer_droplet/main.tf @@ -36,6 +36,7 @@ resource "digitalocean_droplet" "droplet" { 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