diff --git a/integration/app/routes.js b/integration/app/routes.js index 4ff1146..bd028ec 100644 --- a/integration/app/routes.js +++ b/integration/app/routes.js @@ -6,7 +6,7 @@ module.exports = { route: "/blog/:url" }, { - page: "/contacts", + page: "/contact", route: "/contact-us" } ] diff --git a/integration/aws/api.tf b/integration/aws/api.tf index 1392993..cd8cf23 100644 --- a/integration/aws/api.tf +++ b/integration/aws/api.tf @@ -4,6 +4,14 @@ provider "aws" { version = "~> 2.0" } +locals { + groupname = "WebApi" + + lambda_iam_role = "arn:aws:iam::202020202020:role/lambda_execution_role" + + aws_region = "${data.aws_region.current.name}" +} + variable "env" { default = "dev" } @@ -22,14 +30,4 @@ resource "aws_api_gateway_stage" "CustomKey" { resource "aws_api_gateway_deployment" "CustomKey" { rest_api_id = "${aws_api_gateway_rest_api.CustomKey.id}" stage_name = "dev" - - lifecycle { - create_before_destroy = true - } - - stage_description = "Deployment md5: ${md5( - format("%s%s", - file("gateway.terraform.tf.json"), - file("lambdas.terraform.tf.json"), - ))}" } diff --git a/src/generateApiGatewayConfiguration.js b/src/generateApiGatewayConfiguration.js index 3589da4..d4ac886 100644 --- a/src/generateApiGatewayConfiguration.js +++ b/src/generateApiGatewayConfiguration.js @@ -72,7 +72,7 @@ const handleResource = ({ params }) => { const isUrlParam = pathPart.includes(":"); - const currentPathName = pathPart.replace(":", "").replace("?", ""); + const currentPathName = pathPart.replace(":", ""); // Generation of the gateway resource // we don't generate a gateway resource if the path part is a query string uniqueName = generateUniqueName(parts.slice(0, index + 1)); @@ -124,7 +124,7 @@ const handleResource = ({ const integration = generateGatewayIntegration({ id: uniqueName, - gatewayResourceId: currentPathName, + gatewayResourceId: gatewayResourceId, lambdaName, params: urlParams, queryStringParams diff --git a/src/resources/terraFormGatewayIntegration.js b/src/resources/terraFormGatewayIntegration.js index 44f26f5..52e4021 100644 --- a/src/resources/terraFormGatewayIntegration.js +++ b/src/resources/terraFormGatewayIntegration.js @@ -34,12 +34,7 @@ function _generateResource( ) { const resource = { rest_api_id: "${aws_api_gateway_rest_api." + getGatewayKey() + ".id}", - resource_id: - "${aws_api_gateway_resource." + - getGatewayKey() + - "-" + - gatewayResourceId + - ".id}", + resource_id: "${aws_api_gateway_resource." + gatewayResourceId + ".id}", http_method: "GET", integration_http_method: "POST", type: "AWS_PROXY", diff --git a/tests/__snapshots__/generateApiGatewayConfiguration.test.js.snap b/tests/__snapshots__/generateApiGatewayConfiguration.test.js.snap index 1a9dc93..c8d4134 100644 --- a/tests/__snapshots__/generateApiGatewayConfiguration.test.js.snap +++ b/tests/__snapshots__/generateApiGatewayConfiguration.test.js.snap @@ -12,7 +12,7 @@ Object { "integration.request.querystring.hideComments": "method.request.querystring.hideComments", "integration.request.querystring.page": "method.request.querystring.page", }, - "resource_id": "\${aws_api_gateway_resource.CustomKey-url.id}", + "resource_id": "\${aws_api_gateway_resource.CustomKey-blog-detail-url.id}", "rest_api_id": "\${aws_api_gateway_rest_api.CustomKey.id}", "type": "AWS_PROXY", "uri": "arn:aws:apigateway:\${local.aws_region}:lambda:path/2015-03-31/functions/\${aws_lambda_function.lambdaForCustomKey-blogPost.arn}/invocations", @@ -23,7 +23,7 @@ Object { "request_parameters": Object { "integration.request.path.url": "method.request.path.url", }, - "resource_id": "\${aws_api_gateway_resource.CustomKey-url.id}", + "resource_id": "\${aws_api_gateway_resource.CustomKey-blog-url.id}", "rest_api_id": "\${aws_api_gateway_rest_api.CustomKey.id}", "type": "AWS_PROXY", "uri": "arn:aws:apigateway:\${local.aws_region}:lambda:path/2015-03-31/functions/\${aws_lambda_function.lambdaForCustomKey-singleBlogPost.arn}/invocations", diff --git a/tests/terraFormGatewayIntegration.test.js b/tests/terraFormGatewayIntegration.test.js index 00bc0bb..b03c41e 100644 --- a/tests/terraFormGatewayIntegration.test.js +++ b/tests/terraFormGatewayIntegration.test.js @@ -12,7 +12,7 @@ describe("Gateway integration", () => { const resource = generateGatewayIntegration({ id: "index", - gatewayResourceId: "index", + gatewayResourceId: "CustomKey-index", lambdaName: "index" });