Skip to content

Commit cca06fc

Browse files
authored
Remove lb name's postfix and update examples (#5)
1 parent 8aef13b commit cca06fc

File tree

9 files changed

+59
-84
lines changed

9 files changed

+59
-84
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ errored.tfstate
44
crash.log
55
terraform.tfstate
66
*.tfstate*
7-
terraform.tfvars
7+
terraform.tfvars
8+
*.terraform.lock.hcl

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ repos:
1818
args: ['--allow-missing-credentials']
1919
- id: trailing-whitespace
2020
- repo: git://github.com/antonbabenko/pre-commit-terraform
21-
rev: v1.44.0
21+
rev: v1.45.0
2222
hooks:
2323
- id: terraform_fmt
2424
- id: terraform_docs

CHANGELOG.md

+23-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,25 @@ All notable changes to this project will be documented in this file.
55
<a name="unreleased"></a>
66
## [Unreleased]
77

8-
- Update docs + lock versions and add changelog
8+
- Remove lb name's postfix and update examples
9+
10+
11+
<a name="1.2.2"></a>
12+
## [1.2.2] - 2020-11-09
13+
14+
- Update module to remove 0.14 limit ([#4](https://github.com/umotif-public/terraform-aws-alb/issues/4))
15+
16+
17+
<a name="1.2.1"></a>
18+
## [1.2.1] - 2020-08-05
19+
20+
- Improve module versions + add alb access logs example ([#3](https://github.com/umotif-public/terraform-aws-alb/issues/3))
21+
22+
23+
<a name="1.2.0"></a>
24+
## [1.2.0] - 2020-04-21
25+
26+
- Feature/updates ([#2](https://github.com/umotif-public/terraform-aws-alb/issues/2))
927
- add git hooks and update docs
1028
- update docs
1129

@@ -34,7 +52,10 @@ All notable changes to this project will be documented in this file.
3452
- Add default redirect and nlb example
3553

3654

37-
[Unreleased]: https://github.com/umotif-public/terraform-aws-alb/compare/1.1.0...HEAD
55+
[Unreleased]: https://github.com/umotif-public/terraform-aws-alb/compare/1.2.2...HEAD
56+
[1.2.2]: https://github.com/umotif-public/terraform-aws-alb/compare/1.2.1...1.2.2
57+
[1.2.1]: https://github.com/umotif-public/terraform-aws-alb/compare/1.2.0...1.2.1
58+
[1.2.0]: https://github.com/umotif-public/terraform-aws-alb/compare/1.1.0...1.2.0
3859
[1.1.0]: https://github.com/umotif-public/terraform-aws-alb/compare/1.0.4...1.1.0
3960
[1.0.4]: https://github.com/umotif-public/terraform-aws-alb/compare/1.0.3...1.0.4
4061
[1.0.3]: https://github.com/umotif-public/terraform-aws-alb/compare/1.0.2...1.0.3

README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ These types of resources are supported:
99

1010
## Terraform versions
1111

12-
Terraform 0.12. Pin module version to `~> v1.0`. Submit pull-requests to `master` branch.
12+
Terraform 0.12. Pin module version to `~> v2.0`. Submit pull-requests to `master` branch.
1313

1414
## Usage
1515

@@ -18,7 +18,7 @@ Terraform 0.12. Pin module version to `~> v1.0`. Submit pull-requests to `master
1818
```hcl
1919
module "alb" {
2020
source = "umotif-public/alb/aws"
21-
version = "~> 1.2.1"
21+
version = "~> 2.0.0"
2222
2323
name_prefix = "complete-alb"
2424
@@ -43,23 +43,22 @@ module "alb" {
4343
```hcl
4444
module "nlb" {
4545
source = "umotif-public/alb/aws"
46-
version = "~> 1.2.1"
46+
version = "~> 2.0.0"
4747
48-
name = "complete-nlb"
48+
name_prefix = "complete-nlb"
4949
5050
load_balancer_type = "network"
5151
5252
vpc_id = "vpc-abasdasd132"
5353
subnets = ["subnet-abasdasd132123", "subnet-abasdasd132123132"]
5454
5555
access_logs = {
56-
bucket = "my-nlb-logs"
56+
bucket = "nlb-logs"
5757
}
5858
5959
tags = {
6060
Project = "Test"
6161
}
62-
6362
}
6463
```
6564

examples/alb-with-s3-access-logs/data.tf

-3
This file was deleted.

examples/alb-with-s3-access-logs/main.tf

+8-21
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,26 @@ provider "aws" {
55
#####
66
# VPC and subnets
77
#####
8-
module "vpc" {
9-
source = "terraform-aws-modules/vpc/aws"
10-
version = "2.44.0"
11-
12-
name = "simple-vpc"
13-
14-
cidr = "10.0.0.0/16"
15-
16-
azs = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
17-
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
18-
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
19-
20-
enable_nat_gateway = false
21-
22-
tags = {
23-
Environment = "test"
24-
}
8+
data "aws_vpc" "default" {
9+
default = true
2510
}
2611

12+
data "aws_subnet_ids" "all" {
13+
vpc_id = data.aws_vpc.default.id
14+
}
2715
#####
2816
# Application Load Balancer
2917
#####
3018
module "alb" {
3119
source = "../../"
3220

33-
name_prefix = "example-with-access-logs"
21+
name_prefix = "alb-example-access-logs"
3422

3523
load_balancer_type = "application"
3624

3725
internal = false
38-
vpc_id = module.vpc.vpc_id
39-
subnets = flatten([module.vpc.public_subnets])
26+
vpc_id = data.aws_vpc.default.id
27+
subnets = data.aws_subnet_ids.all.ids
4028

4129
enable_http_to_https_redirect = true
4230
cidr_blocks_redirect = ["10.10.0.0/16"]
@@ -94,7 +82,6 @@ locals {
9482
resource "aws_s3_bucket" "alb_access_logs" {
9583
bucket = "example-alb-access-logs-bucket"
9684
acl = "private"
97-
region = data.aws_region.current.name
9885

9986
server_side_encryption_configuration {
10087
rule {

examples/alb/main.tf

+8-21
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,26 @@ provider "aws" {
55
#####
66
# VPC and subnets
77
#####
8-
module "vpc" {
9-
source = "terraform-aws-modules/vpc/aws"
10-
version = "2.21.0"
11-
12-
name = "simple-vpc"
13-
14-
cidr = "10.0.0.0/16"
15-
16-
azs = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
17-
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
18-
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
19-
20-
enable_nat_gateway = false
21-
22-
tags = {
23-
Environment = "test"
24-
}
8+
data "aws_vpc" "default" {
9+
default = true
2510
}
2611

12+
data "aws_subnet_ids" "all" {
13+
vpc_id = data.aws_vpc.default.id
14+
}
2715
#####
2816
# Application Load Balancer
2917
#####
3018
module "alb" {
3119
source = "../../"
3220

33-
name_prefix = "complete-example"
21+
name_prefix = "complete-alb-example"
3422

3523
load_balancer_type = "application"
3624

3725
internal = false
38-
vpc_id = module.vpc.vpc_id
39-
subnets = flatten([module.vpc.public_subnets])
26+
vpc_id = data.aws_vpc.default.id
27+
subnets = data.aws_subnet_ids.all.ids
4028

4129
enable_http_to_https_redirect = true
4230
cidr_blocks_redirect = ["10.10.0.0/16"]
@@ -68,7 +56,6 @@ resource "aws_lb_listener" "alb_80_redirect_to_443" {
6856
#####
6957
# SGs
7058
#####
71-
7259
resource "aws_security_group_rule" "alb_ingress_443" {
7360
security_group_id = module.alb.security_group_id
7461
type = "ingress"

examples/nlb/main.tf

+8-21
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,13 @@ provider "aws" {
55
#####
66
# VPC and subnets
77
#####
8-
module "vpc" {
9-
source = "terraform-aws-modules/vpc/aws"
10-
version = "2.21.0"
11-
12-
name = "simple-vpc"
13-
14-
cidr = "10.0.0.0/16"
15-
16-
azs = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
17-
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
18-
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
19-
20-
enable_nat_gateway = false
21-
22-
tags = {
23-
Environment = "test"
24-
}
8+
data "aws_vpc" "default" {
9+
default = true
2510
}
2611

12+
data "aws_subnet_ids" "all" {
13+
vpc_id = data.aws_vpc.default.id
14+
}
2715
# resource "aws_eip" "main" {
2816
# count = length(module.vpc.public_subnets)
2917

@@ -36,13 +24,12 @@ module "vpc" {
3624
module "nlb" {
3725
source = "../../"
3826

39-
name_prefix = "complete-example"
27+
name_prefix = "complete-nlb-example"
4028

4129
load_balancer_type = "network"
4230

43-
vpc_id = module.vpc.vpc_id
44-
45-
subnets = flatten([module.vpc.public_subnets])
31+
vpc_id = data.aws_vpc.default.id
32+
subnets = data.aws_subnet_ids.all.ids
4633

4734
// Use `subnet_mapping` to attach EIPs and comment out `subnets`
4835
// subnet_mapping = [for i, eip in aws_eip.main : { allocation_id : eip.id, subnet_id : tolist(module.vpc.public_subnets)[i] }]

main.tf

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
locals {
2-
name_prefix = "${var.name_prefix}-${var.load_balancer_type == "network" ? "nlb" : "alb"}"
3-
}
4-
51
resource "aws_lb" "main" {
6-
name = local.name_prefix
2+
name = var.name_prefix
73

84
load_balancer_type = var.load_balancer_type
95
internal = var.internal
@@ -38,7 +34,7 @@ resource "aws_lb" "main" {
3834
tags = merge(
3935
var.tags,
4036
{
41-
"Name" = local.name_prefix
37+
"Name" = var.name_prefix
4238
},
4339
)
4440

@@ -69,14 +65,14 @@ resource "aws_lb_listener" "frontend_http_to_https_redirect" {
6965

7066
resource "aws_security_group" "main" {
7167
count = var.load_balancer_type == "network" ? 0 : 1
72-
name_prefix = "${local.name_prefix}-sg-"
68+
name_prefix = "${var.name_prefix}-sg-"
7369
description = var.description
7470
vpc_id = var.vpc_id
7571

7672
tags = merge(
7773
var.tags,
7874
{
79-
"Name" = "${local.name_prefix}-sg"
75+
"Name" = "${var.name_prefix}-sg"
8076
},
8177
)
8278

0 commit comments

Comments
 (0)