Coder Social home page Coder Social logo

hansohn / terraform-digitalocean-droplet Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 183 KB

Terraform module to build a DigitalOcean droplet

License: Apache License 2.0

HCL 97.57% Makefile 2.43%
terraform terrafrom-module digitalocean digitalocean-droplets

terraform-digitalocean-droplet's Introduction

terraform-digitalocean-droplet

Terraform module to build a Digitalocean droplet

๐Ÿ“– Usage

Welcome to the terraform-digitalocean-droplet repo!

Makefile

I've included the following make targets for convenience:

Available targets:

  clean                               Clean everything
  clean/docker                        Clean docker build images
  clean/terraform                     Clean terraform generated files/directories
  docker                              Docker lint, build and run image
  docker/run                          Docker run image
  help                                Help screen
  help/all                            Display help for all targets
  help/short                          This help short screen

:octocat: Examples

Please see the sample set of examples below for a better understanding of implementation

Requirements

Name Version
terraform >= 1.0.0
cloudinit >= 2.0.0
digitalocean >= 2.0.0
http >= 3.0.0

Providers

Name Version
cloudinit >= 2.0.0
digitalocean >= 2.0.0
http >= 3.0.0

Modules

Name Source Version
igw_label cloudposse/label/null 0.25.0
private_label cloudposse/label/null 0.25.0
public_label cloudposse/label/null 0.25.0
ssh_key ./modules/ssh-key n/a
this cloudposse/label/null 0.25.0

Resources

Name Type
digitalocean_droplet.igw resource
digitalocean_droplet.private resource
digitalocean_firewall.private resource
digitalocean_firewall.public resource
digitalocean_floating_ip.igw resource
digitalocean_floating_ip_assignment.igw resource
digitalocean_loadbalancer.public resource
digitalocean_project.this resource
digitalocean_project_resources.igw_droplet resource
digitalocean_project_resources.igw_droplet_volume resource
digitalocean_project_resources.igw_floating_ip resource
digitalocean_project_resources.private_droplet resource
digitalocean_project_resources.private_droplet_voluem resource
digitalocean_volume.igw resource
digitalocean_volume.private resource
digitalocean_volume_attachment.igw resource
digitalocean_volume_attachment.private resource
digitalocean_vpc.this resource
cloudinit_config.igw data source
cloudinit_config.private data source
http_http.myip data source

Inputs

