Skip to content

Commit

Permalink
fix: run terraform fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mamrajyadav committed Aug 28, 2023
1 parent db7e7bf commit bcbafab
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 33 deletions.
109 changes: 83 additions & 26 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,16 @@ usage : |-
module "alb" {
source = "clouddrove/alb/aws"
version = "1.4.0"
name = "alb"
name = local.name
enable = true
internal = true
load_balancer_type = "application"
instance_count = module.ec2.instance_count
security_groups = [module.ssh.security_group_ids, module.http_https.security_group_ids]
subnets = module.public_subnets.public_subnet_id
target_id = module.ec2.instance_id
vpc_id = module.vpc.vpc_id
allowed_ip = [module.vpc.vpc_cidr_block]
allowed_ports = [3306]
listener_certificate_arn = module.acm.arn
enable_deletion_protection = false
with_target_group = true
Expand All @@ -61,6 +62,34 @@ usage : |-
https_port = 443
listener_type = "forward"
target_group_port = 80
http_tcp_listeners = [
{
port = 80
protocol = "TCP"
target_group_index = 0
},
{
port = 81
protocol = "TCP"
target_group_index = 0
},
]
https_listeners = [
{
port = 443
protocol = "TLS"
target_group_index = 0
certificate_arn = module.acm.arn
},
{
port = 84
protocol = "TLS"
target_group_index = 0
certificate_arn = module.acm.arn
},
]
target_groups = [
{
backend_protocol = "HTTP"
Expand All @@ -80,17 +109,24 @@ usage : |-
}
}
]
}
extra_ssl_certs = [
{
https_listener_index = 0
certificate_arn = module.acm.arn
}
]
}
```
### NLB Example
```hcl
module "nlb" {
source = "clouddrove/alb/aws"
version = "1.4.0"
name = "nlb"
name = local.name
enable = true
internal = true
internal = false
load_balancer_type = "network"
instance_count = module.ec2.instance_count
subnets = module.public_subnets.public_subnet_id
Expand All @@ -104,6 +140,11 @@ usage : |-
protocol = "TCP"
target_group_index = 0
},
{
port = 81
protocol = "TCP"
target_group_index = 0
},
]
target_groups = [
{
Expand All @@ -112,11 +153,26 @@ usage : |-
target_type = "instance"
},
{
backend_protocol = "TLS"
backend_port = 443
backend_protocol = "TCP"
backend_port = 81
target_type = "instance"
},
]
https_listeners = [
{
port = 443
protocol = "TLS"
target_group_index = 0
certificate_arn = module.acm.arn
},
{
port = 84
protocol = "TLS"
target_group_index = 0
certificate_arn = module.acm.arn
},
]
}
```
Expand All @@ -125,34 +181,35 @@ usage : |-
module "clb" {
source = "clouddrove/alb/aws"
version = "1.4.0"
name = "clb"
load_balancer_type = "classic"
clb_enable = true
internal = true
target_id = module.ec2.instance_id
security_groups = [module.ssh.security_group_ids, module.http_https.security_group_ids]
subnets = module.public_subnets.public_subnet_id
with_target_group = true
name = local.name
load_balancer_type = "classic"
clb_enable = true
internal = true
vpc_id = module.vpc.vpc_id
target_id = module.ec2.instance_id
subnets = module.public_subnets.public_subnet_id
with_target_group = true
listeners = [
{
lb_port = 22000
lb_protocol = "TCP"
instance_port = 22000
instance_protocol = "TCP"
ssl_certificate_id = null
lb_port = 22000
lb_protocol = "TCP"
instance_port = 22000
instance_protocol = "TCP"
ssl_certificate_id = null
},
{
lb_port = 4444
lb_protocol = "TCP"
instance_port = 4444
instance_protocol = "TCP"
ssl_certificate_id = null
lb_port = 4444
lb_protocol = "TCP"
instance_port = 4444
instance_protocol = "TCP"
ssl_certificate_id = null
}
]
health_check_target = "TCP:4444"
health_check_timeout = 10
health_check_interval = 30
health_check_unhealthy_threshold = 5
health_check_healthy_threshold = 5
}
}
```
2 changes: 1 addition & 1 deletion _example/alb/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module "ec2" {
vpc_id = module.vpc.vpc_id
ssh_allowed_ip = ["0.0.0.0/0"]
ssh_allowed_ports = [22]
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCmPuPTJ58AMvweGBuAqKX+tkb0ylYq5k6gPQnl6+ivQ8i/jsUJ+juI7q/7vSoTpd0k9Gv7DkjGWg1527I+LJeropVSaRqwDcrnuM1IfUCu0QdRoU8e0sW7kQGnwObJhnRcxiGPa1inwnneq9zdXK8BGgV2E4POKdwbEBlmjZmW8j4JMnCsLvZ4hxBjZB/3fnvHhn7UCqd2C6FhOz9k+aK2kxXHxdDdO9BzKqtvm5dSAxHhw6nDHSU+cHupjiiY/SvmFH0QpR5Fn1kyZH7DxV4D8R9wvP9jKZe/RRTEkB2HY7FpVNz/EqO/z5bv7japQ5LZY1fFOK47S5KVo20y12XwkBcHeL5Bc8MuKt552JSRH7KKxvr2KD9QN5lCc0sOnQnlOK0INGHeIY4WnUSBvlVd4aOAJa4xE2PP0/kbDMAZfO6ET5OIlZF+X7n5VCYyxNJLWbx4opFIcpWgINz4m/GkArB4p4KeF+pc84rX5GkM4fn5SsMMpJTZmhhJYA2YW/E= mamraj@mamraj"
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCmPuPTJ58AMvweGBuAqKX+tkb0ylYq5k6gPQnl6+ivQ8i/jsUJ+juI7q/7vSoTpd0k9Gv7DkjGWg1527I+LJeropVSaRqwDcrnuM1IfUCu0QdRoU8e0sW7kQGnwObJhnRcxiGPa1inwnneq9zdXK8BGgV2E4POKdwbEBlmjZmW8j4JMnCsLvZ4hxBjZB/3fnvHhn7UCqd2C6FhOz9k+aK2kxXHxdDdO9BzKqtvm5dSAxHhw6nDHSU+cHupjiiY/SvmFH0QpR5Fn1kyZH7DxV4D8R9wvP9jKZe/RRTEkB2HY7FpVNz/EqO/z"
instance_count = 2
ami = "ami-08d658f84a6d84a80"
instance_type = "t2.nano"
Expand Down
2 changes: 1 addition & 1 deletion _example/clb/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ module "ec2" {
instance_type = "t2.nano"
monitoring = false
tenancy = "default"
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCmPuPTJ58AMvweGBuAqKX+tkb0ylYq5k6gPQnl6+ivQ8i/jsUJ+juI7q/7vSoTpd0k9Gv7DkjGWg1527I+LJeropVSaRqwDcrnuM1IfUCu0QdRoU8e0sW7kQGnwObJhnRcxiGPa1inwnneq9zdXK8BGgV2E4POKdwbEBlmjZmW8j4JMnCsLvZ4hxBjZB/3fnvHhn7UCqd2C6FhOz9k+aK2kxXHxdDdO9BzKqtvm5dSAxHhw6nDHSU+cHupjiiY/SvmFH0QpR5Fn1kyZH7DxV4D8R9wvP9jKZe/RRTEkB2HY7FpVNz/EqO/z5bv7japQ5LZY1fFOK47S5KVo20y12XwkBcHeL5Bc8MuKt552JSRH7KKxvr2KD9QN5lCc0sOnQnlOK0INGHeIY4WnUSBvlVd4aOAJa4xE2PP0/kbDMAZfO6ET5OIlZF+X7n5VCYyxNJLWbx4opFIcpWgINz4m/GkArB4p4KeF+pc84rX5GkM4fn5SsMMpJTZmhhJYA2YW/E= mamraj@mamraj"
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCmPuPTJ58AMvweGBuAqKX+tkb0ylYq5k6gPQnl6+ivQ8i/jsUJ+juI7q/7vSoTpd0k9Gv7DkjGWg1527I+LJeropVSaRqwDcrnuM1IfUCu0QdRoU8e0sW7kQGnwObJhnRcxiGPa1inwnneq9zdXK8BGgV2E4POKdwbEBlmjZmW8j4JMnCsLvZ4hxBjZB/3fnvHhn7UCqd2C6FhOz9k+aK2kxXHxdDdO9BzKqtvm5dSAxHhw6nDHSU+cHupjiiY/SvmFH0QpR5Fn1kyZH7DxV4D8R9wvP9jKZe/RRTEkB2HY7FpVNz/EqO/z5bv7japQ5LZY1fFOK47S5K"
subnet_ids = tolist(module.public_subnets.public_subnet_id)
iam_instance_profile = module.iam-role.name
assign_eip_address = true
Expand Down
2 changes: 1 addition & 1 deletion _example/nlb/exampe.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ module "ec2" {
ssh_allowed_ip = ["0.0.0.0/0"]
ssh_allowed_ports = [22]
tenancy = "default"
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCmPuPTJ58AMvweGBuAqKX+tkb0ylYq5k6gPQnl6+ivQ8i/jsUJ+juI7q/7vSoTpd0k9Gv7DkjGWg1527I+LJeropVSaRqwDcrnuM1IfUCu0QdRoU8e0sW7kQGnwObJhnRcxiGPa1inwnneq9zdXK8BGgV2E4POKdwbEBlmjZmW8j4JMnCsLvZ4hxBjZB/3fnvHhn7UCqd2C6FhOz9k+aK2kxXHxdDdO9BzKqtvm5dSAxHhw6nDHSU+cHupjiiY/SvmFH0QpR5Fn1kyZH7DxV4D8R9wvP9jKZe/RRTEkB2HY7FpVNz/EqO/z5bv7japQ5LZY1fFOK47S5KVo20y12XwkBcHeL5Bc8MuKt552JSRH7KKxvr2KD9QN5lCc0sOnQnlOK0INGHeIY4WnUSBvlVd4aOAJa4xE2PP0/kbDMAZfO6ET5OIlZF+X7n5VCYyxNJLWbx4opFIcpWgINz4m/GkArB4p4KeF+pc84rX5GkM4fn5SsMMpJTZmhhJYA2YW/E= mamraj@mamraj"
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCmPuPTJ58AMvweGBuAqKX+tkb0ylYq5k6gPQnl6+ivQ8i/jsUJ+juI7q/7vSoTpd0k9Gv7DkjGWg1527I+LJeropVSaRqwDcrnuM1IfUCu0QdRoU8e0sW7kQGnwObJhnRcxiGPa1inwnneq9zdXK8BGgV2E4POKdwbEBlmjZmW8j4JMnCsLvZ4hxBjZB/3fnvHhn7UCqd2C6FhOz9k+aK2kxXHxdDdO9BzKqtvm5dSAxHhw6nDHSU+cHupjiiY/SvmFH0QpR5Fn1kyZH7DxV4D8R9wvP9jKZe/RRTEkB2HY7FpVNz/EqO/z5bv7japQ5LZY1"
subnet_ids = tolist(module.public_subnets.public_subnet_id)
iam_instance_profile = module.iam-role.name
assign_eip_address = true
Expand Down
8 changes: 4 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ resource "aws_lb" "main" {
enable_waf_fail_open = var.enable_waf_fail_open
desync_mitigation_mode = var.desync_mitigation_mode
xff_header_processing_mode = var.xff_header_processing_mode
ip_address_type = var.ip_address_type
tags = module.labels.tags
drop_invalid_header_fields = true
ip_address_type = var.ip_address_type
tags = module.labels.tags
drop_invalid_header_fields = true

timeouts {
create = var.load_balancer_create_timeout
Expand Down Expand Up @@ -278,7 +278,7 @@ resource "aws_lb_target_group" "main" {
## For attaching resources with Elastic Load Balancer (ELB), see the aws_elb_attachment resource.
##-----------------------------------------------------------------------------
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
# count = var.enable && var.with_target_group && var.load_balancer_type == "application" && var.target_type == "" ? var.instance_count : 0
count = var.enable && var.with_target_group && var.load_balancer_type == "application" ? length(var.https_listeners) : 0

target_group_arn = element(aws_lb_target_group.main[*].arn, count.index)
Expand Down

0 comments on commit bcbafab

Please sign in to comment.