Skip to content

Commit a403256

Browse files
committed
Fix formating
1 parent 39ac42f commit a403256

File tree

7 files changed

+75
-29
lines changed

7 files changed

+75
-29
lines changed

examples/asg_disabled/main.tf

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,16 @@ data "aws_ami" "amazon_linux" {
5151
# Launch configuration and autoscaling group
5252
######
5353
module "example" {
54-
source = "../../"
55-
56-
name = "example-with-ec2"
57-
enabled = false
54+
source = "../../"
55+
name = "example-with-ec2"
56+
enabled = false
5857

5958
# Launch configuration
6059
#
6160
# launch_configuration = "my-existing-launch-configuration" # Use the existing launch configuration
6261
# create_lc = false # disables creation of launch configuration
6362
#lc_name = "example-lc"
64-
environment = "${var.environment}"
63+
environment = "${var.environment}"
6564

6665
image_id = "${data.aws_ami.amazon_linux.id}"
6766
instance_type = "t2.micro"
@@ -79,15 +78,16 @@ module "example" {
7978

8079
root_block_device = [
8180
{
82-
volume_size = "50"
83-
volume_type = "gp2"
81+
volume_size = "50"
82+
volume_type = "gp2"
8483
delete_on_termination = true
8584
},
8685
]
8786

8887
# Auto scaling group
8988
#asg_name = "example-asg"
90-
vpc_zone_identifier = ["${data.aws_subnet_ids.all.ids}"]
89+
vpc_zone_identifier = ["${data.aws_subnet_ids.all.ids}"]
90+
9191
health_check_type = "EC2"
9292
min_size = 0
9393
max_size = 1

examples/asg_disabled/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
variable "environment" {
22
default = "one"
33
}
4+
45
variable "region" {
56
default = "us-west-2"
67
}

examples/asg_ec2/main.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,14 @@ data "aws_ami" "amazon_linux" {
5252
######
5353
module "example" {
5454
source = "../../"
55-
56-
name = "example-with-ec2"
55+
name = "example-with-ec2"
5756

5857
# Launch configuration
5958
#
6059
# launch_configuration = "my-existing-launch-configuration" # Use the existing launch configuration
6160
# create_lc = false # disables creation of launch configuration
6261
#lc_name = "example-lc"
63-
environment = "${var.environment}"
62+
environment = "${var.environment}"
6463

6564
image_id = "${data.aws_ami.amazon_linux.id}"
6665
instance_type = "t2.micro"
@@ -78,15 +77,16 @@ module "example" {
7877

7978
root_block_device = [
8079
{
81-
volume_size = "50"
82-
volume_type = "gp2"
80+
volume_size = "50"
81+
volume_type = "gp2"
8382
delete_on_termination = true
8483
},
8584
]
8685

8786
# Auto scaling group
8887
#asg_name = "example-asg"
89-
vpc_zone_identifier = ["${data.aws_subnet_ids.all.ids}"]
88+
vpc_zone_identifier = ["${data.aws_subnet_ids.all.ids}"]
89+
9090
health_check_type = "EC2"
9191
min_size = 0
9292
max_size = 1

examples/asg_ec2/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
variable "environment" {
22
default = "one"
33
}
4+
45
variable "region" {
56
default = "us-west-2"
67
}

main.tf

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
###
32
### Terraform AWS Autoscaling
43
###
@@ -52,12 +51,15 @@ resource "aws_launch_configuration" "this" {
5251
ebs_optimized = "${var.ebs_optimized}"
5352
ephemeral_block_device = "${var.ephemeral_block_device}"
5453
root_block_device = "${var.root_block_device}"
54+
5555
lifecycle {
5656
create_before_destroy = true
5757
}
58+
5859
#spot_price = "${var.spot_price == "0" ? "" : var.spot_price}"
5960
# spot_price = "${var.spot_price}" // placement_tenancy does not work with spot_price
6061
}
62+
6163
/*
6264
# Attempt at improving the issue where it cannot delete the old LC on changes
6365
resource "null_resource" "delay" {
@@ -78,16 +80,17 @@ resource "null_resource" "delay" {
7880
# Autoscaling group
7981
####################
8082
resource "aws_autoscaling_group" "this" {
81-
/*depends_on = [
82-
"null_resource.delay"
83-
]*/
84-
count = "${module.enabled.value}"
85-
name_prefix = "${coalesce(var.asg_name, module.label.id)}-"
86-
launch_configuration = "${var.launch_configuration == "" ? element(aws_launch_configuration.this.*.name, 0) : var.launch_configuration}"
87-
vpc_zone_identifier = ["${var.vpc_zone_identifier}"]
88-
max_size = "${var.max_size}"
89-
min_size = "${var.min_size}"
90-
desired_capacity = "${var.desired_capacity}"
83+
#depends_on = [
84+
# "null_resource.delay"
85+
#]
86+
count = "${module.enabled.value}"
87+
88+
name_prefix = "${coalesce(var.asg_name, module.label.id)}-"
89+
launch_configuration = "${var.launch_configuration == "" ? element(aws_launch_configuration.this.*.name, 0) : var.launch_configuration}"
90+
vpc_zone_identifier = ["${var.vpc_zone_identifier}"]
91+
max_size = "${var.max_size}"
92+
min_size = "${var.min_size}"
93+
desired_capacity = "${var.desired_capacity}"
9194

9295
load_balancers = ["${var.load_balancers}"]
9396
health_check_grace_period = "${var.health_check_grace_period}"
@@ -115,6 +118,7 @@ resource "aws_autoscaling_group" "this" {
115118
),
116119
var.tags_ag
117120
)}"]
121+
118122
lifecycle {
119123
create_before_destroy = true
120124
}

outputs.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,4 @@ output "autoscaling_group_health_check_type" {
6969
// description = "List of Target Group ARNs that apply to this AutoScaling Group"
7070
// value = "${aws_autoscaling_group.this.target_group_arns}"
7171
//}
72+

variables.tf

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,167 +1,199 @@
1-
21
// Variables specific to module label
32
variable "attributes" {
43
description = "Suffix name with additional attributes (policy, role, etc.)"
54
type = "list"
65
default = []
76
}
7+
88
variable "delimiter" {
99
description = "Delimiter to be used between `name`, `namespaces`, `attributes`, etc."
1010
default = "-"
1111
}
12+
1213
variable "environment" {
1314
description = "Environment (ex: `dev`, `qa`, `stage`, `prod`). (Second or top level namespace. Depending on namespacing options)"
1415
}
16+
1517
variable "name" {
1618
description = "Base name for resources"
1719
}
20+
1821
variable "namespace-env" {
1922
description = "Prefix name with the environment. If true, format is: <env>-<name>"
2023
default = true
2124
}
25+
2226
variable "namespace-org" {
2327
description = "Prefix name with the organization. If true, format is: <org>-<env namespaced name>. If both env and org namespaces are used, format will be <org>-<env>-<name>"
2428
default = false
2529
}
30+
2631
variable "organization" {
2732
description = "Organization name (Top level namespace)."
2833
default = ""
2934
}
35+
3036
variable "tags" {
3137
description = "A map of additional tags"
3238
type = "map"
3339
default = {}
3440
}
3541

36-
3742
// Variables specific to this module
3843
variable "enabled" {
3944
description = "Set to false to prevent the module from creating anything"
4045
default = true
4146
}
4247

43-
4448
// Launch configuration variables
4549
variable "lc_name" {
4650
description = "Override launch configuration prefix name"
4751
default = ""
4852
}
53+
4954
variable "image_id" {
5055
description = "The EC2 image ID to launch"
5156
}
57+
5258
variable "instance_type" {
5359
description = "The size of instance to launch"
5460
}
61+
5562
variable "iam_instance_profile" {
5663
description = "The IAM instance profile to associate with launched instances"
5764
default = ""
5865
}
66+
5967
variable "key_name" {
6068
description = "The key name that should be used for the instance"
6169
default = ""
6270
}
71+
6372
variable "security_groups" {
6473
description = "A list of security group IDs to assign to the launch configuration"
6574
type = "list"
6675
}
76+
6777
variable "associate_public_ip_address" {
6878
description = "Associate a public ip address with an instance in a VPC"
6979
default = false
7080
}
81+
7182
variable "user_data" {
7283
description = "The user data to provide when launching the instance"
7384
default = ""
7485
}
86+
7587
variable "enable_monitoring" {
7688
description = "Enables/disables detailed monitoring. This is enabled by default."
7789
default = true
7890
}
91+
7992
variable "ebs_optimized" {
8093
description = "If true, the launched EC2 instance will be EBS-optimized"
8194
default = false
8295
}
96+
8397
variable "ebs_block_device" {
8498
description = "Additional EBS block devices to attach to the instance"
8599
type = "list"
86100
default = []
87101
}
102+
88103
variable "ephemeral_block_device" {
89104
description = "Customize Ephemeral (also known as 'Instance Store') volumes on the instance"
90105
type = "list"
91106
default = []
92107
}
108+
93109
variable "root_block_device" {
94110
description = "Customize details about the root block device of the instance"
95111
type = "list"
96112
default = []
97113
}
114+
98115
variable "placement_tenancy" {
99116
description = "The tenancy of the instance. Valid values are 'default' or 'dedicated'"
100117
default = "default"
101118
}
119+
102120
variable "spot_price" {
103121
description = "The price to use for reserving spot instances"
104122
default = 0
105123
}
106124

107-
108125
// Autoscaling group variables
109126
variable "asg_name" {
110127
description = "Override autoscaling group prefix name"
111128
default = ""
112129
}
130+
113131
variable "launch_configuration" {
114132
description = "The name of the launch configuration to use (if it is created outside of this module)"
115133
default = ""
116134
}
135+
117136
variable "max_size" {
118137
description = "The maximum size of the auto scale group"
119138
}
139+
120140
variable "min_size" {
121141
description = "The minimum size of the auto scale group"
122142
}
143+
123144
variable "desired_capacity" {
124145
description = "The number of Amazon EC2 instances that should be running in the group"
125146
}
147+
126148
variable "default_cooldown" {
127149
description = "The amount of time, in seconds, after a scaling activity completes before another scaling activity can start"
128150
default = 300
129151
}
152+
130153
variable "force_delete" {
131154
description = "Allows deleting the autoscaling group without waiting for all instances in the pool to terminate. You can force an autoscaling group to delete even if it's in the process of scaling a resource. Normally, Terraform drains all the instances before deleting the group. This bypasses that behavior and potentially leaves resources dangling"
132155
default = false
133156
}
157+
134158
variable "health_check_grace_period" {
135159
description = "Time (in seconds) after instance comes into service before checking health"
136160
default = 300
137161
}
162+
138163
variable "health_check_type" {
139164
description = "Controls how health checking is done. Values are - EC2 and ELB"
140165
}
166+
141167
variable "load_balancers" {
142168
description = "A list of elastic load balancer names to add to the autoscaling group names"
143169
default = []
144170
}
171+
145172
variable "suspended_processes" {
146173
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."
147174
default = []
148175
}
176+
149177
variable "target_group_arns" {
150178
description = "A list of aws_alb_target_group ARNs, for use with Application Load Balancing"
151179
default = []
152180
}
181+
153182
variable "termination_policies" {
154183
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"
155184
type = "list"
156185
default = ["OldestLaunchConfiguration", "Default"]
157186
}
187+
158188
variable "placement_group" {
159189
description = "The name of the placement group into which you'll launch your instances, if any"
160190
default = ""
161191
}
192+
162193
variable "enabled_metrics" {
163194
description = "A list of metrics to collect. The allowed values are GroupMinSize, GroupMaxSize, GroupDesiredCapacity, GroupInServiceInstances, GroupPendingInstances, GroupStandbyInstances, GroupTerminatingInstances, GroupTotalInstances"
164195
type = "list"
196+
165197
default = [
166198
"GroupMinSize",
167199
"GroupMaxSize",
@@ -173,30 +205,37 @@ variable "enabled_metrics" {
173205
"GroupTotalInstances",
174206
]
175207
}
208+
176209
variable "metrics_granularity" {
177210
description = "The granularity to associate with the metrics to collect. The only valid value is 1Minute"
178211
default = "1Minute"
179212
}
213+
180214
variable "min_elb_capacity" {
181215
description = "Setting this causes Terraform to wait for this number of instances to show up healthy in the ELB only on creation. Updates will not wait on ELB instance number changes"
182216
default = 0
183217
}
218+
184219
variable "protect_from_scale_in" {
185220
description = "Allows setting instance protection. The autoscaling group will not select instances with this setting for terminination during scale in events."
186221
default = false
187222
}
223+
188224
variable "tags_ag" {
189225
description = "Additional tags for Autoscaling group. A list of tag blocks. Each element is a map with key, value, and propagate_at_launch."
190226
default = []
191227
}
228+
192229
variable "vpc_zone_identifier" {
193230
description = "A list of subnet IDs to launch resources in"
194231
type = "list"
195232
}
233+
196234
variable "wait_for_capacity_timeout" {
197235
description = "A maximum duration that Terraform should wait for ASG instances to be healthy before timing out. (See also Waiting for Capacity below.) Setting this to '0' causes Terraform to skip all Capacity Waiting behavior."
198236
default = "10m"
199237
}
238+
200239
variable "wait_for_elb_capacity" {
201240
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."
202241
default = false

0 commit comments

Comments
 (0)