First working version

This commit is contained in:
Jason Rothstein 2020-07-18 14:02:23 -05:00
parent 2dc844f040
commit a680939b87
15 changed files with 79 additions and 0 deletions

View File

@ -1,2 +1,15 @@
# digitalocean_droplet
## Usage
```
module "test1" {
source = "git::https://git.fdragon.com/TerraformModules/digitalocean_droplet.git"
host_name = "hello-world"
domain_name = "example.com"
ssh_keys = [
data.digitalocean_ssh_key.example.id,
]
}
```

View File

@ -0,0 +1,3 @@
data "digitalocean_domain" "this" {
name = var.domain_name
}

View File

@ -0,0 +1,3 @@
data "digitalocean_vpc" "this" {
name = var.vpc_name
}

3
output.droplet.tf Normal file
View File

@ -0,0 +1,3 @@
output "droplet" {
value = digitalocean_droplet.this
}

View File

@ -0,0 +1,12 @@
resource "digitalocean_droplet" "this" {
backups = "true"
image = var.image_name
ipv6 = "true"
monitoring = "false"
name = "${var.host_name}.${var.domain_name}"
private_networking = "true"
region = var.region
ssh_keys = var.ssh_keys
size = var.size
vpc_uuid = data.digitalocean_vpc.this.id
}

View File

@ -0,0 +1,6 @@
resource "digitalocean_record" "A" {
domain = data.digitalocean_domain.this.name
name = var.host_name
type = "A"
value = digitalocean_droplet.this.ipv4_address
}

View File

@ -0,0 +1,6 @@
resource "digitalocean_record" "AAAA" {
domain = data.digitalocean_domain.this.name
name = var.host_name
type = "AAAA"
value = digitalocean_droplet.this.ipv6_address
}

6
terraform.tf Normal file
View File

@ -0,0 +1,6 @@
terraform {
required_version = ">= 0.12"
required_providers {
digitalocean = ">= 1.18.0"
}
}

4
variable.domain_name.tf Normal file
View File

@ -0,0 +1,4 @@
variable "domain_name" {
default = "example.com"
type = string
}

4
variable.host_name.tf Normal file
View File

@ -0,0 +1,4 @@
variable "host_name" {
default = "hello-world"
type = string
}

4
variable.image_name.tf Normal file
View File

@ -0,0 +1,4 @@
variable "image_name" {
default = "fedora-32-x64"
type = string
}

4
variable.region.tf Normal file
View File

@ -0,0 +1,4 @@
variable "region" {
default = "nyc3"
type = string
}

4
variable.size.tf Normal file
View File

@ -0,0 +1,4 @@
variable "size" {
default = "s-1vcpu-1gb"
type = string
}

3
variable.ssh_keys.tf Normal file
View File

@ -0,0 +1,3 @@
variable "ssh_keys" {
type = list
}

4
variable.vpc_name.tf Normal file
View File

@ -0,0 +1,4 @@
variable "vpc_name" {
default = "nyc3"
type = string
}