Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit 98edae0

Browse files
Magicloudketzacoatl
authored andcommitted
modules: update for Terraform 0.12.x
1 parent 33b797c commit 98edae0

File tree

337 files changed

+3830
-2657
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

337 files changed

+3830
-2657
lines changed

modules/ami-ubuntu/main.tf

+9-7
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
variable "most_recent" {
5050
default = true
5151
description = "boolean, maps to `most_recent` parameter for `aws_ami` data source"
52-
type = "string"
52+
type = string
5353
}
5454

5555
variable "name_map" {
@@ -62,19 +62,20 @@ variable "name_map" {
6262
}
6363

6464
description = "map of release numbers to names, including trusty, xenial, zesty, and artful"
65-
type = "map"
65+
type = map(string)
6666
}
6767

6868
variable "release" {
6969
default = "16.04"
7070
description = "default ubuntu release to target"
71-
type = "string"
71+
type = string
7272
}
7373

74-
data "aws_partition" "current" {}
74+
data "aws_partition" "current" {
75+
}
7576

7677
data "aws_ami" "ubuntu" {
77-
most_recent = "${var.most_recent}"
78+
most_recent = var.most_recent
7879

7980
filter {
8081
name = "name"
@@ -86,10 +87,11 @@ data "aws_ami" "ubuntu" {
8687
values = ["hvm"]
8788
}
8889

89-
owners = ["${data.aws_partition.current.partition == "aws-us-gov" ? "513442679011" : "099720109477"}"] # Canonical
90+
owners = [data.aws_partition.current.partition == "aws-us-gov" ? "513442679011" : "099720109477"] # Canonical
9091
}
9192

9293
output "id" {
93-
value = "${data.aws_ami.ubuntu.id}"
94+
value = data.aws_ami.ubuntu.id
9495
description = "ID of the AMI"
9596
}
97+

modules/ami-ubuntu/versions.tf

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
terraform {
3+
required_version = ">= 0.12"
4+
}

modules/asg-lifecycle/main.tf

+15-14
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
# Auto-Scaling Group
2626
resource "aws_autoscaling_group" "cluster" {
2727
name = "${var.name_prefix}-${aws_launch_configuration.cluster.name}"
28-
launch_configuration = "${aws_launch_configuration.cluster.id}"
29-
availability_zones = ["${var.azs}"]
30-
load_balancers = ["${var.elb_names}"]
31-
vpc_zone_identifier = ["${var.subnet_ids}"]
28+
launch_configuration = aws_launch_configuration.cluster.id
29+
availability_zones = var.azs
30+
load_balancers = var.elb_names
31+
vpc_zone_identifier = var.subnet_ids
3232

3333
min_size = "1"
34-
desired_capacity = "${var.instance_count}"
34+
desired_capacity = var.instance_count
3535
max_size = "4"
3636

3737
lifecycle {
@@ -43,23 +43,24 @@ resource "aws_autoscaling_group" "cluster" {
4343
default_result = "CONTINUE"
4444
heartbeat_timeout = 60
4545
lifecycle_transition = "autoscaling:EC2_INSTANCE_TERMINATING"
46-
notification_target_arn = "${var.sns_topic_arn}"
47-
role_arn = "${var.aws_role_arn}"
46+
notification_target_arn = var.sns_topic_arn
47+
role_arn = var.aws_role_arn
4848
}
4949
}
5050

5151
# Launch Config for the ASG
5252
resource "aws_launch_configuration" "cluster" {
53-
name_prefix = "${var.name_prefix}"
54-
image_id = "${var.instance_ami}"
55-
instance_type = "${var.instance_type}"
56-
key_name = "${var.instance_key}"
57-
iam_instance_profile = "${var.aws_instance_ec2_name}"
58-
security_groups = ["${var.aws_sg_id}", "${var.elb_sg_id}"]
53+
name_prefix = var.name_prefix
54+
image_id = var.instance_ami
55+
instance_type = var.instance_type
56+
key_name = var.instance_key
57+
iam_instance_profile = var.aws_instance_ec2_name
58+
security_groups = [var.aws_sg_id, var.elb_sg_id]
5959

60-
user_data = "${var.asg_template_file}"
60+
user_data = var.asg_template_file
6161

6262
lifecycle {
6363
create_before_destroy = true
6464
}
6565
}
66+

modules/asg-lifecycle/variables.tf

+15-3
Original file line numberDiff line numberDiff line change
@@ -7,68 +7,80 @@ variable "name_prefix" {
77

88
variable "azs" {
99
description = "list of availability zones to associate with the ASG"
10-
type = "list"
10+
type = list(string)
1111
}
1212

1313
variable "elb_names" {
1414
default = []
1515
description = "list of load balancers to associate with the ASG (by name)"
16-
type = "list"
16+
type = list(string)
1717
}
1818

1919
variable "subnet_ids" {
2020
description = "IDs of subnets where the instances will be provisioned."
21-
type = "list"
21+
type = list(string)
2222
}
2323

2424
variable "instance_count" {
2525
description = "Desired (and minimum) number of instances."
2626
default = "2"
27+
type = number
2728
}
2829

2930
variable "instance_ami" {
3031
description = "ID of an Amazon Linux 2 AMI. (Comes with SSM agent installed)"
3132
default = "ami-db51c2a2"
33+
type = string
3234
}
3335

3436
variable "instance_type" {
3537
description = "Type of instance to provision."
3638
default = "t2.micro"
39+
type = string
3740
}
3841

3942
variable "instance_key" {
4043
description = "Name of an EC2 key pair which will be allowed to SSH to the instance."
4144
default = ""
45+
type = string
4246
}
4347

4448
variable "elb_sg_id" {
4549
description = "ID of the VPC for the subnets."
50+
type = string
4651
}
4752

4853
variable "asg_template_file" {
4954
description = "Cloud init script for the autoscaling group"
55+
type = string
5056
}
5157

5258
variable "sns_topic_arn" {
5359
description = "ARN for the SNS topic"
60+
type = string
5461
}
5562

5663
variable "vpc_id" {
5764
description = "ID of the VPC for the subnets."
65+
type = string
5866
}
5967

6068
variable "elb_arn" {
6169
description = "ARN for the elb"
70+
type = string
6271
}
6372

6473
variable "aws_role_arn" {
6574
description = "ARN for the AWS Role"
75+
type = string
6676
}
6777

6878
variable "aws_instance_ec2_name" {
6979
description = "AWS IAM EC2 Name"
80+
type = string
7081
}
7182

7283
variable "aws_sg_id" {
7384
description = "AWS Security group ID"
85+
type = string
7486
}

modules/asg-lifecycle/versions.tf

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
terraform {
3+
required_version = ">= 0.12"
4+
}

modules/asg/main.tf

+28-25
Original file line numberDiff line numberDiff line change
@@ -24,51 +24,54 @@
2424
*/
2525
# Auto-Scaling Group
2626
resource "aws_autoscaling_group" "cluster" {
27-
availability_zones = ["${var.azs}"]
27+
availability_zones = var.azs
2828
force_delete = true
2929
health_check_grace_period = 300
3030
health_check_type = "EC2"
31-
launch_configuration = "${aws_launch_configuration.cluster.name}"
32-
load_balancers = ["${var.elb_names}"]
33-
max_size = "${var.max_nodes}"
34-
min_size = "${var.min_nodes}"
31+
launch_configuration = aws_launch_configuration.cluster.name
32+
load_balancers = var.elb_names
33+
max_size = var.max_nodes
34+
min_size = var.min_nodes
3535
name_prefix = "${var.name_prefix}-${var.name_suffix}"
36-
placement_group = "${var.placement_group}"
37-
termination_policies = ["${var.termination_policies}"]
36+
placement_group = var.placement_group
37+
termination_policies = var.termination_policies
3838

3939
lifecycle {
4040
create_before_destroy = true
4141
}
4242

43-
vpc_zone_identifier = ["${var.subnet_ids}"]
43+
vpc_zone_identifier = var.subnet_ids
4444

45-
tags = ["${concat(
46-
list(
47-
map("key", "Name",
48-
"value", "${var.name_prefix}-${var.name_suffix}",
49-
"propagate_at_launch", true)
50-
),
51-
var.extra_tags
52-
)}"]
45+
tags = concat(
46+
[
47+
{
48+
"key" = "Name"
49+
"value" = "${var.name_prefix}-${var.name_suffix}"
50+
"propagate_at_launch" = true
51+
},
52+
],
53+
var.extra_tags,
54+
)
5355
}
5456

5557
# Launch Config for the ASG
5658
resource "aws_launch_configuration" "cluster" {
5759
# omit name so it's generated as a unique value
58-
associate_public_ip_address = "${var.public_ip}"
59-
iam_instance_profile = "${var.iam_profile}"
60-
image_id = "${var.ami}"
61-
instance_type = "${var.instance_type}"
62-
key_name = "${var.key_name}"
63-
security_groups = ["${var.security_group_ids}"]
64-
user_data = "${var.user_data}"
60+
associate_public_ip_address = var.public_ip
61+
iam_instance_profile = var.iam_profile
62+
image_id = var.ami
63+
instance_type = var.instance_type
64+
key_name = var.key_name
65+
security_groups = var.security_group_ids
66+
user_data = var.user_data
6567

6668
root_block_device {
67-
volume_type = "${var.root_volume_type}"
68-
volume_size = "${var.root_volume_size}"
69+
volume_type = var.root_volume_type
70+
volume_size = var.root_volume_size
6971
}
7072

7173
lifecycle {
7274
create_before_destroy = true
7375
}
7476
}
77+

modules/asg/outputs.tf

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
output "name" {
2-
value = "${aws_autoscaling_group.cluster.name}"
2+
value = aws_autoscaling_group.cluster.name
33
description = "Name of the ASG"
44
}
55

66
output "id" {
7-
value = "${aws_autoscaling_group.cluster.id}"
7+
value = aws_autoscaling_group.cluster.id
88
description = "ID of the ASG"
99
}
1010

1111
output "lc_id" {
12-
value = "${aws_launch_configuration.cluster.id}"
12+
value = aws_launch_configuration.cluster.id
1313
description = "ID of the Launch Config"
1414
}
1515

1616
output "lc_name" {
17-
value = "${aws_launch_configuration.cluster.name}"
17+
value = aws_launch_configuration.cluster.name
1818
description = "Name of the Launch Config"
1919
}
20+

0 commit comments

Comments
 (0)