Name Description Type Default Required
additional_tag_map Additional key-value pairs to add to each map in tags_as_list_of_maps. Not added to tags or id.
This is for some rare cases where resources want additional configuration of tags
and therefore take a list of maps with tag key, value, and additional configuration.
map(string) {} no
algorithm SSH key algorithm string "RSA" no
attributes ID element. Additional attributes (e.g. workers or cluster) to add to id,
in the order they appear in the list. New attributes are appended to the
end of the list. The elements of the list are joined by the delimiter
and treated as a single ID element.
list(string) [] no
context Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as null to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional_tag_map, which are merged.
any
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"descriptor_formats": {},
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"labels_as_tags": [
"unset"
],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {},
"tenant": null
}
no
delimiter Delimiter to be used between ID elements.
Defaults to - (hyphen). Set to "" to use no delimiter at all.
string null no
descriptor_formats Describe additional descriptors to be output in the descriptors output map.
Map of maps. Keys are names of descriptors. Values are maps of the form
{<br> format = string<br> labels = list(string)<br>}
(Type is any so the map values can later be enhanced to provide additional options.)
format is a Terraform format string to be passed to the format() function.
labels is a list of labels, in order, to pass to format() function.
Label values will be normalized before being passed to format() so they will be
identical to how they appear in id.
Default is {} (descriptors output will be empty).
any {} no
ecdsa_curve (Optional) When algorithm is 'ECDSA', the name of the elliptic curve to use. May be any one of 'P224', 'P256', 'P384' or 'P521', with 'P224' as the default. string null no
enable_internet_gateway (Optional) Enable creation of Internet Gateway resources. Defaults to true. bool true no
enable_project (Optional) A boolean flag to enable/disable Project resource creation. Defaults to true. bool true no
enable_public_lb (Optional) A boolean flag to enable/disable Load Balancer resource creation. Defaults to false. bool false no
enabled Set to false to prevent the module from creating any resources bool null no
environment ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' string null no
firewall_allow_myip_ssh (Optional) Allow your external ip ssh inbound permissions to the internet gateway. bool false no
firewall_allow_myip_web (Optional) Allow your external ip port 80/443 inbound permissions to the private droplets. bool false no
generate_ssh_key If set to true, new SSH key pair will be created and ssh_public_key_file will be ignored. Conflicts with ssh_public_key_file bool false no
id_length_limit Limit id to this many characters (minimum 6).
Set to 0 for unlimited length.
Set to null for keep the existing setting, which defaults to 0.
Does not affect id_full.
number null no
igw_droplet_backups (Optional) Boolean controlling if backups are made. Defaults to false. bool null no
igw_droplet_cloudinit_parts (Optional) List of nested block types which adds a file to the generated cloud-init configuration. Use multiple part blocks to specify multiple files, which will be included in order of declaration in the final MIME document. list(any) [] no
igw_droplet_enable_bastion (Optional) Boolean controlling whether to enable bastion ssh feature on droplet bool false no
igw_droplet_enable_notifications (Optional) Boolean controlling whether to enable slack notifications. Currently this feature only applies to bastion fail2ban sshd jail notifications. bool false no
igw_droplet_image (Required) The Droplet image ID or slug. string null no
igw_droplet_ipv6 (Optional) Boolean controlling if IPv6 is enabled. Defaults to false. bool null no
igw_droplet_monitoring (Optional) Boolean controlling whether monitoring agent is installed. Defaults to false. bool true no
igw_droplet_name (Required) The Droplet name. string null no
igw_droplet_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. bool null no
igw_droplet_size (Required) The unique slug that indentifies the type of Droplet. string "s-1vcpu-1gb" no
igw_droplet_ssh_keys (Optional) A list of SSH IDs or fingerprints to enable in the format [12345, 123456]. list(string) [] no
igw_droplet_tags (Optional) A list of the tags to be applied to this Droplet. list(string) [] no
igw_droplet_volume_ids (Optional) - A list of the IDs of each block storage volume to be attached to the Droplet. list(string) null no
igw_volume_description (Optional) A free-form text field up to a limit of 1024 bytes to describe a block storage volume. string null no
igw_volume_enabled Boolean controlling whether a volume will be created and attached to the internet gateway instnace bool false no
igw_volume_initial_filesystem_label (Optional) Initial filesystem label for the block storage volume. string null no
igw_volume_initial_filesystem_type (Optional) Initial filesystem type (xfs or ext4) for the block storage volume. string null no
igw_volume_name (Required) A name for the block storage volume. Must be lowercase and be composed only of numbers, letters and '-', up to a limit of 64 characters. string null no
igw_volume_size (Required) The size of the block storage volume in GiB. If updated, can only be expanded. number null no
igw_volume_snapshot_id (Optional) The ID of an existing volume snapshot from which the new volume will be created. If supplied, the region and size will be limitied on creation to that of the referenced snapshot string null no
igw_volume_tags (Optional) A list of the tags to be applied to this Volume. list(string) [] no
label_key_case Controls the letter case of the tags keys (label names) for tags generated by this module.
Does not affect keys of tags passed in via the tags input.
Possible values: lower, title, upper.
Default value: title.
string null no
label_order The order in which the labels (ID elements) appear in the id.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present.
list(string) null no
label_value_case Controls the letter case of ID elements (labels) as included in id,
set as tag values, and output by this module individually.
Does not affect values of tags passed in via the tags input.
Possible values: lower, title, upper and none (no transformation).
Set this to title and set delimiter to "" to yield Pascal Case IDs.
Default value: lower.
string null no
labels_as_tags Set of labels (ID elements) to include as tags in the tags output.
Default is to include all labels.
Tags with empty values will not be included in the tags output.
Set to [] to suppress all generated tags.
Notes:
The value of the name tag, if included, will be the id, not the name.
Unlike other null-label inputs, the initial setting of labels_as_tags cannot be
changed in later chained modules. Attempts to change it will be silently ignored.
set(string)
[
"default"
]
no
local_download_enabled (Optional) If generate_ssh_key enabled, the key pair will be downloaded locally to the ssh_key_path bool true no
local_ssh_key_path Path to local SSH public key directory (e.g. /secrets) string null no
name ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
This is the only ID element not also included as a tag.
The "name" tag is set to the full id string. There is no tag with the value of the name input.
string null no
namespace ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique string null no
private_droplet_backups (Optional) Boolean controlling if backups are made. Defaults to false. bool null no
private_droplet_cloudinit_parts (Optional) List of nested block types which adds a file to the generated cloud-init configuration. Use multiple part blocks to specify multiple files, which will be included in order of declaration in the final MIME document. list(any) [] no
private_droplet_count (Optional) Number of private droplet instances to create. Defauts to 1. number 1 no
private_droplet_image (Required) The Droplet image ID or slug. string null no
private_droplet_ipv6 (Optional) Boolean controlling if IPv6 is enabled. Defaults to false. bool null no
private_droplet_monitoring (Optional) Boolean controlling whether monitoring agent is installed. Defaults to false. bool null no
private_droplet_name (Required) The Droplet name. string null no
private_droplet_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. bool null no
private_droplet_size (Required) The unique slug that indentifies the type of Droplet. string "s-1vcpu-1gb" no
private_droplet_ssh_keys (Optional) A list of SSH IDs or fingerprints to enable in the format [12345, 123456]. list(string) [] no
private_droplet_tags (Optional) A list of the tags to be applied to this Droplet. list(string) [] no
private_droplet_volume_ids (Optional) - A list of the IDs of each block storage volume to be attached to the Droplet. list(string) null no
private_firewall_inbound_rules (Optional) The inbound access rule block for the Firewall. list(any) [] no
private_firewall_name (Required) The Firewall name string null no
private_firewall_outbound_rules (Optional) The outbound access rule block for the Firewall. list(any) [] no
private_firewall_tags (Optional) - The names of the Tags assigned to the Firewall. list(string)
[
"private"
]
no
private_volume_description (Optional) A free-form text field up to a limit of 1024 bytes to describe a block storage volume. string null no
private_volume_enabled Boolean controlling whether a volume will be created and attached to the private instnace(s) bool false no
private_volume_initial_filesystem_label (Optional) Initial filesystem label for the block storage volume. string null no
private_volume_initial_filesystem_type (Optional) Initial filesystem type (xfs or ext4) for the block storage volume. string null no
private_volume_name (Required) A name for the block storage volume. Must be lowercase and be composed only of numbers, letters and '-', up to a limit of 64 characters. string null no
private_volume_size (Required) The size of the block storage volume in GiB. If updated, can only be expanded. number null no
private_volume_snapshot_id (Optional) The ID of an existing volume snapshot from which the new volume will be created. If supplied, the region and size will be limitied on creation to that of the referenced snapshot string null no
private_volume_tags (Optional) A list of the tags to be applied to this Volume. list(string) [] no
project_description (Optional) the description of the project string "A project to represent development resources." no
project_environment (Optional) the environment of the project's resources. The possible values are: Development, Staging, Production) string "Development" no
project_name (Optional) The name of the Project string "playground" no
project_purpose (Optional) the purpose of the project, (Default: 'Web Application') string "Web Application" no
public_firewall_inbound_rules (Optional) The inbound access rule block for the Firewall. list(any) [] no
public_firewall_name (Required) The Firewall name string null no
public_firewall_outbound_rules (Optional) The outbound access rule block for the Firewall. list(any) [] no
public_firewall_tags (Optional) - The names of the Tags assigned to the Firewall. list(string)
[
"igw"
]
no
public_lb_algorithm (Optional) 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. The default value is round_robin. string null no
public_lb_disable_lets_encrypt_dns_records (Optional) A boolean value indicating whether to disable automatic DNS record creation for Let's Encrypt certificates that are added to the load balancer. Default value is false. bool null no
public_lb_droplet_ids (Optional) - A list of the IDs of each droplet to be attached to the Load Balancer. list(string) null no
public_lb_droplet_tag (Optional) - A list of the IDs of each droplet to be attached to the Load Balancer. string null no
public_lb_enable_backend_keepalive (Optional) A boolean value indicating whether HTTP keepalive connections are maintained to target Droplets. Default value is false. bool null no
public_lb_enable_proxy_protocol (Optional) A boolean value indicating whether PROXY Protocol should be used to pass information from connecting client requests to the backend service. Default value is false. bool null no
public_lb_firewall_allow (Optional) A list of strings describing allow rules. Must be colon delimited strings of the form {type}:{source} list(string) [] no
public_lb_firewall_deny (Optional) A list of strings describing deny rules. Must be colon delimited strings of the form {type}:{source} list(string) [] no
public_lb_forwarding_rule (Required) A list of forwarding_rule to be assigned to the Load Balancer. The forwarding_rule block is documented below. list(any) [] no
public_lb_healthcheck (Optional) A healthcheck block to be assigned to the Load Balancer. The healthcheck block is documented below. Only 1 healthcheck is allowed. list(any) [] no
public_lb_http_idle_timeout_seconds (Optional) Specifies the idle timeout for HTTPS connections on the load balancer in seconds. number null no
public_lb_name (Required) The Load Balancer name. string null no
public_lb_project_id (Optional) The ID of the project that the load balancer is associated with. If no ID is provided at creation, the load balancer associates with the user's default project. string null no
public_lb_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. Default value is false. bool null no
public_lb_size (Optional) The size of the Load Balancer. It must be either lb-small, lb-medium, or lb-large. Defaults to lb-small. Only one of size or size_unit may be provided. string null no
public_lb_size_unit (Optional) The size of the Load Balancer. It must be in the range (1, 100). Defaults to 1. Only one of size or size_unit may be provided. number null no
public_lb_sticky_sessions (Optional) A sticky_sessions block to be assigned to the Load Balancer. The sticky_sessions block is documented below. Only 1 sticky_sessions block is allowed. list(any) [] no
regex_replace_chars Terraform regular expression (regex) string.
Characters matching the regex will be removed from the ID elements.
If not set, "/[^a-zA-Z0-9-]/" is used to remove all characters other than hyphens, letters and digits.
string null no
rsa_bits (Optional) When algorithm is 'RSA', the size of the generated RSA key in bits. Defaults to 2048. number null no
slack_channel (Optional) The name of the channel to be used as the destination for webhook messages. string "" no
slack_icon (Optional) Slack emoji icon to used for notifications. string "" no
slack_username (Optional) Slack username to post on behalf of for notifications. string "" no
slack_webhook_url (Optional) The Incoming Webhook URL string "" no
ssh_key_name If ssh_public_key_file and generate_ssh_key are undefined, the name of existing DigitalOcean ssh key to utilize. If ssh_public_key_file or generate_ssh_key are defined, the name to be assoicated with the ssh key in DigitalOcean string null no
ssh_public_key_file Filename (including path) of existing SSH public key file (e.g. /path/to/id_rsa.pub). Confilcts with generate_ssh_key. string null no
stage ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' string null no
tags Additional tags (e.g. {'BusinessUnit': 'XYZ'}).
Neither the tag keys nor the tag values will be modified by this module.
map(string) {} no
tenant ID element _(Rarely used, not included by default)_. A customer identifier, indicating who this instance of a resource is for string null no
vpc_description (Optional) A free-form text field up to a limit of 255 characters to describe the VPC. string null no
vpc_ip_range (Optional) The range of IP addresses for the VPC in CIDR notation. Network ranges cannot overlap with other networks in the same account and must be in range of private addresses as defined in RFC1918. It may not be larger than /16 or smaller than /24. string null no
vpc_name (Required) A name for the VPC. Must be unique and contain alphanumeric characters, dashes, and periods only. string null no
vpc_region (Required) The DigitalOcean region slug for the VPC's location. string null no

