-
-
Save victor-teal/8b8117f3c780d8ef47fe8a45a57d68c3 to your computer and use it in GitHub Desktop.
Terraform - API Gateway with greedy path (proxy+) calling httpbin. Also includes deployment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| resource "aws_api_gateway_rest_api" "MyDemoAPI" { | |
| name = "MyDemoAPI" | |
| description = "This is my API for demonstration purposes" | |
| } | |
| resource "aws_api_gateway_resource" "MyDemoResource" { | |
| rest_api_id = "${aws_api_gateway_rest_api.MyDemoAPI.id}" | |
| parent_id = "${aws_api_gateway_rest_api.MyDemoAPI.root_resource_id}" | |
| path_part = "{proxy+}" | |
| } | |
| resource "aws_api_gateway_method" "MyDemoMethod" { | |
| rest_api_id = "${aws_api_gateway_rest_api.MyDemoAPI.id}" | |
| resource_id = "${aws_api_gateway_resource.MyDemoResource.id}" | |
| http_method = "GET" | |
| authorization = "NONE" | |
| request_parameters = { | |
| "method.request.path.proxy" = true | |
| } | |
| } | |
| resource "aws_api_gateway_integration" "MyDemoIntegration" { | |
| rest_api_id = "${aws_api_gateway_rest_api.MyDemoAPI.id}" | |
| resource_id = "${aws_api_gateway_resource.MyDemoResource.id}" | |
| http_method = "${aws_api_gateway_method.MyDemoMethod.http_method}" | |
| type = "HTTP_PROXY" | |
| uri = "https://httpbin.org/anything/{proxy}" | |
| integration_http_method = "GET" | |
| cache_key_parameters = ["method.request.path.proxy"] | |
| timeout_milliseconds = 29000 | |
| request_parameters = { | |
| "integration.request.path.proxy" = "method.request.path.proxy" | |
| } | |
| } | |
| resource "aws_api_gateway_deployment" "teststage" { | |
| depends_on = [ | |
| "aws_api_gateway_integration.MyDemoIntegration" | |
| ] | |
| rest_api_id = "${aws_api_gateway_rest_api.MyDemoAPI.id}" | |
| stage_name = "test" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment