Skip to content

Commit

Permalink
Merge pull request #109 from lorengordon/snapshot
Browse files Browse the repository at this point in the history
Supports creating the AppVolume from an EBS Snapshot
  • Loading branch information
lorengordon authored Mar 7, 2019
2 parents 8c303b0 + 892c090 commit 9630506
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 8 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.12.0
current_version = 1.13.0
commit = True
message = Bumps version to {new_version}
tag = False
Expand Down
1 change: 1 addition & 0 deletions modules/lx-autoscale/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ resource "aws_cloudformation_stack" "watchmaker-lx-autoscale" {
AppVolumeDevice = "${var.AppVolumeDevice}"
AppVolumeMountPath = "${var.AppVolumeMountPath}"
AppVolumeSize = "${var.AppVolumeSize}"
AppVolumeSnapshotId = "${var.AppVolumeSnapshotId}"
AppVolumeType = "${var.AppVolumeType}"
AsgMetrics = "${join(",", var.AsgMetrics)}"
AsgNotificationTypes = "${join(",", var.AsgNotificationTypes)}"
Expand Down
6 changes: 6 additions & 0 deletions modules/lx-autoscale/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ variable "AppVolumeSize" {
default = "1"
}

variable "AppVolumeSnapshotId" {
type = "string"
description = "(Optional) EBS Snapshot ID from which to create the AppVolume. \"AppVolumeSize\" must be equal or greater than the size of the snapshot. Ignored if \"AppVolumeDevice\" is false"
default = ""
}

variable "KeyPairName" {
type = "string"
description = "Public/private key pairs allow you to securely connect to your instance after it launches"
Expand Down
25 changes: 21 additions & 4 deletions modules/lx-autoscale/watchmaker-lx-autoscale.template.cfn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ Conditions:
- !Equals
- !Ref WatchmakerAdminUsers
- ''
UseAppVolumeSnapshot: !Not
- !Equals
- !Ref AppVolumeSnapshotId
- ''
UseAsgMetricsCollection: !Not
- !Equals
- !Join [ "," , !Ref AsgMetrics]
Expand Down Expand Up @@ -203,6 +207,7 @@ Metadata:
- AppVolumeDevice
- AppVolumeMountPath
- AppVolumeSize
- AppVolumeSnapshotId
- AppVolumeType
- Label:
default: AutoScale Configuration
Expand Down Expand Up @@ -238,7 +243,7 @@ Metadata:
default: Force Cfn Init Update
ToggleNewInstances:
default: Force New Instances
Version: 1.12.0
Version: 1.13.0
Outputs:
ScaleDownScheduledAction:
Condition: UseScheduledAction
Expand Down Expand Up @@ -306,17 +311,25 @@ Parameters:
Default: /opt/data
Description: >-
Filesystem path to mount the extra app volume. Ignored if
"AppVolumeDevice" is blank
"AppVolumeDevice" is false
Type: String
AppVolumeSize:
ConstraintDescription: Must be between 1GB and 16384GB.
Default: 1
Description: >-
Size in GB of the EBS volume to create. Ignored if "AppVolumeDevice" is
blank
false
MaxValue: 16384
MinValue: 1
Type: Number
AppVolumeSnapshotId:
AllowedPattern: '^$|snap-[a-z0-9]+'
Default: ''
Description: >-
(Optional) EBS Snapshot ID from which to create the AppVolume. "AppVolumeSize"
must be equal or greater than the size of the snapshot. Ignored if "AppVolumeDevice"
is false
Type: String
AppVolumeType:
AllowedValues:
- gp2
Expand All @@ -325,7 +338,7 @@ Parameters:
- st1
- standard
Default: gp2
Description: Type of EBS volume to create. Ignored if "AppVolumeDevice" is blank
Description: Type of EBS volume to create. Ignored if "AppVolumeDevice" is false
Type: String
AsgMetrics:
Default: ''
Expand Down Expand Up @@ -948,6 +961,10 @@ Resources:
- DeviceName: /dev/xvdf
Ebs:
DeleteOnTermination: true
SnapshotId: !If
- UseAppVolumeSnapshot
- !Ref AppVolumeSnapshotId
- !Ref 'AWS::NoValue'
VolumeSize: !Ref AppVolumeSize
VolumeType: !Ref AppVolumeType
- !Ref 'AWS::NoValue'
Expand Down
1 change: 1 addition & 0 deletions modules/lx-instance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ resource "aws_cloudformation_stack" "watchmaker-lx-instance" {
AppVolumeDevice = "${var.AppVolumeDevice}"
AppVolumeMountPath = "${var.AppVolumeMountPath}"
AppVolumeSize = "${var.AppVolumeSize}"
AppVolumeSnapshotId = "${var.AppVolumeSnapshotId}"
AppVolumeType = "${var.AppVolumeType}"
CfnBootstrapUtilsUrl = "${var.CfnBootstrapUtilsUrl}"
CfnEndpointUrl = "${var.CfnEndpointUrl}"
Expand Down
6 changes: 6 additions & 0 deletions modules/lx-instance/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ variable "AppVolumeSize" {
default = "1"
}

variable "AppVolumeSnapshotId" {
type = "string"
description = "(Optional) EBS Snapshot ID from which to create the AppVolume. \"AppVolumeSize\" must be equal or greater than the size of the snapshot. Ignored if \"AppVolumeDevice\" is false"
default = ""
}

variable "KeyPairName" {
type = "string"
description = "Public/private key pairs allow you to securely connect to your instance after it launches"
Expand Down
19 changes: 18 additions & 1 deletion modules/lx-instance/watchmaker-lx-instance.template.cfn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ Conditions:
- !Equals
- !Ref WatchmakerAdminUsers
- ''
UseAppVolumeSnapshot: !Not
- !Equals
- !Ref AppVolumeSnapshotId
- ''
UseCfnUrl: !Not
- !Equals
- !Ref CfnEndpointUrl
Expand Down Expand Up @@ -171,6 +175,7 @@ Metadata:
- AppVolumeDevice
- AppVolumeMountPath
- AppVolumeSize
- AppVolumeSnapshotId
- AppVolumeType
- Label:
default: Network Configuration
Expand All @@ -189,7 +194,7 @@ Metadata:
ParameterLabels:
ToggleCfnInitUpdate:
default: Force Cfn Init Update
Version: 1.12.0
Version: 1.13.0
Outputs:
WatchmakerInstanceId:
Description: Instance ID
Expand Down Expand Up @@ -257,6 +262,14 @@ Parameters:
MaxValue: 16384
MinValue: 1
Type: Number
AppVolumeSnapshotId:
AllowedPattern: '^$|snap-[a-z0-9]+'
Default: ''
Description: >-
(Optional) EBS Snapshot ID from which to create the AppVolume. "AppVolumeSize"
must be equal or greater than the size of the snapshot. Ignored if "AppVolumeDevice"
is false
Type: String
AppVolumeType:
AllowedValues:
- gp2
Expand Down Expand Up @@ -761,6 +774,10 @@ Resources:
- DeviceName: /dev/xvdf
Ebs:
DeleteOnTermination: true
SnapshotId: !If
- UseAppVolumeSnapshot
- !Ref AppVolumeSnapshotId
- !Ref 'AWS::NoValue'
VolumeSize: !Ref AppVolumeSize
VolumeType: !Ref AppVolumeType
- !Ref 'AWS::NoValue'
Expand Down
1 change: 1 addition & 0 deletions modules/win-autoscale/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ resource "aws_cloudformation_stack" "watchmaker-win-autoscale" {
AppScriptUrl = "${var.AppScriptUrl}"
AppVolumeDevice = "${var.AppVolumeDevice}"
AppVolumeSize = "${var.AppVolumeSize}"
AppVolumeSnapshotId = "${var.AppVolumeSnapshotId}"
AppVolumeType = "${var.AppVolumeType}"
AsgMetrics = "${join(",", var.AsgMetrics)}"
AsgNotificationTypes = "${join(",", var.AsgNotificationTypes)}"
Expand Down
6 changes: 6 additions & 0 deletions modules/win-autoscale/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ variable "AppVolumeSize" {
default = "1"
}

variable "AppVolumeSnapshotId" {
type = "string"
description = "(Optional) EBS Snapshot ID from which to create the AppVolume. \"AppVolumeSize\" must be equal or greater than the size of the snapshot. Ignored if \"AppVolumeDevice\" is blank"
default = ""
}

variable "KeyPairName" {
type = "string"
description = "Public/private key pairs allow you to securely connect to your instance after it launches"
Expand Down
19 changes: 18 additions & 1 deletion modules/win-autoscale/watchmaker-win-autoscale.template.cfn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ Conditions:
- !Equals
- !Ref WatchmakerAdminGroups
- ''
UseAppVolumeSnapshot: !Not
- !Equals
- !Ref AppVolumeSnapshotId
- ''
UseCfnUrl: !Not
- !Equals
- !Ref CfnEndpointUrl
Expand Down Expand Up @@ -138,6 +142,7 @@ Metadata:
Parameters:
- AppVolumeDevice
- AppVolumeSize
- AppVolumeSnapshotId
- AppVolumeType
- Label:
default: AutoScale Configuration
Expand Down Expand Up @@ -171,7 +176,7 @@ Metadata:
default: Force Cfn Init Update
ToggleNewInstances:
default: Force New Instances
Version: 1.12.0
Version: 1.13.0
Outputs:
ScaleDownScheduledAction:
Condition: UseScheduledAction
Expand Down Expand Up @@ -231,6 +236,14 @@ Parameters:
MaxValue: 16384
MinValue: 1
Type: Number
AppVolumeSnapshotId:
AllowedPattern: '^$|snap-[a-z0-9]+'
Default: ''
Description: >-
(Optional) EBS Snapshot ID from which to create the AppVolume. "AppVolumeSize"
must be equal or greater than the size of the snapshot. Ignored if "AppVolumeDevice"
is blank
Type: String
AppVolumeType:
AllowedValues:
- gp2
Expand Down Expand Up @@ -902,6 +915,10 @@ Resources:
- DeviceName: !Ref AppVolumeDevice
Ebs:
DeleteOnTermination: true
SnapshotId: !If
- UseAppVolumeSnapshot
- !Ref AppVolumeSnapshotId
- !Ref 'AWS::NoValue'
VolumeSize: !Ref AppVolumeSize
VolumeType: !Ref AppVolumeType
- !Ref 'AWS::NoValue'
Expand Down
1 change: 1 addition & 0 deletions modules/win-instance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ resource "aws_cloudformation_stack" "watchmaker-win-instance" {
AppScriptUrl = "${var.AppScriptUrl}"
AppVolumeDevice = "${var.AppVolumeDevice}"
AppVolumeSize = "${var.AppVolumeSize}"
AppVolumeSnapshotId = "${var.AppVolumeSnapshotId}"
AppVolumeType = "${var.AppVolumeType}"
CfnEndpointUrl = "${var.CfnEndpointUrl}"
CloudWatchAgentUrl = "${var.CloudWatchAgentUrl}"
Expand Down
6 changes: 6 additions & 0 deletions modules/win-instance/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ variable "AppVolumeSize" {
default = "1"
}

variable "AppVolumeSnapshotId" {
type = "string"
description = "(Optional) EBS Snapshot ID from which to create the AppVolume. \"AppVolumeSize\" must be equal or greater than the size of the snapshot. Ignored if \"AppVolumeDevice\" is blank"
default = ""
}

variable "KeyPairName" {
type = "string"
description = "Public/private key pairs allow you to securely connect to your instance after it launches"
Expand Down
19 changes: 18 additions & 1 deletion modules/win-instance/watchmaker-win-instance.template.cfn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Conditions:
- !Equals
- !Ref WatchmakerAdminUsers
- ''
UseAppVolumeSnapshot: !Not
- !Equals
- !Ref AppVolumeSnapshotId
- ''
UseCfnUrl: !Not
- !Equals
- !Ref CfnEndpointUrl
Expand Down Expand Up @@ -109,6 +113,7 @@ Metadata:
Parameters:
- AppVolumeDevice
- AppVolumeSize
- AppVolumeSnapshotId
- AppVolumeType
- Label:
default: Network Configuration
Expand All @@ -125,7 +130,7 @@ Metadata:
ParameterLabels:
ToggleCfnInitUpdate:
default: Force Cfn Init Update
Version: 1.12.0
Version: 1.13.0
Outputs:
WatchmakerInstanceId:
Description: Instance ID
Expand Down Expand Up @@ -174,6 +179,14 @@ Parameters:
MaxValue: 16384
MinValue: 1
Type: Number
AppVolumeSnapshotId:
AllowedPattern: '^$|snap-[a-z0-9]+'
Default: ''
Description: >-
(Optional) EBS Snapshot ID from which to create the AppVolume. "AppVolumeSize"
must be equal or greater than the size of the snapshot. Ignored if "AppVolumeDevice"
is blank
Type: String
AppVolumeType:
AllowedValues:
- gp2
Expand Down Expand Up @@ -726,6 +739,10 @@ Resources:
- DeviceName: !Ref AppVolumeDevice
Ebs:
DeleteOnTermination: true
SnapshotId: !If
- UseAppVolumeSnapshot
- !Ref AppVolumeSnapshotId
- !Ref 'AWS::NoValue'
VolumeSize: !Ref AppVolumeSize
VolumeType: !Ref AppVolumeType
- !Ref 'AWS::NoValue'
Expand Down

0 comments on commit 9630506

Please sign in to comment.