Skip to content

Commit 57a50f3

Browse files
committed
upgrade for tf v0.12
1 parent 7ef872b commit 57a50f3

File tree

15 files changed

+140
-192
lines changed

15 files changed

+140
-192
lines changed

examples/single-node/outputs.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,4 @@ output "bastion_public_eip" {
9292

9393
output "gitlab_private_ip" {
9494
value = module.gitlab.gitlab_private_ip
95-
}
96-
95+
}

module/single-node-omnibus/acm.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
resource "aws_acm_certificate" "gitlab_cert" {
2-
domain_name = "${var.dns_name}"
2+
domain_name = var.dns_name
33
validation_method = "DNS"
4-
tags = "${module.gitlab_label.tags}"
4+
tags = module.gitlab_label.tags
55

66
lifecycle {
77
create_before_destroy = true
88
}
99
}
1010

1111
resource "aws_acm_certificate_validation" "gitlab_cert_validation" {
12-
certificate_arn = "${aws_acm_certificate.gitlab_cert.arn}"
13-
validation_record_fqdns = ["${aws_route53_record.cert_validation.fqdn}"]
12+
certificate_arn = aws_acm_certificate.gitlab_cert.arn
13+
validation_record_fqdns = [aws_route53_record.cert_validation.fqdn]
1414
}

module/single-node-omnibus/alb.tf

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
resource "aws_lb" "gitlab_alb" {
22
load_balancer_type = "application"
3-
idle_timeout = "${var.gitlab_alb_ideal_timeout}"
3+
idle_timeout = var.gitlab_alb_ideal_timeout
44
internal = false
5-
security_groups = ["${aws_security_group.gitlab_alb.id}"]
5+
security_groups = [aws_security_group.gitlab_alb.id]
66
ip_address_type = "ipv4"
7-
subnets = ["${var.public_subnet_id}"]
8-
tags = "${merge (module.gitlab_label.tags, map ("Role", module.gitlab_label.name ))}"
7+
subnets = var.public_subnet_id
8+
tags = {"Name" = format("%s-alb", module.gitlab_label.name), "Environment" = module.gitlab_label.stage}
99
}
1010

