Create digitalocean host and key.
This module creates one new ssh key for all hosts.
Key name ${var.resource_prefix}-key
. Host name ${var.resource_prefix}-X
, where X is the index of droplet_count
.
Variable resource_prefix
divides resources on the provider. Avoid coincidences!
Set environment variables DIGITALOCEAN_TOKEN
or DIGITALOCEAN_ACCESS_TOKEN
.
Use this module in your tf file:
module "do" {
source = "git::https://github.com/a-kataev/terraform-modules.git//digitalocean"
resource_prefix = "new"
droplet_count = 1
droplet_region = "fra1"
droplet_size = "s-1vcpu-1gb"
droplet_image = "ubuntu-20-04-x64"
}
output "do_ip_adresses" {
value = module.do.host.*.ipv4_address
}
Update provider plugins:
$ terraform init
Apply changes:
$ terraform apply
Look at output variable:
...
Outputs:
do_ip_adresses = [
"111.122.133.144",
]
...
terraform >= 0.12