File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -9,17 +9,19 @@ resource "aws_api_gateway_resource" "resource" {
9
9
}
10
10
11
11
resource "aws_api_gateway_method" "method" {
12
+ count = length (var. http_methods )
12
13
rest_api_id = aws_api_gateway_rest_api. api . id
13
14
resource_id = aws_api_gateway_resource. resource . id
14
- http_method = var. http_method
15
+ http_method = var. http_methods [ count . index ]
15
16
authorization = " NONE"
16
17
}
17
18
18
19
resource "aws_api_gateway_integration" "integration" {
20
+ count = length (var. http_methods )
19
21
rest_api_id = aws_api_gateway_rest_api. api . id
20
22
resource_id = aws_api_gateway_resource. resource . id
21
- http_method = aws_api_gateway_method . method . http_method
22
- integration_http_method = var. http_method
23
+ integration_http_method = var . http_methods [ count . index ]
24
+ http_method = var. http_methods [ count . index ]
23
25
type = " AWS_PROXY"
24
26
uri = aws_lambda_function. lambda . invoke_arn
25
27
}
@@ -30,7 +32,7 @@ resource "aws_lambda_permission" "apigw_lambda" {
30
32
function_name = aws_lambda_function. lambda . function_name
31
33
principal = " apigateway.amazonaws.com"
32
34
33
- source_arn = " arn:aws:execute-api:${ var . region } :${ local . account_id } :${ aws_api_gateway_rest_api . api . id } /*/${ aws_api_gateway_method . method . http_method } ${ aws_api_gateway_resource . resource . path } "
35
+ source_arn = " arn:aws:execute-api:${ var . region } :${ local . account_id } :${ aws_api_gateway_rest_api . api . id } /*/* "
34
36
}
35
37
36
38
resource "aws_api_gateway_deployment" "deployment" {
Original file line number Diff line number Diff line change @@ -11,9 +11,9 @@ variable environment_variables {
11
11
default = {}
12
12
}
13
13
14
- variable http_method {
15
- type = string
16
- default = " GET"
14
+ variable http_methods {
15
+ type = list ( string )
16
+ default = [ " GET" ]
17
17
}
18
18
19
19
variable lambda_function_name {
You can’t perform that action at this time.
0 commit comments