Skip to content

Commit db03199

Browse files
committed
changed to use object of methods
1 parent 2900873 commit db03199

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

main.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,23 @@ resource "aws_api_gateway_integration" "root_method_integration" {
118118
}
119119

120120
resource "aws_api_gateway_resource" "resource" {
121-
count = length(var.method-paths)
122-
path_part = var.method-paths[count.index]
121+
count = length(var.methods)
122+
path_part = var.methods[count.index].path
123123
parent_id = aws_api_gateway_rest_api.api.root_resource_id
124124
rest_api_id = aws_api_gateway_rest_api.api.id
125125
}
126126

127127
resource "aws_api_gateway_method" "method" {
128-
count = length(var.method-paths)
128+
count = length(var.methods)
129129
rest_api_id = aws_api_gateway_rest_api.api.id
130130
resource_id = aws_api_gateway_resource.resource[count.index].id
131-
http_method = var.method-types[count.index]
131+
http_method = var.methods[count.index].type
132132
authorization = var.resource-authorization
133133
request_parameters = var.resource-request-params
134134
}
135135

136136
resource "aws_api_gateway_integration" "integration" {
137-
count = length(var.method-paths)
137+
count = length(var.methods)
138138
rest_api_id = aws_api_gateway_rest_api.api.id
139139
resource_id = aws_api_gateway_resource.resource[count.index].id
140140
http_method = aws_api_gateway_method.method[count.index].http_method

variables.tf

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,11 @@ variable "account-id" {
4242
type = string
4343
}
4444

45-
variable "method-paths" {
46-
type = list(string)
47-
default = []
48-
}
49-
50-
variable "method-types" {
51-
type = list(string)
52-
default = []
45+
variable "methods" {
46+
type = list(object({
47+
path = string
48+
type = string
49+
}))
5350
}
5451

5552
variable "root-resource" {

0 commit comments

Comments
 (0)