-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathmain.tf
45 lines (42 loc) · 1.66 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
resource "aws_api_gateway_method" "ResourceOptions" {
rest_api_id = "${var.rest_api_id}"
resource_id = "${var.resource_id}"
http_method = "OPTIONS"
authorization = "NONE"
}
resource "aws_api_gateway_integration" "ResourceOptionsIntegration" {
rest_api_id = "${var.rest_api_id}"
resource_id = "${var.resource_id}"
http_method = "${aws_api_gateway_method.ResourceOptions.http_method}"
type = "MOCK"
request_templates = {
"application/json" = <<PARAMS
{ "statusCode": 200 }
PARAMS
}
}
resource "aws_api_gateway_integration_response" "ResourceOptionsIntegrationResponse" {
depends_on = ["aws_api_gateway_integration.ResourceOptionsIntegration"]
rest_api_id = "${var.rest_api_id}"
resource_id = "${var.resource_id}"
http_method = "${aws_api_gateway_method.ResourceOptions.http_method}"
status_code = "200"
response_parameters = {
"method.response.header.Access-Control-Allow-Headers" = "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'",
"method.response.header.Access-Control-Allow-Methods" = "'POST,OPTIONS,GET,PUT,PATCH,DELETE'",
"method.response.header.Access-Control-Allow-Origin" = "'*'"
}
}
resource "aws_api_gateway_method_response" "ResourceOptions200" {
depends_on = ["aws_api_gateway_method.ResourceOptions"]
rest_api_id = "${var.rest_api_id}"
resource_id = "${var.resource_id}"
http_method = "OPTIONS"
status_code = "200"
response_models = { "application/json" = "Empty" }
response_parameters = {
"method.response.header.Access-Control-Allow-Headers" = true,
"method.response.header.Access-Control-Allow-Methods" = true,
"method.response.header.Access-Control-Allow-Origin" = true
}
}