Comments (5)
Have you check in the "Request Paths" section? That {name}
is not a Query string but a request path.
This is how the dashboard looks like for the apigateway example (https://github.com/jorgebastida/gordon/tree/master/examples/apigateway)
from gordon.
You're right (obviously), the name
parameter is in the Request Paths.
I read http://docs.aws.amazon.com/apigateway/latest/developerguide/integrating-api-with-aws-services-lambda.html and realized that I was missing the configuration for the Integration Request.
I added this manually:
The test in the API Gateway page passed. I deployed the API and it works with curl
as well.
I have to figure out with piece of configuration I'm missing in gordon. I expected I had nothing to do and that declaring the parameter would setup the Integration Request too.
from gordon.
I made further investigations.
I cloned the gordon repository, moved to the examples/apigateway folder, changed the name of the bucket and deployed the example.
That also doesn't configure the Integration Request.
You can try curl https://dpyif1qb1g.execute-api.eu-west-1.amazonaws.com/dev/shop/x
which is defined as /shop/{item}
in settings.yml
I modified the example to print out the events
object, which is empty.
Which is the way to access the value of item
? In my previous comment I show how to do it using Integration Request.
I added an explicit parameters definition:
/shop/{item}:
methods: GET
integration:
lambda: helloworld.hellojs
parameters:
integration.request.querystring.item: method.request.path.item
(I switched to helloworld.hellojs
because I'm more familiar with JS).
The AWS documentation hints that the item
from the URL path should go to the right and the destination should go to the left. I'm not sure that querystring
is the way to tell AWS to put that item
into the events
object.
With those lines gordon apply
fails:
Applying project...
0001_p.json (cloudformation)
✓ No updates are to be performed.
0002_pr_r.json (custom)
✓ code/contrib_lambdas_version.zip (dcfc39a5)
✓ code/helloworld_hellojs.zip (25db66b4)
✓ code/helloworld_hellopy.zip (5cecbbbc)
0003_r.json (cloudformation)
UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS waiting... |
Unfortunately there is no detailed error message.
All the examples that define parameters for the API Gateway don't use those parameters in the lambda functions. Could you give a working example of a lambda function that uses those parameters? Thanks.
A final remark: in the spirit of convention over configuration (I remember your comment on HN) I think that we shouldn't even declare how to map parameters to events
. gordon should automatically configure the API Gateway to pass any parameter to lambda. Path and querystring parameters should be the same. Parameters from the headers could get some special name, such has HEADER_parameter
.
The last two lines here shouldn't be needed:
/parameters:
# http://docs.aws.amazon.com/apigateway/latest/developerguide/request-response-data-mappings.html
methods: GET
parameters:
method.request.header.color: True
integration:
lambda: helloworld.hellopy
responses:
- pattern: ""
code: "200"
parameters:
integration.request.querystring.color: method.request.header.color
from gordon.
I eventually realized that if I POST a JSON to an API Gateway URL it gets forwarded to the events
object in Lambda. This is from https://github.com/jorgebastida/gordon/tree/master/examples/apigateway
$ curl -X POST -H "Content-Type: application/json" -d '{"this":"is","json":"data"}' \
https://your-api-gw-url.amazonaws.com/dev/complex/implementation
"Hello from js!\nEvent\n{\n \"this\": \"is\",\n \"json\": \"data\"\n}\n"
That is totally OK for sending data.
from gordon.
Just found this. @pmontrasio wondering if #117 is related to this?
from gordon.
Related Issues (20)
- Option to fix lambda name in settings.yml
- Add support for configuring DLQ HOT 1
- Issues with nodejs6.10 HOT 7
- question about gordon build
- iam:GetRole still needed
- 'gordon' with no args raises error
- Add python3.6 runtime HOT 5
- Step Functions
- Typo? "context_destinaton"
- Share build settings between lambdas?
- requires troposphere <2.0 HOT 1
- S3 bucket name collision conflict when used across multiple accounts
- gordon appears to ignore npm failures HOT 1
- Can't integrate my kinesis Stream
- version 0.7.0 not published for python3? HOT 3
- python 3 string issue
- EC2 Throttling Issue
- unable to use gordon in aws china
- API Gateway: Headers integration lambda parameters was lost on deply
- wrong project
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gordon.