Skip to content

Community maintained Terraform module for managing DigitalOcean Droplets and related resources

License

Notifications You must be signed in to change notification settings

js-timbirkett/terraform-digitalocean-droplet

 
 

Repository files navigation

terraform-digitalocean-droplet

Terraform module which creates Droplet(s) and optionally, Block Storage Volumes, Floating IPs, Load Balancers and DNS Records on DigitalOcean.

These types of resources are used:

Usage Examples

Some examples can be found in this repository:

Note that examples may create resources which can cost money. Run terraform destroy when you don't need these resources.

Droplet Sizes

A map of name to Droplet sizes exists to make specifying Droplet sizes simpler:

Name Droplet Size
nano s-1vcpu-1gb
micro s-2vcpu-2gb
small s-2vcpu-4gb
medium s-4vcpu-8gb
large s-6vcpu-16gb
x-large s-8vcpu-32gb
xx-large s-16vcpu-64gb
xxx-large s-24vcpu-128gb
maximum s-32vcpu-192gb

See DigitalOcean Pricing for costs.

Inputs

Name Description Type Default Required
backups (Optional) Boolean controlling if backups are made. Defaults to false. string false no
block_storage_attach (Optional) Whether to attach the volume using Terraform or not. string true no
block_storage_count (Optional) A count of block storage volume resources to create. string `` no
block_storage_filesystem_label (Optional) Initial filesystem label for the block storage volume. string data no
block_storage_filesystem_type (Optional) Initial filesystem type (xfs or ext4) for the block storage volume. string xfs no
block_storage_name (Optional) Override filesystem name for the block storage volume. string `` no
block_storage_size (Required) The size of the block storage volume in GiB. If updated, can only be expanded. string 0 no
custom_image Whether the image is custom or not (an official image) string false no
droplet_count The number of droplets / other resources to create string 1 no
droplet_name The name of the droplet. If more than one droplet it is appended with the count, examples: stg-web, stg-web-01, stg-web-02 string - yes
droplet_size the size slug of a droplet size string micro no
floating_ip (Optional) Boolean to control whether floating IPs should be created. string false no
floating_ip_assign (Optional) Boolean controlling whether floatin IPs should be assigned to instances with Terraform. string true no
floating_ip_count Number of floating IPs to create. string `` no
image_id The id of an image to use. string `` no
image_name The image name or slug to lookup. string ubuntu-18-04-x64 no
ipv6 (Optional) Boolean controlling if IPv6 is enabled. Defaults to false. string false no
loadbalancer Boolean to control whether to create a Load Balancer. string false no
loadbalancer_algorithm The load balancing algorithm used to determine which backend Droplet will be selected by a client. It must be either round_robin or least_connections. string round_robin no
loadbalancer_forwarding_rule List of forwarding_rule maps to apply to the loadbalancer. list [ { "entry_port": 80, "entry_protocol": "http", "target_port": 80, "target_protocol": "http" } ] no
loadbalancer_healthcheck A healthcheck block to be assigned to the Load Balancer. Only 1 healthcheck is allowed. map { "path": "/", "port": 80, "protocol": "http" } no
loadbalancer_name Override Load Balancer name. string `` no
loadbalancer_redirect_http_to_https (Optional) A boolean value indicating whether HTTP requests to the Load Balancer on port 80 will be redirected to HTTPS on port 443. string false no
loadbalancer_sticky_sessions A sticky_sessions block to be assigned to the Load Balancer. Only 1 sticky_sessions block is allowed. map {} no
loadbalancer_tag The name of a Droplet tag corresponding to Droplets to be assigned to the Load Balancer. string `` no
monitoring (Optional) Boolean controlling whether monitoring agent is installed. Defaults to false. string false no
number_format The number format used to output. string %02d no
private_domain (Optional) String containing the private DNS domain to create a record for the Droplets in. string `` no
private_networking (Optional) Boolean controlling if private networks are enabled. Defaults to false. string false no
public_domain (Optional) String containing the public DNS domain to create a record for the Droplets in. string `` no
region The Digitalocean datacenter to create resources in. string ams3 no
resize_disk (Optional) Boolean controlling whether to increase the disk size when resizing a Droplet. It defaults to true. When set to false, only the Droplet's RAM and CPU will be resized. Increasing a Droplet's disk size is a permanent change. Increasing only RAM and CPU is reversible. string true no
ssh_keys (Optional) A list of SSH IDs or fingerprints to enable in the format [12345, 123456]. To retrieve this info, use a tool such as curl with the DigitalOcean API, to retrieve them. list [] no
tags (Optional) A list of the tags to label this Droplet. A tag resource must exist before it can be associated with a Droplet. list [] no
user_data (Optional) A string of the desired User Data for the Droplet. string exit 0 no

Outputs

Name Description
droplet_id List of IDs of Droplets
droplet_ids List of associated Droplet IDs of Volumes
filesystem_type List of initial filesystem types of Volumes
floating_ip_address List of floating IP addresses created
image List of images of Droplets
ipv4_address List of public IPv4 addresses assigned to the Droplets
ipv4_address_private List of private IPv4 addresses assigned to the Droplets, if applicable
ipv6_address List of public IPv6 addresses assigned to the Droplets, if applicable
loadbalancer_id ID of the loadbalancer
loadbalancer_ip IP address of the loadbalancer
name List of names of Droplets
private_a List of Droplet private DNS A record FQDNs.
public_a List of Droplet public DNS A record FQDNs.
public_aaaa List of Droplet public DNS AAAA record FQDNs.
region List of regions of Droplets
size List of sizes of Droplets
tags List of tags of Droplets
volume_attachment_id List of IDs of Volume Attachments
volume_id List of IDs of Volumes

About

Community maintained Terraform module for managing DigitalOcean Droplets and related resources

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HCL 100.0%