Skip to content

Commit fc03f8d

Browse files
authored
Merge pull request #5 from pragmaticcoders/SRE-144-split-route-per-method
create route with and without auth(OPTIONS) for each method
2 parents 05d3bc7 + 09c93d9 commit fc03f8d

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
resource "aws_apigatewayv2_route" "auth_on" {
2+
for_each = toset(var.method)
3+
api_id = var.api_id
4+
route_key = "${each.key} ${var.path}"
5+
target = "integrations/${var.integration_id}"
6+
authorization_scopes = var.authorization_scopes
7+
authorizer_id = var.authorizer_id
8+
authorization_type = "JWT"
9+
}
10+
11+
resource "aws_apigatewayv2_route" "auth_off" {
12+
api_id = var.api_id
13+
route_key = "OPTIONS ${var.path}"
14+
target = "integrations/${var.integration_id}"
15+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
variable "path" {}
2+
variable "method"{
3+
type = list
4+
default = [
5+
"GET","POST","DELETE","HEAD","PATCH","PUT"
6+
]
7+
}
8+
variable "api_id" {}
9+
variable "integration_id" {}
10+
variable "authorizer_id" {}
11+
variable "authorization_scopes" {
12+
type = list
13+
default = [
14+
"aws.cognito.signin.user.admin",
15+
]
16+
}

0 commit comments

Comments
 (0)