Remove DO token variable. Update readme and provisioner

This commit is contained in:
Mike Conrad
2024-09-24 21:47:59 -04:00
parent 43f6820f4a
commit cceeda2164
5 changed files with 22 additions and 9 deletions

1
.gitignore vendored
View File

@ -34,3 +34,4 @@ override.tf.json
.terraformrc .terraformrc
terraform.rc terraform.rc
tf-digitalocean*

View File

@ -1,3 +1,20 @@
# wireguard-terraform-digitalocean # wireguard-terraform-digitalocean
Example of creating a wireguard VPN on DO using Terraform. 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
```

View File

@ -1,7 +1,7 @@
# Create a new SSH key # Create a new SSH key
resource "digitalocean_ssh_key" "default" { resource "digitalocean_ssh_key" "default" {
name = "Terraform Example" 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 # Create a new Web Droplet in the nyc2 region
@ -16,11 +16,11 @@ resource "digitalocean_droplet" "web" {
host = digitalocean_droplet.web.ipv4_address host = digitalocean_droplet.web.ipv4_address
type = "ssh" type = "ssh"
user = "root" user = "root"
private_key = "${file("~/.ssh/id_rsa.pem")}" private_key = "${file("./tf-digitalocean")}"
} }
provisioner "remote-exec" { provisioner "remote-exec" {
inline = [ "cat /root/wireguard-config/client-config.conf" ] inline = [ "cat /root/wireguard-conf/client-config.conf" ]
} }
} }

View File

@ -8,6 +8,5 @@ terraform {
} }
provider "digitalocean" { provider "digitalocean" {
token = var.do_token
} }

View File

@ -1,4 +0,0 @@
variable "do_token" {
type = string
description = "Digital Ocean API token"
}