Created
September 3, 2022 05:34
-
-
Save amaudy/f1f572c431070aa357b6938174564aec to your computer and use it in GitHub Desktop.
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
resource "digitalocean_droplet" "web" { | |
image = "ubuntu-22-04-x64" | |
name = "devbox" | |
region = "sgp1" | |
size = "s-2vcpu-4gb" | |
tags = ["devbox"] | |
lifecycle { | |
prevent_destroy = false | |
} | |
ssh_keys = [ | |
data.digitalocean_ssh_key.terraform.id | |
] | |
provisioner "remote-exec" { | |
inline = ["sudo apt update", "sudo apt install python3 -y", "echo Ready to continue"] | |
connection { | |
host = self.ipv4_address | |
type = "ssh" | |
user = "root" | |
agent = "true" | |
} | |
} | |
provisioner "local-exec" { | |
command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -u root -i '${self.ipv4_address},' setup-devbox.yml" | |
} | |
} | |
data "http" "myip" { | |
url = "http://ipv4.icanhazip.com" | |
} | |
output "droplet_ip_addresses" { | |
value = { | |
"Your Development machine IP is:" = digitalocean_droplet.web.ipv4_address | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment