Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #10 from rb-nr/individual-resource-tags
Browse files Browse the repository at this point in the history
Individual resource tags
  • Loading branch information
Todd Radel authored Mar 3, 2021
2 parents c6657a6 + 95806fc commit 8fa1f31
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 20 deletions.
36 changes: 16 additions & 20 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
locals {
tags = merge(var.tags, {
Provider = "BanyanOps"
})

asg_tags = merge(local.tags, {
Name = "${var.site_name}-BanyanHost"
})
}

data aws_ami "default_ami" {
most_recent = true
owners = ["amazon"]
Expand Down Expand Up @@ -58,9 +68,7 @@ resource aws_security_group "sg" {
cidr_blocks = ["0.0.0.0/0"]
}

tags = merge(var.tags, {
Provider = "BanyanOps"
})
tags = merge(local.tags, var.security_group_tags)
}

resource "aws_autoscaling_group" "asg" {
Expand All @@ -76,10 +84,7 @@ resource "aws_autoscaling_group" "asg" {

dynamic "tag" {
# do another merge for application specific tags if need-be
for_each = merge(var.tags, {
Provider = "BanyanOps"
Name = "${var.site_name}-BanyanHost"
})
for_each = merge(local.asg_tags, var.autoscaling_group_tags)

content {
key = tag.key
Expand Down Expand Up @@ -138,9 +143,7 @@ resource aws_alb "nlb" {
subnets = var.public_subnet_ids
enable_cross_zone_load_balancing = var.cross_zone_enabled

tags = merge(var.tags, {
Provider = "BanyanOps"
})
tags = merge(local.tags, var.lb_tags)
}

resource aws_lb_target_group "target443" {
Expand All @@ -156,9 +159,7 @@ resource aws_lb_target_group "target443" {
unhealthy_threshold = 2
}

tags = merge(var.tags, {
Provider = "BanyanOps"
})
tags = merge(local.tags, var.target_group_tags)
}

resource aws_lb_listener "listener443" {
Expand Down Expand Up @@ -186,9 +187,7 @@ resource aws_lb_target_group "target80" {
unhealthy_threshold = 2
}

tags = merge(var.tags, {
Provider = "BanyanOps"
})
tags = merge(local.tags, var.target_group_tags)
}

resource aws_lb_listener "listener80" {
Expand Down Expand Up @@ -216,9 +215,7 @@ resource aws_lb_target_group "target8443" {
unhealthy_threshold = 2
}

tags = merge(var.tags, {
Provider = "BanyanOps"
})
tags = merge(local.tags, var.target_group_tags)
}

resource aws_lb_listener "listener8443" {
Expand All @@ -242,4 +239,3 @@ resource aws_autoscaling_policy "cpu_policy" {
target_value = 80
}
}

24 changes: 24 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,30 @@ variable "tags" {
default = null
}

variable "security_group_tags" {
type = map
description = "Additional tags to the security_group"
default = null
}

variable "autoscaling_group_tags" {
type = map
description = "Additional tags to the autoscaling_group"
default = null
}

variable "lb_tags" {
type = map
description = "Additional tags to the lb"
default = null
}

variable "target_group_tags" {
type = map
description = "Additional tags to each target_group"
default = null
}

variable "host_tags" {
type = map
description = "Additional tags to assign to this AccessTier"
Expand Down

0 comments on commit 8fa1f31

Please sign in to comment.