Skip to content
This repository was archived by the owner on Jan 25, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion modules/consul-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,22 @@ resource "aws_launch_configuration" "launch_configuration" {
volume_type = var.root_volume_type
volume_size = var.root_volume_size
delete_on_termination = var.root_volume_delete_on_termination
encrypted = var.root_volume_encrypted
}


dynamic "ebs_block_device" {
for_each = var.ebs_block_devices
content {
delete_on_termination = lookup(ebs_block_device.value, "delete_on_termination", null)
device_name = lookup(ebs_block_device.value, "device_name", null)
encrypted = lookup(ebs_block_device.value, "encrypted", null)
iops = lookup(ebs_block_device.value, "iops", null)
snapshot_id = lookup(ebs_block_device.value, "snapshot_id", null)
volume_size = lookup(ebs_block_device.value, "volume_size", null)
volume_type = lookup(ebs_block_device.value, "volume_type", null)
}
}

# Important note: whenever using a launch configuration with an auto scaling group, you must set
# create_before_destroy = true. However, as soon as you set create_before_destroy = true in one resource, you must
# also set it in every resource that it depends on, or you'll get an error about cyclic dependencies (especially when
Expand Down
11 changes: 11 additions & 0 deletions modules/consul-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,17 @@ variable "root_volume_delete_on_termination" {
default = true
}

variable "root_volume_encrypted" {
description = "Encrypt the volume at rest"
default = false
}

variable "ebs_block_devices" {
description = "List of EBS volumes"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update this description as follows:

  1. Mention that this is the list of EBS volumes to create... But the user will have to attach and mount these volumes themselves: e.g., in a User Data script.
  2. Specify that the type is a map from some unique name / ID for the volume (see comment below), which is used solely in this Terraform code, and that the values are objects with the fields supported by the ebs_block_device block in aws_launch_configuration. You may want to link to the aws_launch_configuration docs too.

type = list
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a map, not a list so that (a) the for_each works and (b) each volume has a unique name/ID, so if a user removes one or adds one, it only affects that one, rather than all the items after it in a list.

default = []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment with an example of the value you can set this too.

}

variable "wait_for_capacity_timeout" {
description = "A maximum duration that Terraform should wait for ASG instances to be healthy before timing out. Setting this to '0' causes Terraform to skip all Capacity Waiting behavior."
type = string
Expand Down