Skip to content

Commit e754974

Browse files
feat: Support for jwt_validation in aws_lb_listener and aws_lb_listener_rule (#426)
Co-authored-by: Bryant Biggs <[email protected]>
1 parent a000e55 commit e754974

File tree

16 files changed

+129
-19
lines changed

16 files changed

+129
-19
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.103.0
3+
rev: v1.104.0
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_wrapper_module_for_each

README.md

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

examples/complete-alb/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ Note that this example may create resources which cost money. Run `terraform des
2020
| Name | Version |
2121
|------|---------|
2222
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.7 |
23-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.19 |
23+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.22 |
2424
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 2.0 |
2525
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.6 |
2626

2727
## Providers
2828

2929
| Name | Version |
3030
|------|---------|
31-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.19 |
31+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.22 |
3232
| <a name="provider_null"></a> [null](#provider\_null) | >= 2.0 |
3333
| <a name="provider_random"></a> [random](#provider\_random) | >= 3.6 |
3434

examples/complete-alb/main.tf

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,45 @@ module "alb" {
395395
target_group_key = "ex-instance"
396396
}
397397
}
398+
399+
ex-jwt = {
400+
port = 445
401+
protocol = "HTTPS"
402+
certificate_arn = module.acm.acm_certificate_arn
403+
404+
forward = {
405+
target_group_key = "ex-instance"
406+
}
407+
408+
rules = {
409+
ex-jwt = {
410+
priority = 5
411+
412+
actions = [
413+
{
414+
jwt_validation = {
415+
issuer = "https://${var.domain_name}"
416+
jwks_endpoint = "https://${var.domain_name}/jwks.json"
417+
additional_claim = [
418+
{ format = "space-separated-values", name = "scp", values = ["read", "write"] }
419+
]
420+
}
421+
},
422+
{
423+
forward = {
424+
target_group_key = "ex-lambda-with-trigger"
425+
}
426+
}
427+
]
428+
429+
conditions = [{
430+
host_header = {
431+
values = ["foobar.com"]
432+
}
433+
}]
434+
}
435+
}
436+
}
398437
}
399438

400439
target_groups = {

examples/complete-alb/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 6.19"
7+
version = ">= 6.22"
88
}
99
null = {
1010
source = "hashicorp/null"

examples/complete-nlb/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ Note that this example may create resources which cost money. Run `terraform des
2020
| Name | Version |
2121
|------|---------|
2222
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.7 |
23-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.19 |
23+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.22 |
2424

2525
## Providers
2626

2727
| Name | Version |
2828
|------|---------|
29-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.19 |
29+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.22 |
3030

3131
## Modules
3232

examples/complete-nlb/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 6.19"
7+
version = ">= 6.22"
88
}
99
}
1010
}

examples/mutual-auth-alb/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ Note that this example may create resources which cost money. Run `terraform des
2121
| Name | Version |
2222
|------|---------|
2323
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.7 |
24-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.19 |
24+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.22 |
2525
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 2.0 |
2626
| <a name="requirement_tls"></a> [tls](#requirement\_tls) | >= 4.0 |
2727

2828
## Providers
2929

3030
| Name | Version |
3131
|------|---------|
32-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.19 |
32+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.22 |
3333
| <a name="provider_null"></a> [null](#provider\_null) | >= 2.0 |
3434
| <a name="provider_tls"></a> [tls](#provider\_tls) | >= 4.0 |
3535

examples/mutual-auth-alb/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 6.19"
7+
version = ">= 6.22"
88
}
99
null = {
1010
source = "hashicorp/null"

main.tf

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,30 @@ resource "aws_lb_listener" "this" {
164164
}
165165
}
166166

167+
dynamic "default_action" {
168+
for_each = each.value.jwt_validation != null ? [each.value.jwt_validation] : []
169+
170+
content {
171+
jwt_validation {
172+
issuer = default_action.value.issuer
173+
jwks_endpoint = default_action.value.jwks_endpoint
174+
175+
dynamic "additional_claim" {
176+
for_each = default_action.value.additional_claim != null ? default_action.value.additional_claim : []
177+
178+
content {
179+
format = additional_claim.value.format
180+
name = additional_claim.value.name
181+
values = additional_claim.value.values
182+
}
183+
}
184+
}
185+
186+
order = each.value.order
187+
type = "jwt-validation"
188+
}
189+
}
190+
167191
dynamic "default_action" {
168192
for_each = each.value.fixed_response != null ? [each.value.fixed_response] : []
169193

@@ -354,6 +378,35 @@ resource "aws_lb_listener_rule" "this" {
354378
}
355379
}
356380

381+
# JWT validation
382+
dynamic "action" {
383+
for_each = [for action in each.value.actions : action if action.jwt_validation != null]
384+
385+
content {
386+
dynamic "jwt_validation" {
387+
for_each = [action.value.jwt_validation]
388+
389+
content {
390+
issuer = jwt_validation.value.issuer
391+
jwks_endpoint = jwt_validation.value.jwks_endpoint
392+
393+
dynamic "additional_claim" {
394+
for_each = jwt_validation.value.additional_claim != null ? jwt_validation.value.additional_claim : []
395+
396+
content {
397+
format = additional_claim.value.format
398+
name = additional_claim.value.name
399+
values = additional_claim.value.values
400+
}
401+
}
402+
}
403+
}
404+
405+
order = action.value.order
406+
type = "jwt-validation"
407+
}
408+
}
409+
357410
# Fixed response
358411
dynamic "action" {
359412
for_each = [for action in each.value.actions : action if action.fixed_response != null]

0 commit comments

Comments
 (0)