Skip to content

Commit

Permalink
Merge pull request #9 from rhythmictech/ebs-support
Browse files Browse the repository at this point in the history
Added EBS support
  • Loading branch information
kmackowick authored May 18, 2022
2 parents 80bdf1b + 8d9c9ed commit d73f4c2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
33 changes: 33 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,42 @@ resource "aws_instance" "instance" {
user_data = var.userdata_script
vpc_security_group_ids = compact(concat([local.instance_sg], var.security_groups))

dynamic "ebs_block_device" {
for_each = var.ebs_block_device
content {
delete_on_termination = lookup(ebs_block_device.value, "delete_on_termination", null)
device_name = ebs_block_device.value.device_name
encrypted = lookup(ebs_block_device.value, "encrypted", null)
iops = lookup(ebs_block_device.value, "iops", null)
kms_key_id = lookup(ebs_block_device.value, "kms_key_id", 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)
throughput = lookup(ebs_block_device.value, "throughput", null)

tags = merge(
var.tags,
{
"Name" = var.name
}
)
}
}

root_block_device {
delete_on_termination = true
encrypted = true
iops = var.volume_iops
throughput = var.volume_throughput
volume_size = var.volume_size
volume_type = var.volume_type

tags = merge(
var.tags,
{
"Name" = var.name
}
)
}

tags = merge(
Expand All @@ -220,6 +249,10 @@ resource "aws_instance" "instance" {
"Name" = var.name
},
)

lifecycle {
ignore_changes = [ebs_block_device]
}
}

##########################################
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ variable "create" {
default = true
}

variable "ebs_block_device" {
description = "Additional EBS block devices to attach to the instance"
type = list(map(string))
default = []
}

variable "env" {
description = "Name of the environment the Instance will be in."
type = string
Expand Down

0 comments on commit d73f4c2

Please sign in to comment.