diff --git a/.gitignore b/.gitignore index a3d7314..4058a64 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *.tfstate* .terraform/ spec/reports/* + +.idea/ \ No newline at end of file diff --git a/group/asg/main.tf b/group/asg/main.tf index 50979db..3c2ec2e 100644 --- a/group/asg/main.tf +++ b/group/asg/main.tf @@ -5,13 +5,13 @@ locals { default_asg_tags = [ { key = "application" - value = "${var.stack_item_fullname}" + value = var.stack_item_fullname propagate_at_launch = true }, { key = "Name" - value = "${length(var.asg_name_override) > 0 ? var.asg_name_override : var.stack_item_label}" - propagate_at_launch = "${var.propagate_name_at_launch}" + value = length(var.asg_name_override) > 0 ? var.asg_name_override : var.stack_item_label + propagate_at_launch = var.propagate_name_at_launch }, { key = "managed_by" @@ -22,54 +22,55 @@ locals { } resource "aws_autoscaling_group" "asg" { - count = "${length(var.min_elb_capacity) > 0 || length(var.wait_for_elb_capacity) > 0 ? 0 : 1}" + count = length(var.min_elb_capacity) > 0 || length(var.wait_for_elb_capacity) > 0 ? 0 : 1 - default_cooldown = "${length(var.default_cooldown) > 0 ? var.default_cooldown : "300"}" - desired_capacity = "${length(var.desired_capacity) > 0 ? var.desired_capacity : var.min_size}" - enabled_metrics = ["${compact(var.enabled_metrics)}"] - force_delete = "${var.force_delete}" - health_check_grace_period = "${length(var.hc_grace_period) > 0 ? var.hc_grace_period : "300"}" + default_cooldown = length(var.default_cooldown) > 0 ? var.default_cooldown : "300" + desired_capacity = length(var.desired_capacity) > 0 ? var.desired_capacity : var.min_size + enabled_metrics = compact(var.enabled_metrics) + force_delete = var.force_delete + health_check_grace_period = length(var.hc_grace_period) > 0 ? var.hc_grace_period : "300" health_check_type = "EC2" - launch_configuration = "${var.lc_id}" - max_size = "${var.max_size}" - metrics_granularity = "${var.metrics_granularity}" - min_size = "${var.min_size}" - name = "${length(var.asg_name_override) > 0 ? var.asg_name_override : var.stack_item_label}" - placement_group = "${var.placement_group}" - protect_from_scale_in = "${var.protect_from_scale_in}" - suspended_processes = ["${compact(var.suspended_processes)}"] - target_group_arns = ["${compact(var.target_group_arns)}"] - termination_policies = ["${compact(var.termination_policies)}"] - vpc_zone_identifier = ["${compact(var.subnets)}"] - wait_for_capacity_timeout = "${length(var.wait_for_capacity_timeout) > 0 ? var.wait_for_capacity_timeout : "10m"}" + launch_configuration = var.lc_id + max_size = var.max_size + metrics_granularity = var.metrics_granularity + min_size = var.min_size + name = length(var.asg_name_override) > 0 ? var.asg_name_override : var.stack_item_label + placement_group = var.placement_group + protect_from_scale_in = var.protect_from_scale_in + suspended_processes = compact(var.suspended_processes) + target_group_arns = compact(var.target_group_arns) + termination_policies = compact(var.termination_policies) + vpc_zone_identifier = compact(var.subnets) + wait_for_capacity_timeout = length(var.wait_for_capacity_timeout) > 0 ? var.wait_for_capacity_timeout : "10m" - tags = "${concat(local.default_asg_tags, var.additional_asg_tags)}" + tags = concat(local.default_asg_tags, var.additional_asg_tags) } resource "aws_autoscaling_group" "asg_elb" { - count = "${length(var.min_elb_capacity) > 0 || length(var.wait_for_elb_capacity) > 0 ? 1 : 0}" + count = length(var.min_elb_capacity) > 0 || length(var.wait_for_elb_capacity) > 0 ? 1 : 0 - default_cooldown = "${length(var.default_cooldown) > 0 ? var.default_cooldown : "300"}" - desired_capacity = "${length(var.desired_capacity) > 0 ? var.desired_capacity : var.min_size}" - enabled_metrics = ["${compact(var.enabled_metrics)}"] - force_delete = "${var.force_delete}" - health_check_grace_period = "${length(var.hc_grace_period) > 0 ? var.hc_grace_period : "300"}" - health_check_type = "${length(var.hc_check_type) > 0 ? var.hc_check_type : "ELB"}" - launch_configuration = "${var.lc_id}" - load_balancers = ["${compact(var.load_balancers)}"] - max_size = "${var.max_size}" - metrics_granularity = "${var.metrics_granularity}" - min_elb_capacity = "${length(var.min_elb_capacity) > 0 ? var.min_elb_capacity : "0"}" - min_size = "${var.min_size}" - name = "${length(var.asg_name_override) > 0 ? var.asg_name_override : var.stack_item_label}" - placement_group = "${var.placement_group}" - protect_from_scale_in = "${var.protect_from_scale_in}" - suspended_processes = ["${compact(var.suspended_processes)}"] - target_group_arns = ["${compact(var.target_group_arns)}"] - termination_policies = ["${compact(var.termination_policies)}"] - vpc_zone_identifier = ["${compact(var.subnets)}"] - wait_for_capacity_timeout = "${length(var.wait_for_capacity_timeout) > 0 ? var.wait_for_capacity_timeout : "10m"}" - wait_for_elb_capacity = "${length(var.wait_for_elb_capacity) > 0 ? var.wait_for_elb_capacity : "0"}" + default_cooldown = length(var.default_cooldown) > 0 ? var.default_cooldown : "300" + desired_capacity = length(var.desired_capacity) > 0 ? var.desired_capacity : var.min_size + enabled_metrics = compact(var.enabled_metrics) + force_delete = var.force_delete + health_check_grace_period = length(var.hc_grace_period) > 0 ? var.hc_grace_period : "300" + health_check_type = length(var.hc_check_type) > 0 ? var.hc_check_type : "ELB" + launch_configuration = var.lc_id + load_balancers = compact(var.load_balancers) + max_size = var.max_size + metrics_granularity = var.metrics_granularity + min_elb_capacity = length(var.min_elb_capacity) > 0 ? var.min_elb_capacity : "0" + min_size = var.min_size + name = length(var.asg_name_override) > 0 ? var.asg_name_override : var.stack_item_label + placement_group = var.placement_group + protect_from_scale_in = var.protect_from_scale_in + suspended_processes = compact(var.suspended_processes) + target_group_arns = compact(var.target_group_arns) + termination_policies = compact(var.termination_policies) + vpc_zone_identifier = compact(var.subnets) + wait_for_capacity_timeout = length(var.wait_for_capacity_timeout) > 0 ? var.wait_for_capacity_timeout : "10m" + wait_for_elb_capacity = length(var.wait_for_elb_capacity) > 0 ? var.wait_for_elb_capacity : "0" - tags = "${concat(local.default_asg_tags, var.additional_asg_tags)}" + tags = concat(local.default_asg_tags, var.additional_asg_tags) } + diff --git a/group/asg/outputs.tf b/group/asg/outputs.tf index 9a7eef7..35d1c18 100644 --- a/group/asg/outputs.tf +++ b/group/asg/outputs.tf @@ -1,9 +1,16 @@ # Outputs output "asg_id" { - value = "${coalesce(join(",",aws_autoscaling_group.asg.*.id),join(",",aws_autoscaling_group.asg_elb.*.id))}" + value = coalesce( + join(",", aws_autoscaling_group.asg.*.id), + join(",", aws_autoscaling_group.asg_elb.*.id), + ) } output "asg_name" { - value = "${coalesce(join(",",aws_autoscaling_group.asg.*.name),join(",",aws_autoscaling_group.asg_elb.*.name))}" + value = coalesce( + join(",", aws_autoscaling_group.asg.*.name), + join(",", aws_autoscaling_group.asg_elb.*.name), + ) } + diff --git a/group/asg/variables.tf b/group/asg/variables.tf index 0cf21c2..2628e25 100644 --- a/group/asg/variables.tf +++ b/group/asg/variables.tf @@ -2,109 +2,110 @@ ## Resource tags variable "stack_item_fullname" { - type = "string" + type = string } variable "stack_item_label" { - type = "string" + type = string } variable "additional_asg_tags" { - type = "list" + type = list(string) default = [] } ## Allow override of resource naming variable "asg_name_override" { - type = "string" + type = string } variable "propagate_name_at_launch" { - type = "string" + type = string default = "true" } ## VPC parameters variable "subnets" { - type = "list" + type = list(string) } ## LC parameters variable "lc_id" { - type = "string" + type = string } ## ASG parameters variable "default_cooldown" { - type = "string" + type = string } variable "desired_capacity" { - type = "string" + type = string } variable "enabled_metrics" { - type = "list" + type = list(string) } variable "force_delete" { - type = "string" + type = string } variable "hc_check_type" { - type = "string" + type = string } variable "hc_grace_period" { - type = "string" + type = string } variable "max_size" { - type = "string" + type = string } variable "metrics_granularity" { - type = "string" + type = string } variable "min_size" { - type = "string" + type = string } variable "placement_group" { - type = "string" + type = string } variable "protect_from_scale_in" { - type = "string" + type = bool } variable "suspended_processes" { - type = "list" + type = list(string) } variable "termination_policies" { - type = "list" + type = list(string) } variable "wait_for_capacity_timeout" { - type = "string" + type = string } ## ELB parameters variable "load_balancers" { - type = "list" + type = list(string) } variable "min_elb_capacity" { - type = "string" + type = string } variable "target_group_arns" { - type = "list" + type = list(string) } variable "wait_for_elb_capacity" { - type = "string" + type = string } + diff --git a/group/asg/versions.tf b/group/asg/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/group/asg/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/group/lc/main.tf b/group/lc/main.tf index d45ac9a..8a26c4f 100644 --- a/group/lc/main.tf +++ b/group/lc/main.tf @@ -3,13 +3,13 @@ ## Creates security group resource "aws_security_group" "sg_asg" { description = "${var.stack_item_fullname} security group" - name_prefix = "${length(var.lc_sg_name_prefix_override) > 0 ? format("%s-", var.lc_sg_name_prefix_override) : format("%s-asg-", var.stack_item_label)}" - vpc_id = "${var.vpc_id}" + name_prefix = length(var.lc_sg_name_prefix_override) > 0 ? format("%s-", var.lc_sg_name_prefix_override) : format("%s-asg-", var.stack_item_label) + vpc_id = var.vpc_id - tags { - application = "${var.stack_item_fullname}" + tags = { + application = var.stack_item_fullname managed_by = "terraform" - Name = "${length(var.lc_sg_name_prefix_override) > 0 ? var.lc_sg_name_prefix_override : format("%s-asg", var.stack_item_label)}" + Name = length(var.lc_sg_name_prefix_override) > 0 ? var.lc_sg_name_prefix_override : format("%s-asg", var.stack_item_label) } lifecycle { @@ -19,26 +19,29 @@ resource "aws_security_group" "sg_asg" { ## Creates launch configuration resource "aws_launch_configuration" "lc" { - count = "${length(var.ebs_vol_device_name) > 0 ? 0 : 1}" + count = length(var.ebs_vol_device_name) > 0 ? 0 : 1 - associate_public_ip_address = "${var.associate_public_ip_address}" - ebs_optimized = "${var.ebs_optimized}" - enable_monitoring = "${var.enable_monitoring}" - iam_instance_profile = "${var.instance_profile}" - image_id = "${var.ami}" - instance_type = "${var.instance_type}" - key_name = "${var.key_name}" + associate_public_ip_address = var.associate_public_ip_address + ebs_optimized = var.ebs_optimized + enable_monitoring = var.enable_monitoring + iam_instance_profile = var.instance_profile + image_id = var.ami + instance_type = var.instance_type + key_name = var.key_name name_prefix = "${var.stack_item_label}-" - placement_tenancy = "${var.placement_tenancy}" - security_groups = ["${distinct(concat(list(aws_security_group.sg_asg.id), compact(var.security_groups)))}"] - spot_price = "${var.spot_price}" - user_data = "${var.user_data}" + placement_tenancy = var.placement_tenancy + security_groups = distinct( + concat([aws_security_group.sg_asg.id], compact(var.security_groups)), + ) + spot_price = var.spot_price + user_data = var.user_data root_block_device { - delete_on_termination = "${var.root_vol_del_on_term}" - iops = "${var.root_vol_type == "io1" ? var.root_vol_iops : "0" }" - volume_size = "${length(var.root_vol_size) > 0 ? var.root_vol_size : "8"}" - volume_type = "${var.root_vol_type}" + delete_on_termination = var.root_vol_del_on_term + iops = var.root_vol_type == "io1" ? var.root_vol_iops : "0" + volume_size = length(var.root_vol_size) > 0 ? var.root_vol_size : "8" + volume_type = var.root_vol_type + encrypted = var.root_vol_encrypted } lifecycle { @@ -47,39 +50,42 @@ resource "aws_launch_configuration" "lc" { } resource "aws_launch_configuration" "lc_ebs" { - count = "${length(var.ebs_vol_device_name) > 0 ? 1 : 0}" + count = length(var.ebs_vol_device_name) > 0 ? 1 : 0 - associate_public_ip_address = "${var.associate_public_ip_address}" - ebs_optimized = "${var.ebs_optimized}" - enable_monitoring = "${var.enable_monitoring}" - iam_instance_profile = "${var.instance_profile}" - image_id = "${var.ami}" - instance_type = "${var.instance_type}" - key_name = "${var.key_name}" + associate_public_ip_address = var.associate_public_ip_address + ebs_optimized = var.ebs_optimized + enable_monitoring = var.enable_monitoring + iam_instance_profile = var.instance_profile + image_id = var.ami + instance_type = var.instance_type + key_name = var.key_name name_prefix = "${var.stack_item_label}-" - placement_tenancy = "${var.placement_tenancy}" - security_groups = ["${distinct(concat(list(aws_security_group.sg_asg.id), compact(var.security_groups)))}"] - spot_price = "${var.spot_price}" - user_data = "${var.user_data}" + placement_tenancy = var.placement_tenancy + security_groups = distinct( + concat([aws_security_group.sg_asg.id], compact(var.security_groups)), + ) + spot_price = var.spot_price + user_data = var.user_data root_block_device { - delete_on_termination = "${var.root_vol_del_on_term}" - iops = "${var.root_vol_type == "io1" ? var.root_vol_iops : "0" }" - volume_size = "${length(var.root_vol_size) > 0 ? var.root_vol_size : "0"}" - volume_type = "${var.root_vol_type}" + delete_on_termination = var.root_vol_del_on_term + iops = var.root_vol_type == "io1" ? var.root_vol_iops : "0" + volume_size = length(var.root_vol_size) > 0 ? var.root_vol_size : "0" + volume_type = var.root_vol_type } ebs_block_device { - delete_on_termination = "${var.ebs_vol_del_on_term}" - device_name = "${var.ebs_vol_device_name}" - encrypted = "${length(var.ebs_vol_snapshot_id) > 0 ? "" : var.ebs_vol_encrypted}" - iops = "${var.ebs_vol_type == "io1" ? var.ebs_vol_iops : "0" }" - snapshot_id = "${var.ebs_vol_snapshot_id}" - volume_size = "${length(var.ebs_vol_snapshot_id) > 0 ? "0" : var.ebs_vol_size}" - volume_type = "${var.ebs_vol_type}" + delete_on_termination = var.ebs_vol_del_on_term + device_name = var.ebs_vol_device_name + encrypted = length(var.ebs_vol_snapshot_id) > 0 ? "" : var.ebs_vol_encrypted + iops = var.ebs_vol_type == "io1" ? var.ebs_vol_iops : "0" + snapshot_id = var.ebs_vol_snapshot_id + volume_size = length(var.ebs_vol_snapshot_id) > 0 ? "0" : var.ebs_vol_size + volume_type = var.ebs_vol_type } lifecycle { create_before_destroy = true } } + diff --git a/group/lc/outputs.tf b/group/lc/outputs.tf index 71b97af..5271632 100644 --- a/group/lc/outputs.tf +++ b/group/lc/outputs.tf @@ -1,9 +1,13 @@ # Outputs output "lc_id" { - value = "${coalesce(join(",",aws_launch_configuration.lc.*.id),join(",",aws_launch_configuration.lc_ebs.*.id))}" + value = coalesce( + join(",", aws_launch_configuration.lc.*.id), + join(",", aws_launch_configuration.lc_ebs.*.id), + ) } output "sg_id" { - value = "${aws_security_group.sg_asg.id}" + value = aws_security_group.sg_asg.id } + diff --git a/group/lc/variables.tf b/group/lc/variables.tf index 12939b8..79d30d9 100644 --- a/group/lc/variables.tf +++ b/group/lc/variables.tf @@ -2,108 +2,114 @@ ## Resource tags variable "stack_item_fullname" { - type = "string" + type = string } variable "stack_item_label" { - type = "string" + type = string } ## Allow override of resource naming variable "lc_sg_name_prefix_override" { - type = "string" + type = string } ## VPC parameters variable "vpc_id" { - type = "string" + type = string } ## LC parameters variable "associate_public_ip_address" { - type = "string" + type = string } variable "ami" { - type = "string" + type = string } variable "ebs_optimized" { - type = "string" + type = string } variable "ebs_vol_del_on_term" { - type = "string" + type = string } variable "ebs_vol_device_name" { - type = "string" + type = string } variable "ebs_vol_encrypted" { - type = "string" + type = string } variable "ebs_vol_snapshot_id" { - type = "string" + type = string } variable "ebs_vol_iops" { - type = "string" + type = string } variable "ebs_vol_size" { - type = "string" + type = string } variable "ebs_vol_type" { - type = "string" + type = string } variable "enable_monitoring" { - type = "string" + type = string } variable "instance_profile" { - type = "string" + type = string } variable "instance_type" { - type = "string" + type = string } variable "key_name" { - type = "string" + type = string } variable "placement_tenancy" { - type = "string" + type = string } variable "root_vol_del_on_term" { - type = "string" + type = string } variable "root_vol_iops" { - type = "string" + type = string } variable "root_vol_size" { - type = "string" + type = string } variable "root_vol_type" { - type = "string" + type = string +} + +variable "root_vol_encrypted" { + type = bool + default = false } variable "security_groups" { - type = "list" + type = list(string) } variable "spot_price" { - type = "string" + type = string } variable "user_data" { - type = "string" + type = string } + diff --git a/group/lc/versions.tf b/group/lc/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/group/lc/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/group/main.tf b/group/main.tf index b95cbd8..5292804 100644 --- a/group/main.tf +++ b/group/main.tf @@ -1,31 +1,27 @@ # AWS Auto Scaling Configuration -## Set Terraform version constraint -terraform { - required_version = "> 0.8.0" -} - ## Creates cloudconfig fragments for tagging -data "aws_region" "current" {} +data "aws_region" "current" { +} data "template_file" "name" { - template = "${var.instance_based_naming_enabled == "true" ? file("${path.module}/templates/name.tpl") : ""}" + template = var.instance_based_naming_enabled == "true" ? file("${path.module}/templates/name.tpl") : "" - vars { - name_prefix = "${length(var.instance_name_prefix) > 0 ? var.instance_name_prefix : var.stack_item_label}" - region = "${data.aws_region.current.name}" + vars = { + name_prefix = length(var.instance_name_prefix) > 0 ? var.instance_name_prefix : var.stack_item_label + region = data.aws_region.current.name } } data "template_file" "tags" { - count = "${length(keys(var.instance_tags))}" + count = length(keys(var.instance_tags)) - template = "${element(keys(var.instance_tags),count.index) != "" ? file("${path.module}/templates/tag.tpl") : ""}" + template = element(keys(var.instance_tags), count.index) != "" ? file("${path.module}/templates/tag.tpl") : "" - vars { - key = "${element(keys(var.instance_tags),count.index)}" - region = "${data.aws_region.current.name}" - value = "${lookup(var.instance_tags,element(keys(var.instance_tags),count.index))}" + vars = { + key = element(keys(var.instance_tags), count.index) + region = data.aws_region.current.name + value = var.instance_tags[element(keys(var.instance_tags), count.index)] } } @@ -35,95 +31,96 @@ data "template_cloudinit_config" "cloud_config" { part { content_type = "text/cloud-config" - content = "${var.user_data}" + content = var.user_data } part { content_type = "text/cloud-config" - content = "${data.template_file.name.rendered}" + content = data.template_file.name.rendered merge_type = "list(append)+dict(recurse_array)+str()" } part { content_type = "text/cloud-config" - content = "#cloud-config\nruncmd:\n${join("",data.template_file.tags.*.rendered)}" + content = "#cloud-config\nruncmd:\n${join("", data.template_file.tags.*.rendered)}" merge_type = "list(append)+dict(recurse_array)+str()" } } ## Creates launch configuration & security group module "lc" { - source = "lc" + source = "./lc" ### Resource labels - stack_item_fullname = "${var.stack_item_fullname}" - stack_item_label = "${var.stack_item_label}" - lc_sg_name_prefix_override = "${var.lc_sg_name_prefix_override}" + stack_item_fullname = var.stack_item_fullname + stack_item_label = var.stack_item_label + lc_sg_name_prefix_override = var.lc_sg_name_prefix_override ### VPC parameters - vpc_id = "${var.vpc_id}" + vpc_id = var.vpc_id ### LC parameters - ami = "${var.ami}" - associate_public_ip_address = "${var.associate_public_ip_address}" - ebs_optimized = "${var.ebs_optimized}" - ebs_vol_del_on_term = "${var.ebs_vol_del_on_term}" - ebs_vol_device_name = "${var.ebs_vol_device_name}" - ebs_vol_encrypted = "${var.ebs_vol_encrypted}" - ebs_vol_iops = "${var.ebs_vol_iops}" - ebs_vol_size = "${var.ebs_vol_size}" - ebs_vol_snapshot_id = "${var.ebs_vol_snapshot_id}" - ebs_vol_type = "${var.ebs_vol_type}" - enable_monitoring = "${var.enable_monitoring}" - instance_profile = "${var.instance_profile}" - instance_type = "${var.instance_type}" - key_name = "${var.key_name}" - placement_tenancy = "${var.placement_tenancy}" - root_vol_del_on_term = "${var.root_vol_del_on_term}" - root_vol_iops = "${var.root_vol_iops}" - root_vol_size = "${var.root_vol_size}" - root_vol_type = "${var.root_vol_type}" - security_groups = ["${var.security_groups}"] - spot_price = "${var.spot_price}" - user_data = "${data.template_cloudinit_config.cloud_config.rendered}" + ami = var.ami + associate_public_ip_address = var.associate_public_ip_address + ebs_optimized = var.ebs_optimized + ebs_vol_del_on_term = var.ebs_vol_del_on_term + ebs_vol_device_name = var.ebs_vol_device_name + ebs_vol_encrypted = var.ebs_vol_encrypted + ebs_vol_iops = var.ebs_vol_iops + ebs_vol_size = var.ebs_vol_size + ebs_vol_snapshot_id = var.ebs_vol_snapshot_id + ebs_vol_type = var.ebs_vol_type + enable_monitoring = var.enable_monitoring + instance_profile = var.instance_profile + instance_type = var.instance_type + key_name = var.key_name + placement_tenancy = var.placement_tenancy + root_vol_del_on_term = var.root_vol_del_on_term + root_vol_iops = var.root_vol_iops + root_vol_size = var.root_vol_size + root_vol_type = var.root_vol_type + root_vol_encrypted = var.root_vol_encrypted + security_groups = var.security_groups + spot_price = var.spot_price + user_data = data.template_cloudinit_config.cloud_config.rendered } ## Creates auto scaling group module "asg" { - source = "asg" + source = "./asg" ### Resource tags - stack_item_label = "${var.stack_item_label}" - stack_item_fullname = "${var.stack_item_fullname}" - asg_name_override = "${var.asg_name_override}" - propagate_name_at_launch = "${var.propagate_name_at_launch}" + stack_item_label = var.stack_item_label + stack_item_fullname = var.stack_item_fullname + asg_name_override = var.asg_name_override + propagate_name_at_launch = var.propagate_name_at_launch ### VPC parameters - subnets = ["${var.subnets}"] + subnets = var.subnets ### LC parameters - lc_id = "${module.lc.lc_id}" + lc_id = module.lc.lc_id ### ASG parameters - default_cooldown = "${var.default_cooldown}" - desired_capacity = "${var.desired_capacity}" - enabled_metrics = ["${var.enabled_metrics}"] - force_delete = "${var.force_delete}" - hc_check_type = "${var.hc_check_type}" - hc_grace_period = "${var.hc_grace_period}" - max_size = "${var.max_size}" + default_cooldown = var.default_cooldown + desired_capacity = var.desired_capacity + enabled_metrics = var.enabled_metrics + force_delete = var.force_delete + hc_check_type = var.hc_check_type + hc_grace_period = var.hc_grace_period + max_size = var.max_size metrics_granularity = "1Minute" - min_size = "${var.min_size}" - placement_group = "${var.placement_group}" - protect_from_scale_in = "${var.protect_from_scale_in}" - suspended_processes = ["${var.suspended_processes}"] - termination_policies = ["${var.termination_policies}"] - wait_for_capacity_timeout = "${var.wait_for_capacity_timeout}" - additional_asg_tags = "${var.additional_asg_tags}" + min_size = var.min_size + placement_group = var.placement_group + protect_from_scale_in = var.protect_from_scale_in + suspended_processes = var.suspended_processes + termination_policies = var.termination_policies + wait_for_capacity_timeout = var.wait_for_capacity_timeout + additional_asg_tags = var.additional_asg_tags ### ELB parameters - load_balancers = ["${var.load_balancers}"] - min_elb_capacity = "${var.min_elb_capacity}" - target_group_arns = ["${var.target_group_arns}"] - wait_for_elb_capacity = "${var.wait_for_elb_capacity}" + load_balancers = var.load_balancers + min_elb_capacity = var.min_elb_capacity + target_group_arns = var.target_group_arns + wait_for_elb_capacity = var.wait_for_elb_capacity } diff --git a/group/outputs.tf b/group/outputs.tf index 847616b..c4a3c9e 100644 --- a/group/outputs.tf +++ b/group/outputs.tf @@ -1,17 +1,18 @@ # Outputs output "asg_id" { - value = "${module.asg.asg_id}" + value = module.asg.asg_id } output "asg_name" { - value = "${module.asg.asg_name}" + value = module.asg.asg_name } output "lc_id" { - value = "${module.lc.lc_id}" + value = module.lc.lc_id } output "sg_id" { - value = "${module.lc.sg_id}" + value = module.lc.sg_id } + diff --git a/group/variables.tf b/group/variables.tf index 720e288..e416387 100644 --- a/group/variables.tf +++ b/group/variables.tf @@ -2,76 +2,76 @@ ## Resource tags variable "stack_item_fullname" { - type = "string" + type = string description = "Long form descriptive name for this stack item. This value is used to create the 'application' resource tag for resources created by this stack item." } variable "stack_item_label" { - type = "string" + type = string description = "Short form identifier for this stack. This value is used to create the 'Name' resource tag for resources created by this stack item, and also serves as a unique key for re-use." } variable "asg_name_override" { - type = "string" + type = string description = "A string to override the ASG name" default = "" } variable "lc_sg_name_prefix_override" { - type = "string" + type = string description = "A string to override the ASG name" default = "" } variable "propagate_name_at_launch" { - type = "string" + type = string description = "A string to override the ASG name" default = "true" } ## VPC parameters variable "subnets" { - type = "list" + type = list(string) description = "A list of subnet IDs to launch resources in" } variable "vpc_id" { - type = "string" + type = string description = "ID of the target VPC." } ## LC parameters variable "ami" { - type = "string" + type = string description = "Amazon Machine Image (AMI) to associate with the launch configuration." } variable "associate_public_ip_address" { - type = "string" + type = string description = "Flag for associating public IP addresses with instances managed by the auto scaling group." default = "" } variable "ebs_optimized" { - type = "string" + type = string description = "Flag to enable EBS optimization." default = "false" } variable "ebs_vol_del_on_term" { - type = "string" + type = string description = "Whether the volume should be destroyed on instance termination." default = "true" } variable "ebs_vol_device_name" { - type = "string" + type = string description = "The name of the device to mount." default = "" } variable "ebs_vol_encrypted" { - type = "string" + type = string description = "Whether the volume should be encrypted or not. Do not use this option if you are using 'snapshot_id' as the encrypted flag will be determined by the snapshot." default = "" } @@ -81,55 +81,55 @@ http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html For the best per-I/O latency experience, we recommend that you provision an IOPS-to-GiB ratio greater than 2:1. For example, a 2,000 IOPS volume should be smaller than 1,000 GiB. */ variable "ebs_vol_iops" { - type = "string" + type = string description = "The amount of provisioned IOPS" default = "2000" } variable "ebs_vol_size" { - type = "string" + type = string description = "The size of the volume in gigabytes." default = "" } variable "ebs_vol_snapshot_id" { - type = "string" + type = string description = "The Snapshot ID to mount." default = "" } variable "ebs_vol_type" { - type = "string" + type = string description = "The type of volume. Valid values are 'standard', 'gp2' and 'io1'." default = "gp2" } variable "enable_monitoring" { - type = "string" + type = string description = "Flag to enable detailed monitoring." default = "" } variable "instance_based_naming_enabled" { - type = "string" + type = string description = "Flag to enable instance-id based name tagging." default = "" } variable "instance_name_prefix" { - type = "string" + type = string description = "Sring to prepend instance-id based name tags with." default = "" } variable "instance_profile" { - type = "string" + type = string description = "IAM instance profile to associate with the launch configuration." default = "" } variable "instance_tags" { - type = "map" + type = map(string) description = "Map of tags to add to isntances." default = { @@ -138,24 +138,24 @@ variable "instance_tags" { } variable "instance_type" { - type = "string" + type = string description = "EC2 instance type to associate with the launch configuration." } variable "key_name" { - type = "string" + type = string description = "SSH key pair to associate with the launch configuration." default = "" } variable "placement_tenancy" { - type = "string" + type = string description = "The tenancy of the instance. Valid values are 'default' or 'dedicated'." default = "default" } variable "root_vol_del_on_term" { - type = "string" + type = string description = "Whether the volume should be destroyed on instance termination." default = "true" } @@ -165,145 +165,151 @@ http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html For the best per-I/O latency experience, we recommend that you provision an IOPS-to-GiB ratio greater than 2:1. For example, a 2,000 IOPS volume should be smaller than 1,000 GiB. */ variable "root_vol_iops" { - type = "string" + type = string description = "The amount of provisioned IOPS" default = "2000" } variable "root_vol_size" { - type = "string" + type = string description = "The size of the volume in gigabytes." default = "" } variable "root_vol_type" { - type = "string" + type = string description = "The type of volume. Valid values are 'standard', 'gp2' and 'io1'." default = "gp2" } +variable "root_vol_encrypted" { + type = bool + default = false +} + variable "security_groups" { - type = "list" + type = list(string) description = "A list of associated security group IDs" default = [] } variable "spot_price" { - type = "string" + type = string description = "The price to use for reserving spot instances." default = "" } variable "user_data" { - type = "string" + type = string description = "Instance initialization data to associate with the launch configuration." default = "" } ## ASG parameters variable "additional_asg_tags" { - type = "list" + type = list(string) description = "Additional tags to apply at the ASG level, if any" default = [] } variable "default_cooldown" { - type = "string" + type = string description = "The amount of time, in seconds, after a scaling activity completes before another scaling activity can start." default = "" } variable "desired_capacity" { - type = "string" + type = string description = "The number of Amazon EC2 instances that should be running in the group." default = "" } variable "enabled_metrics" { - type = "list" + type = list(string) description = "A list of metrics to collect. The allowed values are 'GroupMinSize', 'GroupMaxSize', 'GroupDesiredCapacity', 'GroupInServiceInstances', 'GroupPendingInstances', 'GroupStandbyInstances', 'GroupTerminatingInstances', 'GroupTotalInstances'." default = [] } variable "force_delete" { - type = "string" + type = string description = "Flag to allow deletion of the auto scaling group without waiting for all instances in the pool to terminate." default = "false" } variable "hc_check_type" { - type = "string" + type = string description = "Type of health check performed by the auto scaling group. Valid values are 'ELB' or 'EC2'." default = "" } variable "hc_grace_period" { - type = "string" + type = string description = "Time allowed after an instance comes into service before checking health." default = "" } variable "max_size" { - type = "string" + type = string description = "Maximum number of instances allowed by the auto scaling group." } variable "min_size" { - type = "string" + type = string description = "Minimum number of instance to be maintained by the auto scaling group." } variable "placement_group" { - type = "string" + type = string description = "The name of the placement group into which you'll launch your instances, if any." default = "" } variable "protect_from_scale_in" { - type = "string" + type = bool description = "Allows setting instance protection. The autoscaling group will not select instances with this setting for terminination during scale in events." - default = "" + default = false } variable "suspended_processes" { - type = "list" + type = list(string) description = "A list of processes to suspend for the AutoScaling Group. The allowed values are 'Launch', 'Terminate', 'HealthCheck', 'ReplaceUnhealthy', 'AZRebalance', 'AlarmNotification', 'ScheduledActions', 'AddToLoadBalancer'. Note that if you suspend either the 'Launch' or 'Terminate' process types, it can prevent your autoscaling group from functioning properly." default = [] } variable "termination_policies" { - type = "list" + type = list(string) description = "A list of policies to decide how the instances in the auto scale group should be terminated. The allowed values are 'OldestInstance', 'NewestInstance', 'OldestLaunchConfiguration', 'ClosestToNextInstanceHour', 'Default'." default = [] } variable "wait_for_capacity_timeout" { - type = "string" + type = string description = "A maximum duration that Terraform should wait for ASG managed instances to become healthy before timing out." default = "" } ## ELB parameters variable "load_balancers" { - type = "list" + type = list(string) description = "List of load balancer names to associate with the auto scaling group." default = [] } variable "min_elb_capacity" { - type = "string" + type = string description = "Minimum number of healthy instances attached to the ELB that must be maintained during updates." default = "" } variable "target_group_arns" { - type = "list" + type = list(string) description = "A list of 'aws_alb_target_group' ARNs, for use with Application Load Balancing" default = [] } variable "wait_for_elb_capacity" { - type = "string" + type = string description = "Setting this will cause Terraform to wait for exactly this number of healthy instances in all attached load balancers on both create and update operations. (Takes precedence over 'min_elb_capacity' behavior.)" default = "" } + diff --git a/group/versions.tf b/group/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/group/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +}