Skip to content

Instantly share code, notes, and snippets.

@taragurung
Created June 4, 2020 16:46
Show Gist options
  • Save taragurung/ff9a28e4270b5da6e4214c161c3ed48e to your computer and use it in GitHub Desktop.
Save taragurung/ff9a28e4270b5da6e4214c161c3ed48e to your computer and use it in GitHub Desktop.
Adding digital ocean droplet with ssh enable using terraform
# use the existing the ssh-key, these are added to digital ocean console
# check the security section, use the same name added there
data "digitalocean_ssh_key" "default" {
name = "<change-it>"
}
#Generate it from digitalocean console, make sure to pass it safely
provider "digitalocean" {
token = "<change-it>"
}
# Create a new Web Droplet in the nyc2 region
resource "digitalocean_droplet" "web" {
image = "ubuntu-18-04-x64"
name = "schoolweb"
region = "nyc1"
size = "s-1vcpu-1gb"
ssh_keys = ["${data.digitalocean_ssh_key.default.fingerprint}"] #this will allow the user to ssh.
}
#let get the public-ip of the droplet
output "controller_ip_address" {
value = digitalocean_droplet.web.ipv4_address
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment