Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix module path #30

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.tfstate*
.terraform/
spec/reports/*

.idea/
91 changes: 46 additions & 45 deletions group/asg/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
}

11 changes: 9 additions & 2 deletions group/asg/outputs.tf
Original file line number Diff line number Diff line change
@@ -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),
)
}

51 changes: 26 additions & 25 deletions group/asg/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

4 changes: 4 additions & 0 deletions group/asg/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

terraform {
required_version = ">= 0.12"
}
Loading