Skip to content

Commit

Permalink
Merge pull request #29 from lorengordon/as-updates
Browse files Browse the repository at this point in the history
Adds blue/green updates and scheduled scaling to autoscale modules
  • Loading branch information
lorengordon authored Apr 12, 2018
2 parents caacd23 + 928f7ca commit 51fef34
Show file tree
Hide file tree
Showing 7 changed files with 203 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.2.0
current_version = 1.3.0
commit = True
message = Bumps version to {new_version}
tag = False
Expand Down
2 changes: 2 additions & 0 deletions modules/lx-autoscale/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ resource "aws_cloudformation_stack" "watchmaker-lx-autoscale" {
MinCapacity = "${var.MinCapacity}"
MaxCapacity = "${var.MaxCapacity}"
DesiredCapacity = "${var.DesiredCapacity}"
ScaleDownSchedule = "${var.ScaleDownSchedule}"
ScaleUpSchedule = "${var.ScaleUpSchedule}"
NoPublicIp = "${var.NoPublicIp}"
NoReboot = "${var.NoReboot}"
NoUpdates = "${var.NoUpdates}"
Expand Down
12 changes: 12 additions & 0 deletions modules/lx-autoscale/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ variable "DesiredCapacity" {
default = "1"
}

variable "ScaleDownSchedule" {
type = "string"
description = "(Optional) Scheduled Action in cron-format (UTC) to scale down to MinCapacity; ignored if empty or ScaleUpSchedule is unset (E.g. \"0 0 * * *\")"
default = ""
}

variable "ScaleUpSchedule" {
type = "string"
description = "(Optional) Scheduled Action in cron-format (UTC) to scale up to MaxCapacity; ignored if empty or ScaleDownSchedule is unset (E.g. \"0 10 * * Mon-Fri\")"
default = ""
}

variable "NoPublicIp" {
type = "string"
description = "Controls whether to assign the instance a public IP. Recommended to leave at true _unless_ launching in a public subnet"
Expand Down
93 changes: 87 additions & 6 deletions modules/lx-autoscale/watchmaker-lx-autoscale.cfn.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,34 @@
}
]
},
"UseScheduledAction": {
"Fn::And": [
{
"Fn::Not": [
{
"Fn::Equals": [
{
"Ref": "ScaleUpSchedule"
},
""
]
}
]
},
{
"Fn::Not": [
{
"Fn::Equals": [
{
"Ref": "ScaleDownSchedule"
},
""
]
}
]
}
]
},
"UseWamConfig": {
"Fn::Not": [
{
Expand Down Expand Up @@ -283,7 +311,9 @@
"Parameters": [
"DesiredCapacity",
"MinCapacity",
"MaxCapacity"
"MaxCapacity",
"ScaleDownSchedule",
"ScaleUpSchedule"
]
},
{
Expand Down Expand Up @@ -319,6 +349,20 @@
}
},
"Outputs": {
"ScaleDownScheduledAction": {
"Condition": "UseScheduledAction",
"Description": "Scale Down Scheduled Action ID",
"Value": {
"Ref": "ScaleDownScheduledAction"
}
},
"ScaleUpScheduledAction": {
"Condition": "UseScheduledAction",
"Description": "Scale Up Scheduled Action ID",
"Value": {
"Ref": "ScaleUpScheduledAction"
}
},
"WatchmakerAutoScalingGroupId": {
"Description": "Autoscaling Group ID",
"Value": {
Expand Down Expand Up @@ -510,6 +554,16 @@
"Description": "URL to the PyPi Index",
"Type": "String"
},
"ScaleDownSchedule": {
"Default": "",
"Description": "(Optional) Scheduled Action in cron-format (UTC) to scale down to MinCapacity; ignored if empty or ScaleUpSchedule is unset (E.g. \"0 0 * * *\")",
"Type": "String"
},
"ScaleUpSchedule": {
"Default": "",
"Description": "(Optional) Scheduled Action in cron-format (UTC) to scale up to MaxCapacity; ignored if empty or ScaleDownSchedule is unset (E.g. \"0 10 * * Mon-Fri\")",
"Type": "String"
},
"SecurityGroupIds": {
"Description": "List of security groups to apply to the instance(s)",
"Type": "List<AWS::EC2::SecurityGroup::Id>"
Expand Down Expand Up @@ -571,6 +625,36 @@
}
},
"Resources": {
"ScaleDownScheduledAction": {
"Condition": "UseScheduledAction",
"Properties": {
"AutoScalingGroupName": {
"Ref": "WatchmakerAutoScalingGroup"
},
"DesiredCapacity": {
"Ref": "MinCapacity"
},
"Recurrence": {
"Ref": "ScaleDownSchedule"
}
},
"Type": "AWS::AutoScaling::ScheduledAction"
},
"ScaleUpScheduledAction": {
"Condition": "UseScheduledAction",
"Properties": {
"AutoScalingGroupName": {
"Ref": "WatchmakerAutoScalingGroup"
},
"DesiredCapacity": {
"Ref": "MaxCapacity"
},
"Recurrence": {
"Ref": "ScaleUpSchedule"
}
},
"Type": "AWS::AutoScaling::ScheduledAction"
},
"WatchmakerAutoScalingGroup": {
"CreationPolicy": {
"ResourceSignal": {
Expand Down Expand Up @@ -615,11 +699,8 @@
},
"Type": "AWS::AutoScaling::AutoScalingGroup",
"UpdatePolicy": {
"AutoScalingRollingUpdate": {
"MaxBatchSize": "2",
"MinInstancesInService": "1",
"PauseTime": "PT30M",
"WaitOnResourceSignals": "true"
"AutoScalingReplacingUpdate": {
"WillReplace": "true"
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions modules/win-autoscale/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ resource "aws_cloudformation_stack" "watchmaker-win-autoscale" {
MinCapacity = "${var.MinCapacity}"
MaxCapacity = "${var.MaxCapacity}"
DesiredCapacity = "${var.DesiredCapacity}"
ScaleDownSchedule = "${var.ScaleDownSchedule}"
ScaleUpSchedule = "${var.ScaleUpSchedule}"
NoPublicIp = "${var.NoPublicIp}"
NoReboot = "${var.NoReboot}"
SecurityGroupIds = "${var.SecurityGroupIds}"
Expand Down
12 changes: 12 additions & 0 deletions modules/win-autoscale/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ variable "DesiredCapacity" {
default = "1"
}

variable "ScaleDownSchedule" {
type = "string"
description = "(Optional) Scheduled Action in cron-format (UTC) to scale down to MinCapacity; ignored if empty or ScaleUpSchedule is unset (E.g. \"0 0 * * *\")"
default = ""
}

variable "ScaleUpSchedule" {
type = "string"
description = "(Optional) Scheduled Action in cron-format (UTC) to scale up to MaxCapacity; ignored if empty or ScaleDownSchedule is unset (E.g. \"0 10 * * Mon-Fri\")"
default = ""
}

variable "NoPublicIp" {
type = "string"
description = "Controls whether to assign the instance a public IP. Recommended to leave at true _unless_ launching in a public subnet"
Expand Down
93 changes: 87 additions & 6 deletions modules/win-autoscale/watchmaker-win-autoscale.cfn.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,34 @@
}
]
},
"UseScheduledAction": {
"Fn::And": [
{
"Fn::Not": [
{
"Fn::Equals": [
{
"Ref": "ScaleUpSchedule"
},
""
]
}
]
},
{
"Fn::Not": [
{
"Fn::Equals": [
{
"Ref": "ScaleDownSchedule"
},
""
]
}
]
}
]
},
"UseWamConfig": {
"Fn::Not": [
{
Expand Down Expand Up @@ -204,7 +232,9 @@
"Parameters": [
"DesiredCapacity",
"MinCapacity",
"MaxCapacity"
"MaxCapacity",
"ScaleDownSchedule",
"ScaleUpSchedule"
]
},
{
Expand Down Expand Up @@ -238,6 +268,20 @@
}
},
"Outputs": {
"ScaleDownScheduledAction": {
"Condition": "UseScheduledAction",
"Description": "Scale Down Scheduled Action ID",
"Value": {
"Ref": "ScaleDownScheduledAction"
}
},
"ScaleUpScheduledAction": {
"Condition": "UseScheduledAction",
"Description": "Scale Up Scheduled Action ID",
"Value": {
"Ref": "ScaleUpScheduledAction"
}
},
"WatchmakerAutoScalingGroupId": {
"Description": "Autoscaling Group ID",
"Value": {
Expand Down Expand Up @@ -394,6 +438,16 @@
"Description": "URL to the Python Installer Executable",
"Type": "String"
},
"ScaleDownSchedule": {
"Default": "",
"Description": "(Optional) Scheduled Action in cron-format (UTC) to scale down to MinCapacity; ignored if empty or ScaleUpSchedule is unset (E.g. \"0 0 * * *\")",
"Type": "String"
},
"ScaleUpSchedule": {
"Default": "",
"Description": "(Optional) Scheduled Action in cron-format (UTC) to scale up to MaxCapacity; ignored if empty or ScaleDownSchedule is unset (E.g. \"0 10 * * Mon-Fri\")",
"Type": "String"
},
"SecurityGroupIds": {
"Description": "List of security groups to apply to the instance",
"Type": "List<AWS::EC2::SecurityGroup::Id>"
Expand Down Expand Up @@ -456,6 +510,36 @@
}
},
"Resources": {
"ScaleDownScheduledAction": {
"Condition": "UseScheduledAction",
"Properties": {
"AutoScalingGroupName": {
"Ref": "WatchmakerAutoScalingGroup"
},
"DesiredCapacity": {
"Ref": "MinCapacity"
},
"Recurrence": {
"Ref": "ScaleDownSchedule"
}
},
"Type": "AWS::AutoScaling::ScheduledAction"
},
"ScaleUpScheduledAction": {
"Condition": "UseScheduledAction",
"Properties": {
"AutoScalingGroupName": {
"Ref": "WatchmakerAutoScalingGroup"
},
"DesiredCapacity": {
"Ref": "MaxCapacity"
},
"Recurrence": {
"Ref": "ScaleUpSchedule"
}
},
"Type": "AWS::AutoScaling::ScheduledAction"
},
"WatchmakerAutoScalingGroup": {
"CreationPolicy": {
"ResourceSignal": {
Expand Down Expand Up @@ -500,11 +584,8 @@
},
"Type": "AWS::AutoScaling::AutoScalingGroup",
"UpdatePolicy": {
"AutoScalingRollingUpdate": {
"MaxBatchSize": "2",
"MinInstancesInService": "1",
"PauseTime": "PT60M",
"WaitOnResourceSignals": "true"
"AutoScalingReplacingUpdate": {
"WillReplace": "true"
}
}
},
Expand Down

0 comments on commit 51fef34

Please sign in to comment.