Skip to content

Commit

Permalink
fix(records): remove hardcoded count number and pass consul version
Browse files Browse the repository at this point in the history
Closed #3

Signed-off-by: Bruce Becker <brucellino@protonmail.com>
  • Loading branch information
brucellino committed Aug 2, 2022
1 parent e20769d commit 6a539fa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ No modules.
| [digitalocean_firewall.ssh](https://registry.terraform.io/providers/digitalocean/digitalocean/2.21.0/docs/resources/firewall) | resource |
| [digitalocean_loadbalancer.external](https://registry.terraform.io/providers/digitalocean/digitalocean/2.21.0/docs/resources/loadbalancer) | resource |
| [digitalocean_project_resources.agent_droplets](https://registry.terraform.io/providers/digitalocean/digitalocean/2.21.0/docs/resources/project_resources) | resource |
| [digitalocean_project_resources.consul_volumes](https://registry.terraform.io/providers/digitalocean/digitalocean/2.21.0/docs/resources/project_resources) | resource |
| [digitalocean_project_resources.network](https://registry.terraform.io/providers/digitalocean/digitalocean/2.21.0/docs/resources/project_resources) | resource |
| [digitalocean_project_resources.server_droplets](https://registry.terraform.io/providers/digitalocean/digitalocean/2.21.0/docs/resources/project_resources) | resource |
| [digitalocean_record.server](https://registry.terraform.io/providers/digitalocean/digitalocean/2.21.0/docs/resources/record) | resource |
Expand All @@ -65,14 +64,14 @@ No modules.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_agents"></a> [agents](#input\_agents) | number of agent instances | `number` | `7` | no |
| <a name="input_consul_version"></a> [consul\_version](#input\_consul\_version) | Version of Consul to deploy | `string` | `"1.12.3"` | no |
| <a name="input_datacenter"></a> [datacenter](#input\_datacenter) | Name of the Consul datacenter | `string` | `"HashiDO"` | no |
| <a name="input_droplet_size"></a> [droplet\_size](#input\_droplet\_size) | Size of the droplet for Vault instances | `string` | `"s-1vcpu-1gb"` | no |
| <a name="input_project_name"></a> [project\_name](#input\_project\_name) | Name of the project in digitalocean | `string` | `"hashi"` | no |
| <a name="input_servers"></a> [servers](#input\_servers) | number of server instances | `number` | `3` | no |
| <a name="input_ssh_inbound_source_cidrs"></a> [ssh\_inbound\_source\_cidrs](#input\_ssh\_inbound\_source\_cidrs) | List of CIDRs from which we will allow ssh connections on port 22 | `list(any)` | `[]` | no |
| <a name="input_ssh_public_key_url"></a> [ssh\_public\_key\_url](#input\_ssh\_public\_key\_url) | URL of of the public ssh key to add to the droplet | `string` | `"https://github.com/brucellino.keys"` | no |
| <a name="input_username"></a> [username](#input\_username) | Name of the non-root user to add | `string` | `"hashiuser"` | no |
| <a name="input_vpc"></a> [vpc](#input\_vpc) | VPC we are deploying into | `string` | n/a | yes |
| <a name="input_vpc_name"></a> [vpc\_name](#input\_vpc\_name) | Name of the VPC we are deploying into | `string` | `"hashi"` | no |

## Outputs
Expand Down
13 changes: 7 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ resource "digitalocean_droplet" "agent" {
user_data = templatefile(
"${path.module}/templates/userdata.tftpl",
{
consul_version = "1.12.3"
consul_version = var.consul_version
server = false
username = var.username
datacenter = var.datacenter
Expand Down Expand Up @@ -220,7 +220,7 @@ resource "digitalocean_domain" "cluster" {
}

resource "digitalocean_record" "server" {
count = 3
count = var.servers
type = "A"
value = digitalocean_droplet.server[count.index].ipv4_address_private
name = digitalocean_droplet.server[count.index].name
Expand All @@ -236,10 +236,11 @@ resource "digitalocean_project_resources" "agent_droplets" {
resources = digitalocean_droplet.agent[*].urn
}

resource "digitalocean_project_resources" "consul_volumes" {
project = data.digitalocean_project.p.id
resources = digitalocean_volume.consul_data[*].urn
}
# resource "digitalocean_project_resources" "consul_volumes" {
# depends_on = digitalocean_project_resources.agent_droplets
# project = data.digitalocean_project.p.id
# resources = digitalocean_volume.consul_data[*].urn
# }


resource "digitalocean_project_resources" "network" {
Expand Down
16 changes: 11 additions & 5 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
# consul-digitalocean variables.tf
variable "vpc" {
type = string
description = "VPC we are deploying into"
}

variable "servers" {
type = number
default = 3
description = "number of server instances"
# validation = must be prime number less than 7
}
variable "agents" {
type = number
default = 7
description = "number of agent instances"
# validation = must be > 0
}

variable "project_name" {
Expand All @@ -31,18 +28,21 @@ variable "ssh_inbound_source_cidrs" {
type = list(any)
description = "List of CIDRs from which we will allow ssh connections on port 22"
default = []
# validation = must not be 0.0.0.0/0
}

variable "ssh_public_key_url" {
type = string
description = "URL of of the public ssh key to add to the droplet"
default = "https://github.com/brucellino.keys"
# Pre-condition in data.
}

variable "droplet_size" {
type = string
description = "Size of the droplet for Vault instances"
default = "s-1vcpu-1gb"
# validation = must be in digitalocean droplet sizes
}

variable "username" {
Expand All @@ -51,6 +51,12 @@ variable "username" {
default = "hashiuser"
}

variable "consul_version" {
description = "Version of Consul to deploy"
type = string
default = "1.12.3"
}

variable "datacenter" {
type = string
description = "Name of the Consul datacenter"
Expand Down

0 comments on commit 6a539fa

Please sign in to comment.