Skip to content
Snippets Groups Projects
Commit da64fe8c authored by Bertrand PINEL's avatar Bertrand PINEL
Browse files

Handle CORS response for all methods of the API Gateway

parent 8f1de7e1
No related branches found
No related tags found
No related merge requests found
...@@ -165,8 +165,8 @@ resource "aws_api_gateway_method_response" "200TypeGet" { ...@@ -165,8 +165,8 @@ resource "aws_api_gateway_method_response" "200TypeGet" {
http_method = "${aws_api_gateway_method.typePathGet.http_method}" http_method = "${aws_api_gateway_method.typePathGet.http_method}"
status_code = "200" status_code = "200"
response_parameters { response_parameters {
"method.response.header.Access-Control-Allow-Origin" = true "method.response.header.Access-Control-Allow-Origin" = true
} }
} }
resource "aws_api_gateway_integration_response" "200TypeGetIntegrationResponse" { resource "aws_api_gateway_integration_response" "200TypeGetIntegrationResponse" {
...@@ -179,7 +179,7 @@ resource "aws_api_gateway_integration_response" "200TypeGetIntegrationResponse" ...@@ -179,7 +179,7 @@ resource "aws_api_gateway_integration_response" "200TypeGetIntegrationResponse"
} }
response_parameters { response_parameters {
"method.response.header.Access-Control-Allow-Origin" = "'*'" "method.response.header.Access-Control-Allow-Origin" = "'*'"
} }
depends_on = ["aws_api_gateway_integration.lambdaJsonTypeGet"] depends_on = ["aws_api_gateway_integration.lambdaJsonTypeGet"]
} }
############################################## ##############################################
...@@ -205,6 +205,9 @@ resource "aws_api_gateway_method_response" "200TypePost" { ...@@ -205,6 +205,9 @@ resource "aws_api_gateway_method_response" "200TypePost" {
resource_id = "${aws_api_gateway_resource.typePath.id}" resource_id = "${aws_api_gateway_resource.typePath.id}"
http_method = "${aws_api_gateway_method.typePathPost.http_method}" http_method = "${aws_api_gateway_method.typePathPost.http_method}"
status_code = "200" status_code = "200"
response_parameters {
"method.response.header.Access-Control-Allow-Origin" = true
}
} }
resource "aws_api_gateway_integration_response" "200TypePostIntegrationResponse" { resource "aws_api_gateway_integration_response" "200TypePostIntegrationResponse" {
...@@ -215,6 +218,9 @@ resource "aws_api_gateway_integration_response" "200TypePostIntegrationResponse" ...@@ -215,6 +218,9 @@ resource "aws_api_gateway_integration_response" "200TypePostIntegrationResponse"
response_templates = { response_templates = {
"application/json" = "" "application/json" = ""
} }
response_parameters {
"method.response.header.Access-Control-Allow-Origin" = "'*'"
}
depends_on = ["aws_api_gateway_integration.lambdaJsonTypePost"] depends_on = ["aws_api_gateway_integration.lambdaJsonTypePost"]
} }
############################################## ##############################################
...@@ -240,6 +246,9 @@ resource "aws_api_gateway_method_response" "200TypeIdGet" { ...@@ -240,6 +246,9 @@ resource "aws_api_gateway_method_response" "200TypeIdGet" {
resource_id = "${aws_api_gateway_method.typeIdPathGet.resource_id}" resource_id = "${aws_api_gateway_method.typeIdPathGet.resource_id}"
http_method = "${aws_api_gateway_method.typeIdPathGet.http_method}" http_method = "${aws_api_gateway_method.typeIdPathGet.http_method}"
status_code = "200" status_code = "200"
response_parameters {
"method.response.header.Access-Control-Allow-Origin" = true
}
} }
resource "aws_api_gateway_integration_response" "200TypeIdGetIntegrationResponse" { resource "aws_api_gateway_integration_response" "200TypeIdGetIntegrationResponse" {
...@@ -249,7 +258,10 @@ resource "aws_api_gateway_integration_response" "200TypeIdGetIntegrationResponse ...@@ -249,7 +258,10 @@ resource "aws_api_gateway_integration_response" "200TypeIdGetIntegrationResponse
status_code = "${aws_api_gateway_method_response.200TypeIdGet.status_code}" status_code = "${aws_api_gateway_method_response.200TypeIdGet.status_code}"
response_templates = { response_templates = {
"application/json" = "" "application/json" = ""
} }
response_parameters {
"method.response.header.Access-Control-Allow-Origin" = "'*'"
}
depends_on=["aws_api_gateway_integration.lambdaJsonTypeIdGet"] depends_on=["aws_api_gateway_integration.lambdaJsonTypeIdGet"]
} }
############################################## ##############################################
...@@ -275,8 +287,10 @@ resource "aws_api_gateway_method_response" "200TypeIdDelete" { ...@@ -275,8 +287,10 @@ resource "aws_api_gateway_method_response" "200TypeIdDelete" {
resource_id = "${aws_api_gateway_method.typeIdPathDelete.resource_id}" resource_id = "${aws_api_gateway_method.typeIdPathDelete.resource_id}"
http_method = "${aws_api_gateway_method.typeIdPathDelete.http_method}" http_method = "${aws_api_gateway_method.typeIdPathDelete.http_method}"
status_code = "200" status_code = "200"
response_parameters {
"method.response.header.Access-Control-Allow-Origin" = true
}
} }
resource "aws_api_gateway_integration_response" "200TypeIdDeleteIntegrationResponse" { resource "aws_api_gateway_integration_response" "200TypeIdDeleteIntegrationResponse" {
rest_api_id = "${aws_api_gateway_rest_api.jsonapi.id}" rest_api_id = "${aws_api_gateway_rest_api.jsonapi.id}"
resource_id = "${aws_api_gateway_resource.typeIdPath.id}" resource_id = "${aws_api_gateway_resource.typeIdPath.id}"
...@@ -285,6 +299,9 @@ resource "aws_api_gateway_integration_response" "200TypeIdDeleteIntegrationRespo ...@@ -285,6 +299,9 @@ resource "aws_api_gateway_integration_response" "200TypeIdDeleteIntegrationRespo
response_templates = { response_templates = {
"application/json" = "" "application/json" = ""
} }
response_parameters {
"method.response.header.Access-Control-Allow-Origin" = "'*'"
}
depends_on= ["aws_api_gateway_integration.lambdaJsonTypeIdDelete"] depends_on= ["aws_api_gateway_integration.lambdaJsonTypeIdDelete"]
} }
############################################## ##############################################
...@@ -310,6 +327,9 @@ resource "aws_api_gateway_method_response" "200TypeIdPatch" { ...@@ -310,6 +327,9 @@ resource "aws_api_gateway_method_response" "200TypeIdPatch" {
resource_id = "${aws_api_gateway_method.typeIdPathPatch.resource_id}" resource_id = "${aws_api_gateway_method.typeIdPathPatch.resource_id}"
http_method = "${aws_api_gateway_method.typeIdPathPatch.http_method}" http_method = "${aws_api_gateway_method.typeIdPathPatch.http_method}"
status_code = "200" status_code = "200"
response_parameters {
"method.response.header.Access-Control-Allow-Origin" = true
}
} }
resource "aws_api_gateway_integration_response" "200TypeIdPatchIntegrationResponse" { resource "aws_api_gateway_integration_response" "200TypeIdPatchIntegrationResponse" {
rest_api_id = "${aws_api_gateway_rest_api.jsonapi.id}" rest_api_id = "${aws_api_gateway_rest_api.jsonapi.id}"
...@@ -319,6 +339,9 @@ resource "aws_api_gateway_integration_response" "200TypeIdPatchIntegrationRespon ...@@ -319,6 +339,9 @@ resource "aws_api_gateway_integration_response" "200TypeIdPatchIntegrationRespon
response_templates = { response_templates = {
"application/json" = "" "application/json" = ""
} }
response_parameters {
"method.response.header.Access-Control-Allow-Origin" = "'*'"
}
depends_on = ["aws_api_gateway_integration.lambdaJsonTypeIdPatch"] depends_on = ["aws_api_gateway_integration.lambdaJsonTypeIdPatch"]
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment