Capture DO SSH keys in Terraform

This commit is contained in:
Jeremy Dormitzer 2020-12-21 10:42:58 -05:00
parent 5388db88ce
commit afcac2d014
5 changed files with 83 additions and 0 deletions

View File

@ -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",
]
}

View File

@ -0,0 +1,20 @@
provider "digitalocean" {
token = var.do_token
spaces_access_id = var.spaces_access_id
spaces_secret_key = var.spaces_secret_key
}
resource "digitalocean_ssh_key" "jdormit_laptop" {
name = "jdormit-laptop"
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCmtwCuxI8xP6fN9p1y+Kx7tG2appxLUTRD3yfuSiCpHEqyGy7uyY6ImbvgEc5+ZAUSwRWChFdsjUyYAq1nG2fuEyGMJxfYNyp2tJKRuJ0qBHZ8TjF4gpM5aieC6WI4Ja7x5tN+oAqQBx0UJBXQ7y3SQ9tx2rVEKGi9i9+biDFID3cukcaCVti8CEm47Z6ahJlcWQpdHxQG8SXWiL6cG89WZnkZHScuCAgEdGjq4LAYfw8XkEdphGUnqQ8Zq4PK6b8jf/F7YuhwJquRjSgXfq5amyjq6YRNIbpcq/NRnZKd1HKybAntswMz1o9vRMbx6/pt4HruE56IZA6s1t85iOPEsnYpIXd6SgHvHsN2eBhK2h0ER31YOxIzycJ8ql4OiQJMEawfkt6Bc84y1gznNqbK81R7Wgl6J7GMyl5dPlTwy3BIguFj4UcSSh5eH9jHO7wly81WzWz9M7/pYfaBaJ5au1hF423qPro9wLDmjPlOlfa9X3+C57RuVESC3KFEyutxkPye/SEKUpB526iHRYZ5F/SiqA6Zd7b9rZbT71AMwWjG2BKGImyXfKlenCRMuexsEkninJ4rPCU557/ThwFgiWtp1EHruSO26YqyJnJqXkcxpe6yk1uGneVEUAHJd1mHSie8/fTZYu9q9LqxWixdTEjOaqN9ZkZC9YsZr3iySQ== jeremy.dormitzer@gmail.com"
}
resource "digitalocean_ssh_key" "jdormit_macbook" {
name = "jdormit-macbook"
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQClncYn+vgTz6n6C99l0YMJn8PpRJGGmyvu3zje0RZeXrO+Y/7FvxWMGmVeH0oGCvDq698Rac+5JC6pZlPayqSdn56Tef7CVJsHCI9hKntTY7H3uLAJ3QjI8MbrvWUsNgBcxMkmMjx2/G/B/rDcva0yv5AOQgTYT6rC7qRQrT+jaraTVny3qTC8T+DQiLMH9tkrLySCuxm1WKf5eNg+S8VuY6iD7rXWqa5tMV+B7WY1zAa/LMkp3DBm4+NbIRgjUaWVEjIywNVgvYb+SHCwvfzM5Bx9kVi8tfiAcIZ8jDsDljTmJrtDhWiIvALfWSdjOLwCFRGp823Hbp83DIKtxnF+q/3ND4hdZd6cpy3WSfaVLR2DmFjEwVkaIBq5/8zzSfogWHjAVFDYbIhEYprg9g9lhirbLInZVpfcQgscLGvILvlyIHyAajIC3M0ZjTOn5BJ6vQYAbGtEpkGBPPc4LW/WXfNdFXGCWSzthDMPKhYlr4MxBi3rHXi1UWy5t3kb3yRHeNijd98wJLIVFMDoC5Vu/FmJDusghS+quishCj2nKFPKvNFkILLI6oPWWjnLGPQvk+KaWrsnRLeJtA7JBAemVbQWO9Nj1GGIJxfF9AGT9f320oVtEe1eJWaV9Ls49IP9dASosjZgeZgq4jjPfNbgCQOod6+0g4GE4wjZFpLvWQ== jdormitzer@BOSMM2T13LQH03Q"
}
resource "digitalocean_ssh_key" "jdormit_macbook_lola" {
name = "jdormit-macbook-lola"
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDgtweszDBXhSW3ceaTWmCc/2M6tqCNClooaOWCubdfGxw+n7mJwKmH/zXvlJaW3FYIZw9oX04FkqPPfBOP58Tr/csyjIrkbVQ4Ns1ajVvavmF3+XuzFAzJnBXHLdPdQg6ajyOWljQMr6cQYpAsEp5iMwfU4CQiUkAM3gF5Dw+Xl8uqrnhwhJmDxiSVPfdpx5eW7U07twVGYFJG6GMnEfSX6xn5b2fYqGu3wxiDrydeVHgEjc/CnrIqtEM8XFTmOjeoHpPzcDPjfE0bHOp3h2vuyWX02pJGZUFew3E883iuxutPSIQvDD+fRrWbfJ5XlGwV5lyrFe68xXU8grCWJlOZ jdormit@Jeremys-MacBook-Pro.local"
}

View File

@ -0,0 +1,11 @@
output "jdormit_laptop_ssh_key_id" {
value = digitalocean_ssh_key.jdormit_laptop.id
}
output "jdormit_macbook_ssh_key_id" {
value = digitalocean_ssh_key.jdormit_macbook.id
}
output "jdormit_macbook_lola_ssh_key_id" {
value = digitalocean_ssh_key.jdormit_macbook_lola.id
}

View File

@ -0,0 +1,18 @@
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = "~> 2.3.0"
}
}
backend "s3" {
skip_credentials_validation = true
skip_metadata_api_check = true
# Need to specify an AWS region to stop Terraform complaining
region = "us-east-1"
endpoint = "nyc3.digitaloceanspaces.com"
bucket = "jdormit-tf-state"
key = "mgmt/do-ssh-keys.tfstate"
}
}

View File

@ -0,0 +1,11 @@
variable "do_token" {
type = string
}
variable "spaces_access_id" {
type = string
}
variable "spaces_secret_key" {
type = string
}