Skip to content
This repository has been archived by the owner on Jul 23, 2023. It is now read-only.

Commit

Permalink
fix: integration name and how to validate files
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Jun 10, 2019
1 parent 653f868 commit 9c0a33a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 22 deletions.
2 changes: 1 addition & 1 deletion integration/app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
route: "/blog/:url"
},
{
page: "/contacts",
page: "/contact",
route: "/contact-us"
}
]
Expand Down
18 changes: 8 additions & 10 deletions integration/aws/api.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -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"),
))}"
}
4 changes: 2 additions & 2 deletions src/generateApiGatewayConfiguration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -124,7 +124,7 @@ const handleResource = ({

const integration = generateGatewayIntegration({
id: uniqueName,
gatewayResourceId: currentPathName,
gatewayResourceId: gatewayResourceId,
lambdaName,
params: urlParams,
queryStringParams
Expand Down
7 changes: 1 addition & 6 deletions src/resources/terraFormGatewayIntegration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tests/terraFormGatewayIntegration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("Gateway integration", () => {

const resource = generateGatewayIntegration({
id: "index",
gatewayResourceId: "index",
gatewayResourceId: "CustomKey-index",
lambdaName: "index"
});

Expand Down

0 comments on commit 9c0a33a

Please sign in to comment.