From cceeda2164b18b63a6ad408c327f48a9cc869da2 Mon Sep 17 00:00:00 2001 From: Mike Conrad Date: Tue, 24 Sep 2024 21:47:59 -0400 Subject: [PATCH] Remove DO token variable. Update readme and provisioner --- .gitignore | 1 + README.md | 19 ++++++++++++++++++- main.tf | 6 +++--- terraform.tf | 1 - variables.tf | 4 ---- 5 files changed, 22 insertions(+), 9 deletions(-) delete mode 100644 variables.tf diff --git a/.gitignore b/.gitignore index a9e8a0c..3947236 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ override.tf.json .terraformrc terraform.rc +tf-digitalocean* diff --git a/README.md b/README.md index 91ec133..89aeb92 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,20 @@ # wireguard-terraform-digitalocean -Example of creating a wireguard VPN on DO using Terraform. \ No newline at end of file +Example of creating a wireguard VPN on DO using Terraform. + +## Setup +First create an `ssh key` to use with this example: +```shell +ssh-keygen -t rsa -C "WireguardVPN" -f ./tf-digitalocean -q -N "" +``` + +Next export your DigitalOcean Access token: +```shell +export DIGITALOCEAN_ACCESS_TOKEN=dop_v1_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +``` + +Finally run the Terraform +```shell +terraform init +terraform apply -auto-approve +``` \ No newline at end of file diff --git a/main.tf b/main.tf index c2ef460..d9296fc 100644 --- a/main.tf +++ b/main.tf @@ -1,7 +1,7 @@ # Create a new SSH key resource "digitalocean_ssh_key" "default" { name = "Terraform Example" - public_key = file("~/.ssh/id_rsa.pub") + public_key = file("./tf-digitalocean.pub") } # Create a new Web Droplet in the nyc2 region @@ -16,11 +16,11 @@ resource "digitalocean_droplet" "web" { host = digitalocean_droplet.web.ipv4_address type = "ssh" user = "root" - private_key = "${file("~/.ssh/id_rsa.pem")}" + private_key = "${file("./tf-digitalocean")}" } provisioner "remote-exec" { - inline = [ "cat /root/wireguard-config/client-config.conf" ] + inline = [ "cat /root/wireguard-conf/client-config.conf" ] } } diff --git a/terraform.tf b/terraform.tf index a33c03c..9b91a2d 100644 --- a/terraform.tf +++ b/terraform.tf @@ -8,6 +8,5 @@ terraform { } provider "digitalocean" { - token = var.do_token } diff --git a/variables.tf b/variables.tf deleted file mode 100644 index 0068de8..0000000 --- a/variables.tf +++ /dev/null @@ -1,4 +0,0 @@ -variable "do_token" { - type = string - description = "Digital Ocean API token" -}