Skip to content

Commit 72f592d

Browse files
add options to PUT with id
1 parent f4912ce commit 72f592d

File tree

4 files changed

+32
-15
lines changed

4 files changed

+32
-15
lines changed

infrastructure/gateway-document-reference.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,19 @@ module "document_reference_gateway" {
2121
require_credentials = true
2222
origin = contains(["prod"], terraform.workspace) ? "'https://${var.domain}'" : "'https://${terraform.workspace}.${var.domain}'"
2323
}
24+
25+
module "document_reference_id_gateway" {
26+
source = "./modules/gateway"
27+
api_gateway_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
28+
parent_id = module.document_reference_gateway.gateway_resource_id
29+
http_methods = ["PUT"]
30+
authorization = "CUSTOM"
31+
gateway_path = "{id}"
32+
authorizer_id = aws_api_gateway_authorizer.repo_authoriser.id
33+
require_credentials = true
34+
origin = contains(["prod"], terraform.workspace) ? "'https://${var.domain}'" : "'https://${terraform.workspace}.${var.domain}'"
35+
36+
request_parameters = {
37+
"method.request.path.id" = true
38+
}
39+
}

infrastructure/lambda-update-doc-ref.tf

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
resource "aws_api_gateway_resource" "update_document_reference_with_id" {
2-
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
3-
parent_id = module.document_reference_gateway.gateway_resource_id
4-
path_part = "{id}"
5-
}
6-
71
resource "aws_api_gateway_method" "update_document_reference_with_id" {
82
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
9-
resource_id = aws_api_gateway_resource.update_document_reference_with_id.id
3+
resource_id = module.document_reference_id_gateway.gateway_resource_id.id
104
http_method = "PUT"
115
authorization = "CUSTOM"
126
authorizer_id = aws_api_gateway_authorizer.repo_authoriser.id
@@ -73,7 +67,7 @@ module "update_doc_ref_lambda" {
7367
]
7468
kms_deletion_window = var.kms_deletion_window
7569
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
76-
resource_id = aws_api_gateway_resource.update_document_reference_with_id.id
70+
resource_id = module.document_reference_id_gateway.gateway_resource_id.id
7771
http_methods = ["PUT"]
7872
memory_size = 512
7973

infrastructure/modules/gateway/main.tf

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ resource "aws_api_gateway_method" "preflight_method" {
1313
}
1414

1515
resource "aws_api_gateway_method" "proxy_method" {
16-
for_each = toset(var.http_methods)
17-
rest_api_id = var.api_gateway_id
18-
resource_id = aws_api_gateway_resource.gateway_resource.id
19-
http_method = each.key
20-
authorization = var.authorization
21-
authorizer_id = var.authorizer_id
22-
api_key_required = var.api_key_required
16+
for_each = toset(var.http_methods)
17+
rest_api_id = var.api_gateway_id
18+
resource_id = aws_api_gateway_resource.gateway_resource.id
19+
http_method = each.key
20+
authorization = var.authorization
21+
authorizer_id = var.authorizer_id
22+
api_key_required = var.api_key_required
23+
request_parameters = var.request_parameters
2324
}
2425

2526
resource "aws_api_gateway_method_response" "preflight_method_response" {

infrastructure/modules/gateway/variable.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,9 @@ variable "api_key_required" {
4545
type = bool
4646
default = false
4747
}
48+
49+
variable "request_parameters" {
50+
description = "Request parameters for the API Gateway method."
51+
type = map(string)
52+
default = {}
53+
}

0 commit comments

Comments
 (0)