Skip to content

Commit bb20397

Browse files
author
Premdeep Saini
committed
add support for additional tags
1 parent b808416 commit bb20397

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

main.tf

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ resource "aws_instance" "gitlab" {
3030

3131
tags = merge({
3232
Name = "${local.environment_prefix}-gitlab"
33-
}, local.default_tags)
33+
}, local.default_tags, var.additional_tags)
3434

3535
}
3636

@@ -40,7 +40,7 @@ resource "aws_key_pair" "gitlab_ssh" {
4040
public_key = var.gitlab_ssh_public_key
4141
tags = merge({
4242
Name = "${local.environment_prefix}-gitlab-key-pair"
43-
}, local.default_tags)
43+
}, local.default_tags, var.additional_tags)
4444
}
4545

4646
data "aws_vpc" "vpc" {
@@ -105,7 +105,7 @@ resource "aws_security_group" "gitlab" {
105105
]
106106
tags = merge({
107107
Name = "${local.environment_prefix}-gitlab"
108-
}, local.default_tags)
108+
}, local.default_tags, var.additional_tags)
109109
}
110110

111111
resource "aws_security_group" "gitlab_lb" {
@@ -162,7 +162,7 @@ resource "aws_security_group" "gitlab_lb" {
162162
]
163163
tags = merge({
164164
Name = "${local.environment_prefix}-gitlab-lb"
165-
}, local.default_tags)
165+
}, local.default_tags, var.additional_tags)
166166
}
167167

168168
module "records" {
@@ -194,7 +194,7 @@ module "acm" {
194194

195195
tags = merge({
196196
Name = var.gitlab_domain
197-
}, local.default_tags)
197+
}, local.default_tags, var.additional_tags)
198198
}
199199

200200
module "elb" {
@@ -241,7 +241,7 @@ module "elb" {
241241

242242
tags = merge({
243243
Name = "${local.environment_prefix}-gitlab"
244-
}, local.default_tags)
244+
}, local.default_tags, var.additional_tags)
245245
}
246246

247247
module "gitlab_pg" {
@@ -268,7 +268,7 @@ module "gitlab_pg" {
268268
vpc_security_group_ids = [aws_security_group.gitlab_rds.id]
269269
tags = merge({
270270
Name = "${local.environment_prefix}-gitlab-pg"
271-
}, local.default_tags)
271+
}, local.default_tags, var.additional_tags)
272272
}
273273

274274
resource "aws_security_group" "gitlab_rds" {
@@ -290,7 +290,7 @@ resource "aws_security_group" "gitlab_rds" {
290290
]
291291
tags = merge({
292292
Name = "${local.environment_prefix}-gitlab-rds"
293-
}, local.default_tags)
293+
}, local.default_tags, var.additional_tags)
294294
}
295295

296296
resource "aws_elasticache_cluster" "gitlab_redis" {
@@ -306,7 +306,7 @@ resource "aws_elasticache_cluster" "gitlab_redis" {
306306

307307
tags = merge({
308308
Name = "${local.environment_prefix}-gitlab-redis"
309-
}, local.default_tags)
309+
}, local.default_tags, var.additional_tags)
310310

311311
lifecycle {
312312
precondition {
@@ -323,7 +323,9 @@ resource "aws_elasticache_parameter_group" "gitlab_redis" {
323323
count = var.gitlab_redis_create_parameter_group == true ? 1 : 0
324324
family = var.gitlab_redis_parameter_group.family
325325
name = var.gitlab_redis_parameter_group.name
326-
326+
tags = merge({
327+
Name = "${local.environment_prefix}-${var.gitlab_redis_parameter_group.name}"
328+
}, local.default_tags, var.additional_tags)
327329
lifecycle {
328330
precondition {
329331
condition = var.gitlab_redis_parameter_group.name != null && var.gitlab_redis_parameter_group.family != null
@@ -339,7 +341,7 @@ resource "aws_elasticache_subnet_group" "gitlab_redis" {
339341

340342
tags = merge({
341343
Name = "${local.environment_prefix}-gitlab-redis"
342-
}, local.default_tags)
344+
}, local.default_tags, var.additional_tags)
343345

344346
lifecycle {
345347
precondition {
@@ -368,7 +370,7 @@ resource "aws_security_group" "gitlab_redis" {
368370
]
369371
tags = merge({
370372
Name = "${local.environment_prefix}-gitlab-redis"
371-
}, local.default_tags)
373+
}, local.default_tags, var.additional_tags)
372374
}
373375

374376
resource "aws_s3_bucket" "gitlab_backup" {
@@ -377,7 +379,7 @@ resource "aws_s3_bucket" "gitlab_backup" {
377379

378380
tags = merge({
379381
Name = "${local.environment_prefix}-${var.gitlab_backup_bucket_name}"
380-
}, local.default_tags)
382+
}, local.default_tags, var.additional_tags)
381383

382384
lifecycle {
383385
precondition {
@@ -441,7 +443,7 @@ resource "aws_iam_policy" "gitlab_backup" {
441443
policy = data.aws_iam_policy_document.gitlab_s3_backup[0].json
442444
tags = merge({
443445
Name = "${local.environment_prefix}-gitlab-backup"
444-
}, local.default_tags)
446+
}, local.default_tags, var.additional_tags)
445447
}
446448

447449
resource "aws_iam_role" "gitlab_backup" {
@@ -464,15 +466,15 @@ EOF
464466
managed_policy_arns = var.enable_gitlab_backup_to_s3 ? [aws_iam_policy.gitlab_backup[0].arn] : []
465467
tags = merge({
466468
Name = "${local.environment_prefix}-gitlab-backup"
467-
}, local.default_tags)
469+
}, local.default_tags, var.additional_tags)
468470
}
469471

470472
resource "aws_iam_instance_profile" "gitlab" {
471473
name = "${local.environment_prefix}-gitlab"
472474
role = aws_iam_role.gitlab_backup.name
473475
tags = merge({
474476
Name = "${local.environment_prefix}-gitlab"
475-
}, local.default_tags)
477+
}, local.default_tags, var.additional_tags)
476478
}
477479

478480
data "template_file" "gitlab_config_template" {

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,9 @@ variable "ses_username" {
297297
description = "Username for Gitlab SMTP user"
298298
default = "gitlab_smtp_user"
299299
}
300+
301+
variable "additional_tags" {
302+
type = map(string)
303+
default = {}
304+
description = "A map of additional tags to attach to the resources."
305+
}

0 commit comments

Comments
 (0)