Skip to content

Commit

Permalink
feat: update subnet tag
Browse files Browse the repository at this point in the history
  • Loading branch information
theprashantyadav committed Aug 1, 2023
1 parent 4c2c5de commit c6d1a30
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 80 deletions.
2 changes: 1 addition & 1 deletion _example/alb/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module "vpc" {
##-----------------------------------------------------
module "public_subnets" {
source = "clouddrove/subnet/aws"
version = "1.3.0"
version = "2.0.0"

name = "public-subnet"
environment = "test"
Expand Down
4 changes: 2 additions & 2 deletions _example/alb/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
output "arn" {
value = module.alb.*.arn
value = module.alb[*].arn
description = "The ARN suffix of the ALB"
}

Expand All @@ -9,6 +9,6 @@ output "tags" {
}

output "main_target_group_arn" {
value = module.alb.*.main_target_group_arn
value = module.alb[*].main_target_group_arn
description = "The ARN target of the ALB"
}
11 changes: 11 additions & 0 deletions _example/alb/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Terraform version
terraform {
required_version = ">= 1.5.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.9.0"
}
}
}
2 changes: 1 addition & 1 deletion _example/clb/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module "vpc" {
##-----------------------------------------------------
module "public_subnets" {
source = "clouddrove/subnet/aws"
version = "1.3.0"
version = "2.0.0"

name = "public-subnet"
environment = "test"
Expand Down
2 changes: 1 addition & 1 deletion _example/clb/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
output "arn" {
value = module.clb.*.clb_arn
value = module.clb[*].clb_arn
description = "The ARN suffix of the ALB"
}

Expand Down
11 changes: 11 additions & 0 deletions _example/clb/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Terraform version
terraform {
required_version = ">= 1.5.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.9.0"
}
}
}
2 changes: 1 addition & 1 deletion _example/nlb/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module "vpc" {
##-----------------------------------------------------
module "public_subnets" {
source = "clouddrove/subnet/aws"
version = "1.3.0"
version = "2.0.0"

name = "public-subnet"
environment = "test"
Expand Down
2 changes: 1 addition & 1 deletion _example/nlb/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
output "arn" {
value = module.nlb.*.arn
value = module.nlb[*].arn
description = "The ARN suffix of the ALB"
}

Expand Down
11 changes: 11 additions & 0 deletions _example/nlb/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Terraform version
terraform {
required_version = ">= 1.5.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.9.0"
}
}
}
16 changes: 8 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ resource "aws_lb" "main" {
resource "aws_lb_listener" "https" {
count = var.enable == true && var.with_target_group && var.https_enabled == true && var.load_balancer_type == "application" ? 1 : 0

load_balancer_arn = element(aws_lb.main.*.arn, count.index)
load_balancer_arn = element(aws_lb.main[*].arn, count.index)
port = var.https_port
protocol = var.listener_protocol
ssl_policy = "ELBSecurityPolicy-TLS-1-2-2017-01"
certificate_arn = var.listener_certificate_arn
default_action {
target_group_arn = join("", aws_lb_target_group.main.*.arn)
target_group_arn = join("", aws_lb_target_group.main[*].arn)
type = var.listener_type

dynamic "fixed_response" {
Expand All @@ -86,11 +86,11 @@ resource "aws_lb_listener" "https" {
resource "aws_lb_listener" "http" {
count = var.enable == true && var.with_target_group && var.http_enabled == true && var.load_balancer_type == "application" ? 1 : 0

load_balancer_arn = element(aws_lb.main.*.arn, count.index)
load_balancer_arn = element(aws_lb.main[*].arn, count.index)
port = var.http_port
protocol = "HTTP"
default_action {
target_group_arn = element(aws_lb_target_group.main.*.arn, count.index)
target_group_arn = element(aws_lb_target_group.main[*].arn, count.index)
type = var.http_listener_type
redirect {
port = var.https_port
Expand All @@ -107,7 +107,7 @@ resource "aws_lb_listener" "http" {
resource "aws_lb_listener" "nhttps" {
count = var.enable == true && var.with_target_group && var.https_enabled == true && var.load_balancer_type == "network" ? length(var.https_listeners) : 0

load_balancer_arn = element(aws_lb.main.*.arn, count.index)
load_balancer_arn = element(aws_lb.main[*].arn, count.index)
port = var.https_listeners[count.index]["port"]
protocol = lookup(var.https_listeners[count.index], "protocol", "HTTPS")
certificate_arn = var.https_listeners[count.index]["certificate_arn"]
Expand All @@ -125,7 +125,7 @@ resource "aws_lb_listener" "nhttps" {
resource "aws_lb_listener" "nhttp" {
count = var.enable == true && var.with_target_group && var.load_balancer_type == "network" ? length(var.http_tcp_listeners) : 0

load_balancer_arn = element(aws_lb.main.*.arn, 0)
load_balancer_arn = element(aws_lb.main[*].arn, 0)
port = var.http_tcp_listeners[count.index]["port"]
protocol = var.http_tcp_listeners[count.index]["protocol"]
default_action {
Expand Down Expand Up @@ -182,15 +182,15 @@ resource "aws_lb_target_group" "main" {
resource "aws_lb_target_group_attachment" "attachment" {
count = var.enable && var.with_target_group && var.load_balancer_type == "application" && var.target_type == "" ? var.instance_count : 0

target_group_arn = element(aws_lb_target_group.main.*.arn, count.index)
target_group_arn = element(aws_lb_target_group.main[*].arn, count.index)
target_id = element(var.target_id, count.index)
port = var.target_group_port
}

resource "aws_lb_target_group_attachment" "nattachment" {
count = var.enable && var.with_target_group && var.load_balancer_type == "network" ? length(var.https_listeners) : 0

target_group_arn = element(aws_lb_target_group.main.*.arn, count.index)
target_group_arn = element(aws_lb_target_group.main[*].arn, count.index)
target_id = element(var.target_id, 0)
port = lookup(var.target_groups[count.index], "backend_port", null)
}
Expand Down
24 changes: 12 additions & 12 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
#Module : ALB
#Description : This terraform module is used to create ALB on AWS.
output "name" {
value = join("", aws_lb.main.*.name)
value = join("", aws_lb.main[*].name)
description = "The ARN suffix of the ALB."
}

output "arn" {
value = join("", concat(aws_lb.main.*.arn))
value = join("", concat(aws_lb.main[*].arn))
description = "The ARN of the ALB."
}

output "clb_arn" {
value = join("", concat(aws_elb.main.*.arn))
value = join("", concat(aws_elb.main[*].arn))
description = "The ARN of the CLB."
}
output "arn_suffix" {
value = join("", aws_lb.main.*.arn_suffix)
value = join("", aws_lb.main[*].arn_suffix)
description = "The ARN suffix of the ALB."
}

output "dns_name" {
value = join("", aws_lb.main.*.dns_name)
value = join("", aws_lb.main[*].dns_name)
description = "DNS name of ALB."
}

output "clb_name" {
value = join("", aws_elb.main.*.dns_name)
value = join("", aws_elb.main[*].dns_name)
description = "DNS name of CLB."
}
output "zone_id" {
value = join("", aws_lb.main.*.zone_id)
value = join("", aws_lb.main[*].zone_id)
description = "The ID of the zone which ALB is provisioned."
}

output "clb_zone_id" {
value = join("", aws_elb.main.*.zone_id)
value = join("", aws_elb.main[*].zone_id)
description = "The ID of the zone which ALB is provisioned."
}
output "main_target_group_arn" {
value = join("", aws_lb_target_group.main.*.arn)
value = join("", aws_lb_target_group.main[*].arn)
description = "The main target group ARN."
}

output "http_listener_arn" {
value = join("", aws_lb_listener.http.*.arn)
value = join("", aws_lb_listener.http[*].arn)
description = "The ARN of the HTTP listener."
}

output "https_listener_arn" {
value = join("", aws_lb_listener.https.*.arn)
value = join("", aws_lb_listener.https[*].arn)
description = "The ARN of the HTTPS listener."
}

output "listener_arns" {
value = compact(concat(aws_lb_listener.http.*.arn, aws_lb_listener.https.*.arn))
value = compact(concat(aws_lb_listener.http[*].arn, aws_lb_listener.https[*].arn))
description = "A list of all the listener ARNs."
}

Expand Down
50 changes: 0 additions & 50 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,6 @@ variable "label_order" {
description = "Label order, e.g. `name`,`application`."
}

variable "attributes" {
type = list(any)
default = []
description = "Additional attributes (e.g. `1`)."
}

variable "delimiter" {
type = string
default = "-"
description = "Delimiter to be used between `organization`, `environment`, `name` and `attributes`."
}

variable "tags" {
type = map(any)
default = {}
description = "Additional tags (e.g. map(`BusinessUnit`,`XYZ`)."
}

variable "managedby" {
type = string
default = "hello@clouddrove.com"
Expand Down Expand Up @@ -123,20 +105,6 @@ variable "enable_deletion_protection" {
description = "If true, deletion of the load balancer will be disabled via the AWS API. This will prevent Terraform from deleting the load balancer. Defaults to false."
}

variable "subnet_id" {
type = string
default = ""
description = "The id of the subnet of which to attach to the load balancer. You can specify only one subnet per Availability Zone."
sensitive = true
}

variable "allocation_id" {
type = string
default = ""
description = "The allocation ID of the Elastic IP address."
sensitive = true
}

variable "https_port" {
type = number
default = 443
Expand Down Expand Up @@ -289,12 +257,6 @@ variable "listeners" {
description = "A list of listener configurations for the ELB."
}

variable "enable_connection_draining" {
type = bool
default = false
description = "Whether or not to enable connection draining (\"true\" or \"false\")."
}

variable "connection_draining_timeout" {
type = number
default = 300
Expand All @@ -307,12 +269,6 @@ variable "connection_draining" {
description = "TBoolean to enable connection draining. Default: false."
}

variable "availability_zones" {
default = []
type = list(map(string))
description = "The AZ's to serve traffic in."
}

variable "health_check_target" {
description = "The target to use for health checks."
type = string
Expand Down Expand Up @@ -365,12 +321,6 @@ variable "listener_https_fixed_response" {
default = null
}

variable "https_listener_rules" {
description = "A list of maps describing the Listener Rules for this ALB. Required key/values: actions, conditions. Optional key/values: priority, https_listener_index (default to https_listeners[count.index])"
type = any
default = []
}

variable "with_target_group" {
type = bool
default = true
Expand Down
6 changes: 3 additions & 3 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Terraform version
terraform {
required_version = ">= 1.4.6"
required_version = ">= 1.5.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.1.0"
version = ">= 5.9.0"
}
}
}
}

0 comments on commit c6d1a30

Please sign in to comment.