Remove DO token variable. Update readme and provisioner
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -34,3 +34,4 @@ override.tf.json
|
||||
.terraformrc
|
||||
terraform.rc
|
||||
|
||||
tf-digitalocean*
|
||||
|
19
README.md
19
README.md
@ -1,3 +1,20 @@
|
||||
# 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
|
||||
```
|
6
main.tf
6
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" ]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,5 @@ terraform {
|
||||
}
|
||||
|
||||
provider "digitalocean" {
|
||||
token = var.do_token
|
||||
}
|
||||
|
||||
|
@ -1,4 +0,0 @@
|
||||
variable "do_token" {
|
||||
type = string
|
||||
description = "Digital Ocean API token"
|
||||
}
|
Reference in New Issue
Block a user