Outputs

Name Description
floating_ip_address The IP Address of the resource
floating_ip_urn The uniform resource name of the floating ip
igw_droplet_disk The size of the instance's disk in GB
igw_droplet_id The ID of the Droplet
igw_droplet_image The image of the Droplet
igw_droplet_ipv4_address The IPv4 address
igw_droplet_ipv4_address_private The IPv4 address
igw_droplet_ipv6 Is IPv6 enabled
igw_droplet_ipv6_address The IPv6 address
igw_droplet_locked The IPv4 address
igw_droplet_name The name of the Droplet
igw_droplet_price_hourly Droplet hourly price
igw_droplet_price_monthly Droplet monthly price
igw_droplet_private_networking Is private networking enabled
igw_droplet_region The region of the Droplet
igw_droplet_size The instance size
igw_droplet_status The status of the Droplet
igw_droplet_tags The tags associated with the Droplet
igw_droplet_urn The uniform resource name of the Droplet
igw_droplet_vcpus The number of the instance's virtual CPUs
igw_droplet_volume_ids A list of the attached block storage volumes
igw_volume_description Description of the volume.
igw_volume_droplet_ids A list of associated droplet ids.
igw_volume_filesystem_label Filesystem label for the block storage volume.
igw_volume_filesystem_type Filesystem type (xfs or ext4) for the block storage volume.
igw_volume_id The unique identifier for the volume.
igw_volume_initial_filesystem_label Filesystem label for the block storage volume when it was first created.
igw_volume_initial_filesystem_type Filesystem type (xfs or ext4) for the block storage volume when it was first created.
igw_volume_name Name of the volume.
igw_volume_region The region that the volume is created in.
igw_volume_snapshot_id The ID of the existing volume snapshot from which this volume was created from.
igw_volume_tags List of applied tags to the volume.
igw_volume_urn The uniform resource name for the volume.
private_droplet_disk The size of the instance's disk in GB
private_droplet_id The ID of the Droplet
private_droplet_image The image of the Droplet
private_droplet_ipv4_address The IPv4 address
private_droplet_ipv4_address_private The IPv4 address
private_droplet_ipv6 Is IPv6 enabled
private_droplet_ipv6_address The IPv6 address
private_droplet_locked The IPv4 address
private_droplet_name The name of the Droplet
private_droplet_price_hourly Droplet hourly price
private_droplet_price_monthly Droplet monthly price
private_droplet_private_networking Is private networking enabled
private_droplet_region The region of the Droplet
private_droplet_size The instance size
private_droplet_status The status of the Droplet
private_droplet_tags The tags associated with the Droplet
private_droplet_urn The uniform resource name of the Droplet
private_droplet_vcpus The number of the instance's virtual CPUs
private_droplet_volume_ids A list of the attached block storage volumes
private_firewall_created_at A time value given in ISO8601 combined date and time format that represents when the Firewall was created.
private_firewall_droplet_ids The list of the IDs of the Droplets assigned to the Firewall.
private_firewall_id A unique ID that can be used to identify and reference a Firewall.
private_firewall_name The name of the Firewall.
private_firewall_pending_changes An list of object containing the fields, 'droplet_id', 'removing', and 'status'. It is provided to detail exactly which Droplets are having their security policies updated. When empty, all changes have been successfully applied.
private_firewall_status A status string indicating the current state of the Firewall. This can be 'waiting', 'succeeded', or 'failed'.
private_firewall_tags The names of the Tags assigned to the Firewall.
private_volume_description Description of the volume.
private_volume_droplet_ids A list of associated droplet ids.
private_volume_filesystem_label Filesystem label for the block storage volume.
private_volume_filesystem_type Filesystem type (xfs or ext4) for the block storage volume.
private_volume_id The unique identifier for the volume.
private_volume_initial_filesystem_label Filesystem label for the block storage volume when it was first created.
private_volume_initial_filesystem_type Filesystem type (xfs or ext4) for the block storage volume when it was first created.
private_volume_name Name of the volume.
private_volume_region The region that the volume is created in.
private_volume_snapshot_id The ID of the existing volume snapshot from which this volume was created from.
private_volume_tags List of applied tags to the volume.
private_volume_urn The uniform resource name for the volume.
public_firewall_created_at A time value given in ISO8601 combined date and time format that represents when the Firewall was created.
public_firewall_droplet_ids The list of the IDs of the Droplets assigned to the Firewall.
public_firewall_id A unique ID that can be used to identify and reference a Firewall.
public_firewall_name The name of the Firewall.
public_firewall_pending_changes An list of object containing the fields, 'droplet_id', 'removing', and 'status'. It is provided to detail exactly which Droplets are having their security policies updated. When empty, all changes have been successfully applied.
public_firewall_status A status string indicating the current state of the Firewall. This can be 'waiting', 'succeeded', or 'failed'.
public_firewall_tags The names of the Tags assigned to the Firewall.
vpc_created_at The date and time of when the VPC was created.
vpc_default A boolean indicating whether or not the VPC is the default one for the region.
vpc_id The unique identifier for the VPC.
vpc_urn The uniform resource name (URN) for the VPC.

terraform-digitalocean-droplet's People

Contributors

dependabot[bot] avatar hansohn avatar

Stargazers

 avatar

Watchers

 avatar  avatar

terraform-digitalocean-droplet's Issues

[Feat]: add load balancer support

Contact Details

No response

Is your feature request related to a problem/challenge you are trying to solve?

no

Describe the solution you'd like

add load balancer support

Describe alternatives you've considered

No response

Additional Context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Feat]: modernize github actions

Contact Details

No response

Is your feature request related to a problem/challenge you are trying to solve?

modernize github actions

Describe the solution you'd like

modernize github actions

Describe alternatives you've considered

No response

Additional Context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.