Lambda Returned Payload Different Than Received Payload - amazon-web-services

I have an AWS Lambda function that has been working as expected for months. It delivers a python dictionary using json.dumps
I added a new variable to the dictionary with a string 'true' or 'false' value. I store the dictionary into a variable, and log it one line before returning it using the same variable to the requester.
The logger shows the payload has 'variable_name': 'true' but when it gets delivered to the requested, it changes to 'false'.
What could cause the variable to change?

The problem was website server caching as part of a Wordpress plugin. Clearing the website cache fixed the problem.

Related

Loosing current values API Keys stored in environment variable in Postman

I have stored my API keys as environment variables in Postman. After logging into my API, a script reads fields and sets current values using pm.environment.set('api-key-token', data.api_key).
The issue/inconvenience I am having is every time I change a Query param, I lose my API key current value. I thought the current values are only lost when you log out of your postman. Is this behavior normal?

AWS API Gateway Caching by Query Parameter not working

This is question is slightly different than this question, but related. I have AWS API gateway setup with a single GET method, which has 1 query parameter search. This GET call returns a list of words based on the search string. I have turned on caching by this query parameter, but get the same results, no matter the query parameter. When I turn caching off, it works as expected.
First request search=a* => words that start with a are returned, as expected
Second request search=b* => words that start with a are returned, but I expect words that start with b.
Why aren't my requests being cached by the query parameter?
API Settings:
Method Query Parameter:
It might help if I actually deployed the API after making the changes.

Elastic search returning empty result even when data is present

I have a scenario where elasticsearch (version 2.3) is not returning results even though data is present.
The same request gets a response on retrying. But why does elastic search fails to fetch a response in the first time.
Any help in understanding
NOTE: I am querying the data using "match". So the text analyzer issue mustn't be in play (https://www.elastic.co/blog/found-beginner-troubleshooting). Also it gives result on retry
Found the answer for initial question: Updating the question
https://discuss.elastic.co/t/how-documents-read-and-write-work-in-elasticsearch-if-we-doing-this-on-the-same-document-simultaneously/125139

Path based AWS API Caching Keys Issue

I have several API paths set up in a test API Gateway setup with a simple 'api' stage. I am using AWS Lambda and wish to cache the results of the lambda call.
There are three test paths (no authentication)
/a/{thing} (GET Caching turned on in stage)
/b/{thing} (GET Caching turned off in stage)
/c/{thing} (GET Caching turned off in stage)
They all map to the same lambda function. The lambda function returns the current time and the value of {thing}.
If I request /a/0000 through /a/1000 I get back the same result for a function that ran for thing=0000.
If I request /b/0000 through /b/1000 (or /c/) I get back uncached results.
thing is selected as 'cache' in resources /a/{thing}. Nothing else is set 'cache'.
It is my understanding that selecting 'cache' next to a path element, query element, or header would construct a cache key - possibly a multi-key cache key hash. That would be ideal!
Ideally /a/0000 and /a/1234 would return a cached version keyed to the {thing} value.
What did I do wrong or misread or step over? Am I hitting a bug when it comes to AWS Lambda? Is caching keyed to authorization - these URLs are public and unauthenticated. I'm just using curl to request these and nothing is being cached on the client side of course.
Honestly. I've also tried using a query argument as the only cache key and let the cache flush and waited 30 minutes to try try try again. Still not giving the results I would expect.
Pro Tip:
You still have to deploy from resources to stage when you set up cache keys. This makes sense of course but it would be good if the management console showed more about the method parameters than it does.
I am using Chalice.. which is why I wasn't deploying in the normal fashion.

How do I set the cache key for the AWS API Gateway?

I have a Lambda function that is mapped to a HTTP endpoint using the AWS API Gateway. This works fine, I have mapped query string params to the Lambda event, everything works:
https://api.buzzcloud.xyz/?count=999
Which I can call from http://buzzcloud.xyz
I would like to enable caching, but it seems that by default the API Gateway uses the URL for caching, and so changes in my query string parameters are not triggering a different cache result.
The result is that with caching on, my page returns whatever data was first requested and put in the cache.
How do I set a custom cache key or ensure querystring is part of the cache identifier?
Turns out the is a not-so-secret setting that I totally missed that allows for the exact query string params that should be used for the cache to be set.