Last active
September 11, 2019 19:56
-
-
Save davidlares/6d9d4ff54a55f166d873cac04472f62c to your computer and use it in GitHub Desktop.
Terraform's Digital Ocean instance configuration files with an Nginx Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apt-get update && apt-get install nginx -y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Aleatory data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| output "ip" { | |
| value = "${digitalocean_droplet.web.ipv4_address}" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| provider "digitalocean" { | |
| token = var.token | |
| } | |
| resource "digitalocean_ssh_key" "default" { | |
| name = "example" | |
| "public_key" = "${file("~/.ssh/id_rsa.pub")}" | |
| } | |
| resource "digitalocean_droplet" "web" { | |
| image = "ubuntu-18-04-x64" | |
| name = "davidDroplet" | |
| region = "nyc3" | |
| size = "s-1vcpu-1gb" | |
| ssh_keys = ["${digitalocean_ssh_key.default.fingerprint}"] | |
| connection { | |
| user = "root" | |
| type = "ssh" | |
| host = "${digitalocean_droplet.web.ipv4_address}" | |
| private_key = "${file("~/.ssh/id_rsa")}" | |
| } | |
| provisioner "remote-exec" { | |
| inline = [ | |
| "chmod +x /tmp/data.sh", | |
| "cd /tmp/ && ./data.sh" | |
| ] | |
| } | |
| provisioner "file" { | |
| source = "data.txt" | |
| destination = "/tmp/data.txt" | |
| } | |
| provisioner "file" { | |
| source = "data.sh" | |
| destination = "/tmp/data.sh" | |
| } | |
| } | |
| resource "digitalocean_domain" "default" { | |
| name = "yourdomain.com" | |
| ip_address = "${digitalocean_droplet.web.ipv4_address}" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| token = "YOUR_DIGITAL_OCEAN_API_TOKEN" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| variable "token" {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment