AWS API creation delay? - amazon-web-services

I'm currently using aws-amplify for react native. I'm using the API command to do HTTP requests and I was able to call a GET method API that I created few months ago. The thing is when I call a function that's freshly made, it keeps telling me that the "Api 'API name' doesn't exist". I tried to see if there was any typo, but nothing. I also created a GET method API with the exact same code as the one that was working but same result (api doesn't exist). Has anyone also run into this issue?

Can you post your sample code including the object you're passing to Amplify.configure(object) and also the GET call which includes the name (API.get(name, path, options)()? You'll need to ensure that the name is in the endpoints[] array of your configuration object per the documentation and that this matches the name passed in your method call. For more information see this page: https://github.com/aws/aws-amplify/blob/master/media/api_guide.md

Related

API Gateway not passing event to lambda from console?

I'm trying to call a basic lambda from my API Gateway console. The lambda has an input taken in by the event called filterBy.
I created a query string called filterBy however, when I try to invoke the lambda I get the error:
{errorMessage: {'statusCode': 500, 'body': '{"msg": "KeyError(\'filterBy\')"}'}}
Presumably because the piece of code in my lambda
event['filterBy'] is not finding a filterBy in the event. What do I need to do so that I can get the filterBy in the event from the API Gateway console? I understand this is probably quite simple but I surprisingly cannot find anything about this so any help would be appreciated.
Based on the integration type, approach can be vary.
1. Lambda custom integrations:
Looks like you are trying to use Lambda custom integrations. If that is the case you have to add a mapping template as below.
(under the Integration Request -> Mapping Templates --> Add mapping template)
{
"filterBy": "$input.params('filterBy')"
}
Please refer this article or this video for more info.
2. Lambda proxy integrations:
If you are using Lambada proxy integration (either as REST API or as HTTP APIs), then instead of event['filterBy'], you have to access the queryStringParameters first and then access the relevant query param.
event['queryStringParameters']['filterBy']
And another thing is: once you modify something in API GW, please make sure to deploy and wait some time before test. :)

Calling operations.get in gcp throws "field [name] has issue [invalid operation name]"

Recently I was trying to get the status of an operation calling operation.get on API explorer in GCP https://cloud.google.com/resource-manager/reference/rest/v1/operations/get
The request throws:
field [name] has issue [invalid operation name]
I tried the same request using node Lib for GCP and got the same result.
Operation name used is in format as below:
operations/operation-1552901443197-5845b0ae4997f-496bcbdb-xxxxxx
Did someone encounter this error before?
The issue is caused because the operation you are trying to fetch is from a different resource from the API that you are calling.
Most Cloud APIs have their own APIs, and each one performs its own operations under their own resource.
In this case you are trying to get your operation in the Resource Manager API, as a Resource Management resource, while it is from the Compute Engine resource, and this API (or this one if the operation is global to your project) should be used instead.
Using this API instead would solve this issue.
I agree that the response message could be improved in order to point users to which is the actual issue, when facing issues like the one in this question.
That's why I have opened a feature request that you can see in the following link. You can star it in order to give it more visibility and notifications on the updates made there, and add comments here if you have any additional information you might add to this improvement.

Failed to get the current sub/segment from the context and addAnnotation of NULL issue in NodeJS

I am getting "Failed to get the current sub/segment from the context" with node lambda. AFter adding environment variable as suggested in another post, I am getting addAnnotation of NULL. Because of this my test are getting failed.
Is there any workaround to make this pass? Help is much appreciated.
Which other post are you referring to?
Can you post the code to reproduce?
When in Lambda, X-Ray does not have access to the segment. The segment is created by Lambda and sent independently. In order for the X-Ray service to reconstruct the full segment/subsegment structure, the SDK picks up an environment varibale set by Lambda, and creates a "facade segment". This represents a placeholder to build off of and cannot be modified.
Typically we advise to create a new subsegment and add the annotation there.
Keep in mind, this will only work within the handler.

Consuming RSS feed with AWS Lambda and API Gateway

I'm a newbie rails programmer, and I have even less experience with all the AWS products. I'm trying to use lambda to subscribe to and consume an rss feed from youtube. I am able to send the subscription request just fine with HTTParty from my locally hosted rails app:
query = {'hub.mode':'subscribe', 'hub.verify':'sync', 'hub.topic': 'https://www.youtube.com/feeds/videos.xml?channel_id=CHANNELID', 'hub.callback':'API Endpoint for Lambda'}
subscribe = 'HTTParty.post(https://pubsubhubbub.appspot.com/subscribe, :query=>query)
and it will ping the lambda function with a get request. I know that I need to echo back a hub.challenge string, but I don't know how. The lambda event is empty, I didn't see anything useful in the context. I tried formatting the response in the API gateway but that didn't work either. So right now when I try to subscribe I get back a 'Challenge Mismatch' error.
I know this: https://pubsubhubbub.googlecode.come/git/pubsubhubbub-core-0.3.html#subscribing explains what I'm trying to do better than what I just did, and section 6.2.1 is where the breakdown is. How do I set up either the AWS Lambda function and/or the API Gateway to reflect back the 'hub.challenge' verification token string?
You need to use the parameter mapping functionality of API Gateway to map the parameters from the incoming query string to a parameter passed to your Lambda function. From the documentation link you provided, it looks like you'll at least need to map the hub.challenge query string parameter, but you may also need the other parameters (hub.mode, hub.topic, and hub.verify_token) depending on what validation logic (if any) that you're implementing.
The first step is to declare your query string parameters in the method request page. Once you have declared the parameters open the integration request page (where you specify which Lambda function API Gateway should call) and use the "+" icon to add a new template. In the template you will have to specify a content type (application/json), and then the body you want to send to Lambda. You can read both query string and header parameters using the params() function. In that input mapping field you are creating the event body that is posted to AWS Lambda. For example: { "challenge": "$input.params('hub.challenge')" }
Documentation for mapping query string parameters

JItterBit HTTP Endpoint

I am working to set up a HTTP Endpoint in JitterBit, for this end point we have a system that will call this Endpoint and pass parameters through the URL to it.
example...
http://[server]:[server port]/EndPoint?Id={SalesForecID}&Status={updated status in SF}
Would i need to use the Text File, JSON or XML Method for this? Follow up question would be if it is JSON or XML what would the file look like that is uploaded during creating the endpoint. I have tired with no success with the text file version.
any help would be great.
I'm just seeing your question now. You may have found a solution, but this took me a while to figure out, so I'll respond anyway.
To get the passed values, go ahead and create your HTTP Endpoint and add a new operation triggered by it. Then, in your new operation create a script with something like the following:
$SalesForceID = $jitterbit.networking.http.query.Id
$UpdatedStatus = $jitterbit.networking.http.query.Status
You can then use these variables elsewhere in your operation chain.
If you want to use these values to feed into another RESTful web service (i.e. an HTTP Source), you'll have to create a separate transformation operation with the HTTP Source. You'd set that source URL to be: http://mysfapp.com/call?Id=[SalesForceID]&Status=[UpdatedStatus]. I'm not sure why, but you can't have the script that extracts the parameters from the Endpoint and the HTTP Source that uses those in the same operation.
Cheers