1111
resource "aws_lb_target_group" "gitlab_alb_tg" {
1212
port = 443
1313
protocol = "HTTPS"
14-
vpc_id = "${var.vpc_id}"
15-
14+
vpc_id = var.vpc_id
15+
tags = {"Name" = format("%s-alb-tg", module.gitlab_label.name), "Environment" = module.gitlab_label.stage}
1616
health_check {
1717
port = "traffic-port"
1818
protocol = "HTTPS"
@@ -26,32 +26,32 @@ resource "aws_lb_target_group" "gitlab_alb_tg" {
2626
}
2727

2828
resource "aws_lb_listener" "gitlab_alb_https_listener" {
29-
load_balancer_arn = "${aws_lb.gitlab_alb.arn}"
29+
load_balancer_arn = aws_lb.gitlab_alb.arn
3030
port = 443
3131
protocol = "HTTPS"
3232
ssl_policy = "ELBSecurityPolicy-2016-08"
33-
certificate_arn = "${aws_acm_certificate.gitlab_cert.arn}"
33+
certificate_arn = aws_acm_certificate.gitlab_cert.arn
3434
default_action {
35-
target_group_arn = "${aws_lb_target_group.gitlab_alb_tg.arn}"
35+
target_group_arn = aws_lb_target_group.gitlab_alb_tg.arn
3636
type = "forward"
3737
}
3838
}
3939

4040

4141
resource "aws_lb_listener" "gitlab_registry_alb_https_listener" {
42-
load_balancer_arn = "${aws_lb.gitlab_alb.arn}"
43-
port = 4000
44-
protocol = "HTTPS"
45-
ssl_policy = "ELBSecurityPolicy-2016-08"
46-
certificate_arn = "${aws_acm_certificate.gitlab_cert.arn}"
42+
load_balancer_arn = aws_lb.gitlab_alb.arn
43+
port = 4000
44+
protocol = "HTTPS"
45+
ssl_policy = "ELBSecurityPolicy-2016-08"
46+
certificate_arn = aws_acm_certificate.gitlab_cert.arn
4747
default_action {
48-
target_group_arn = "${aws_lb_target_group.gitlab_alb_tg.arn}"
48+
target_group_arn = aws_lb_target_group.gitlab_alb_tg.arn
4949
type = "forward"
5050
}
5151
}
5252

5353
resource "aws_lb_target_group_attachment" "gitlab_alb_tg_attachment" {
54-
target_group_arn = "${aws_lb_target_group.gitlab_alb_tg.arn}"
55-
target_id = "${aws_instance.gitlab_application.id}"
54+
target_group_arn = aws_lb_target_group.gitlab_alb_tg.arn
55+
target_id = aws_instance.gitlab_application.id
5656
port = 443
5757
}

module/single-node-omnibus/bastion.tf

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
11
resource "aws_instance" "bastion" {
22
instance_type = "t2.micro"
3-
subnet_id = "${data.aws_subnet.public_selected.id}"
4-
security_groups = ["${aws_security_group.external_ssh.id}"]
5-
key_name = "${var.ssh_key_name}"
6-
ami = "${data.aws_ami.centos.id}"
7-
tags = "${
8-
merge(
9-
map(
10-
"Name", "${module.gitlab_label.name}-bastion",
11-
"Role", "${replace(module.gitlab_label.name, "-", "_")}"
12-
)
13-
)}"
3+
subnet_id = data.aws_subnet.public_selected.id
4+
security_groups = [aws_security_group.external_ssh.id]
5+
key_name = var.ssh_key_name
6+
ami = data.aws_ami.centos.id
7+
volume_tags = { "Name" = format("%s-bastion-ebs", module.gitlab_label.name), "Environment" = module.gitlab_label.stage}
8+
tags = { "Name" = format("%s-bastion", module.gitlab_label.name), "Environment" = module.gitlab_label.stage}
149
}
1510

1611
resource "aws_eip" "bastion" {
17-
instance = "${aws_instance.bastion.id}"
12+
instance = aws_instance.bastion.id
1813
vpc = true
19-
20-
tags = "${
21-
merge(
22-
map(
23-
"Name", "${module.gitlab_label.name}-bastion-eip",
24-
"Role", "${replace(module.gitlab_label.name, "-", "_")}"
25-
)
26-
)}"
14+
tags = { "Name" = format("%s-bastion-eip", module.gitlab_label.name), "Environment"= module.gitlab_label.stage}
2715
}

module/single-node-omnibus/ebs.tf

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,47 @@
11
resource "aws_ebs_volume" "gitlab_data" {
2-
size = "${var.gitlab_data_disk_size}"
3-
kms_key_id = "${aws_kms_key.gitlab_kms_key.arn}"
2+
size = var.gitlab_data_disk_size
3+
kms_key_id = aws_kms_key.gitlab_kms_key.arn
44
encrypted = true
55
type = "gp2"
6-
availability_zone = "${data.aws_subnet.private_selected.availability_zone}"
7-
tags = "${
8-
merge(
9-
map(
10-
"Name", "${module.gitlab_label.name}_data_disk",
11-
"Type", "gitlab-data",
12-
"snapshot_policy", "${module.gitlab_label.name}-data daily snapshots",
13-
"Snapshot", "true"
14-
)
15-
)}"
6+
availability_zone = data.aws_subnet.private_selected.availability_zone
7+
tags = {
8+
"Name" = format("%s-data-disk",module.gitlab_label.name),
9+
"Type" = "gitlab-data",
10+
"snapshot_policy" = format("%s-data daily snapshots", module.gitlab_label.name),
11+
"Snapshot"= "true"
12+
}
1613
}
1714

1815
resource "aws_volume_attachment" "gitlab_data_attachment" {
19-
device_name = "${var.gitlab_data_disk_device_name}"
20-
volume_id = "${aws_ebs_volume.gitlab_data.id}"
21-
instance_id = "${aws_instance.gitlab_application.id}"
16+
device_name = var.gitlab_data_disk_device_name
17+
volume_id = aws_ebs_volume.gitlab_data.id
18+
instance_id = aws_instance.gitlab_application.id
2219
force_detach = true
2320
}
2421

25-
resource "aws_dlm_lifecycle_policy" "data" {
22+
resource "aws_dlm_lifecycle_policy" "gitlab_data_snapshot_policy" {
2623
description = "Gitlab Data Volume DLM lifecycle policy"
27-
execution_role_arn = "${aws_iam_role.dlm_lifecycle_role.arn}"
24+
execution_role_arn = aws_iam_role.dlm_lifecycle_role.arn
2825
state = "ENABLED"
2926

3027
policy_details {
3128
resource_types = ["VOLUME"]
3229

3330
schedule {
34-
name = "${module.gitlab_label.name}-data daily snapshots"
31+
name = format("%s-data daily snapshots", module.gitlab_label.name)
3532

3633
create_rule {
37-
interval = "${var.snapshot_interval}"
34+
interval = var.snapshot_interval
3835
interval_unit = "HOURS"
39-
times = ["${var.snapshot_start_time}"]
36+
times = flatten(var.snapshot_start_time)
4037
}
4138

4239
retain_rule {
43-
count = "${var.retain_rule}"
40+
count = var.retain_rule
4441
}
4542

4643
tags_to_add = {
47-
Snapshot_type = "${module.gitlab_label.name}-data-daily-snapshot"
44+
Snapshot_type = format("%s-data daily snapshots", module.gitlab_label.name)
4845
}
4946

5047
copy_tags = true

module/single-node-omnibus/ec2.tf

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
resource "aws_instance" "gitlab_application" {
2-
ami = "${var.gitlab_application_ami}"
2+
ami = var.gitlab_application_ami
33
instance_type = "m4.xlarge"
4-
subnet_id = "${data.aws_subnet.private_selected.id}"
5-
security_groups = ["${aws_security_group.internal_ssh.id}", "${aws_security_group.internal_gitlab.id}"]
6-
key_name = "${var.ssh_key_name}"
7-
user_data = "${data.template_cloudinit_config.config.rendered}"
4+
subnet_id = data.aws_subnet.private_selected.id
5+
security_groups = flatten([aws_security_group.internal_ssh.id ,aws_security_group.internal_gitlab.id])
6+
key_name = var.ssh_key_name
7+
user_data = data.template_cloudinit_config.config.rendered
88
associate_public_ip_address = false
99
monitoring = true
10-
tags = "${
11-
merge(
12-
map(
13-
"Name", "${module.gitlab_label.name}",
14-
"Role", "${replace(module.gitlab_label.name, "-", "_")}"
15-
)
16-
)}"
10+
volume_tags = { "Name" = format("%s-instance-ebs", module.gitlab_label.name), "Environment" = module.gitlab_label.stage}
11+
tags = { "Name" = format("%s-instance", module.gitlab_label.name), "Environment" = module.gitlab_label.stage}
1712
}
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
module "gitlab_label" {
22
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.14.1"
3-
namespace = "${var.namespace}"
4-
stage = "${var.stage}"
5-
name = "${var.name}"
6-
attributes = "${var.attributes}"
7-
delimiter = "${var.delimiter}"
8-
tags = {
9-
"Name" = "${var.name}"
10-
"Environment" = "${var.stage}"
11-
}
3+
namespace = var.namespace
4+
stage = var.stage
5+
name = var.name
6+
attributes = var.attributes
7+
delimiter = var.delimiter
8+
tags = { "Name" = var.name, "Environment" = var.stage }
129
}

module/single-node-omnibus/iam.tf

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
resource "aws_iam_user" "s3_user" {
2-
name = "${var.name}"
3-
path = "/"
2+
name = module.gitlab_label.name
3+
path = "/"
44
force_destroy = "false"
55
}
66

77

88
resource "aws_iam_user_policy_attachment" "s3_allow_policy" {
9-
user = "${aws_iam_user.s3_user.name}"
10-
policy_arn = "${aws_iam_policy.s3_policy.arn}"
9+
user = aws_iam_user.s3_user.name
10+
policy_arn = aws_iam_policy.s3_policy.arn
1111
}
1212

1313
resource "aws_iam_user_policy_attachment" "deny_put_acl" {
14-
user = "${aws_iam_user.s3_user.name}"
15-
policy_arn = "${aws_iam_policy.deny_put_acl.arn}"
14+
user = aws_iam_user.s3_user.name
15+
policy_arn = aws_iam_policy.deny_put_acl.arn
1616
}
1717

1818

1919
resource "aws_iam_access_key" "s3_access_key" {
20-
user = "${aws_iam_user.s3_user.name}"
20+
user = aws_iam_user.s3_user.name
2121
}
2222

2323
resource "aws_iam_policy" "s3_policy" {
24-
name = "${var.name}_policy"
24+
name = format("%s-policy",module.gitlab_label.name)
2525
path = "/"
26-
description = "${var.name}_policy"
26+
description = format("%s-policy",module.gitlab_label.name)
2727
policy = <<EOF
2828
{
2929
"Version": "2012-10-17",
@@ -44,7 +44,7 @@ EOF
4444
}
4545

4646
resource "aws_iam_policy" "deny_put_acl" {
47-
name = "${var.name}_deny_put_acl_policy"
47+
name = format("%s-deny-put-acl-policy",module.gitlab_label.name)
4848
path = "/"
4949
description = "deny_put_acl"
5050
policy = <<EOF
@@ -88,7 +88,7 @@ EOF
8888

8989
resource "aws_iam_role_policy" "dlm_lifecycle" {
9090
name = "dlm-lifecycle-policy"
91-
role = "${aws_iam_role.dlm_lifecycle_role.id}"
91+
role = aws_iam_role.dlm_lifecycle_role.id
9292

9393
policy = <<EOF
9494
{

module/single-node-omnibus/kms.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
resource "aws_kms_key" "gitlab_kms_key" {
22
description = "Gitlab KMS key"
33
deletion_window_in_days = 10
4-
tags = "${module.gitlab_label.tags}"
5-
enable_key_rotation = "${var.enable_key_rotation}"
4+
tags = module.gitlab_label.tags
5+
enable_key_rotation = var.enable_key_rotation
66
}
77

88
resource "aws_kms_alias" "gitlab_kms_key_alias" {
9-
name = "${coalesce(var.alias, format("alias/%v", module.gitlab_label.id))}"
10-
target_key_id = "${aws_kms_key.gitlab_kms_key.key_id}"
9+
name = coalesce(var.alias, format("alias/%v", module.gitlab_label.id))
10+
target_key_id = aws_kms_key.gitlab_kms_key.key_id
1111
}

module/single-node-omnibus/local-resources.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# use this resource when a module accepts a subnet id as an input variable and needs to, for example, determine the id of the VPC that the subnet belongs to.
22
data "aws_subnet" "private_selected" {
3-
id = "${element (["${var.private_subnet_id}"], 0)}"
3+
id = element(var.private_subnet_id, 0)
44
}
55

66
data "aws_subnet" "public_selected" {
7-
id = "${element (["${var.public_subnet_id}"], 0)}"
7+
id = element(var.public_subnet_id, 0)
88
}
99

1010
# Use this data source to get the access to the effective Account ID, User ID, and ARN in which Terraform is authorized.
@@ -49,6 +49,7 @@ data "template_cloudinit_config" "config" {
4949
part {
5050
content_type = "text/cloud-config"
5151
content = "${data.template_file.gitlab_application_user_data.rendered}"
52-
}
52+
}
5353
}
5454

55+

0 commit comments

Comments
 (0)