Event Bridge schedulers - Call my API gateway endpoint - aws-event-bridge

I'm trying to use event bridge's new scheduler functionality:
I don't see the option "Call endpoint...", I did further reading and apparently is possible by sending a JSON but the format of that JSON is a big mystery and I can't find an example.
Is it possible to provide a working example of that, all that I tried is just not working.
EDIT:
This is an AWS cli example for something else:
aws scheduler create-schedule --schedule-expression "at(2022-11-20T13:00:00)" --name schedule-name \
--target '{"RoleArn": "role-arn", "Arn": "QUEUE_ARN", "Input": "TEST_PAYLOAD" }' \
--schedule-expression-timezone "America/Los_Angeles"
--flexible-time-window '{ "Mode": "OFF"}'
The --target should be changed to call my API gateway endpoint but I can't figure out what are the required fields.
EDIT2:
Was suggested that (this question) may provide a solution, but so far the accepted solution raises another question:
It appears you are right that the brand-new EventBridge Scheduler
console interface does not yet (?) support API Destinations.
I would like to do it in schedulers not rules, the way I see it schedulers is more adequate to what I'm trying to do, and I already have a solution using rules

Related

Start and verify Dart VM service

I have a two part question.
First, what Dart command should I use to "start"
the VM service listening for requests, with possibly
giving it what host and port number to use.
I'm using Windows, and I don't need the Observatory possibly
interfering.
I'm currently trying to use this, after I CD into the project's directory:
dart --pause_isolates_on_start bicycle
And the second part of the question is, is it possible to verify
that the VM service is there and listening on whatever port?
I want to be able to send a request to the VM service,
from a WebSocket client, and get back a response.
After I give the above command, if I do a 'netstat'
it doesn't look like there is anything there listening.
And any attempts at trying to connect to the VM service get
a connection refused Exception, same as if I didn't even
try to start the VM service.
UPDATE:
I was looking at the intelliJ plugin code, to see how they did their connect,
and saw that they used "ws://localhost:8181/ws", I was trying to use
"ws://localhost:8181", and now it's finally getting past the handshake,
the server was returning "200 OK" instead of "101" before.
I'm assuming that I'm talking to the Observer at this point,
and not the VM service, I'm not sure, but at least I'm further along..
When it worked, I was using:
dart --enable-vm-service --pause_isolates_on_start bicycle.dart
Thanks!!
dart --help -v prints
--observe[=<port>[/<bind-address>]]
The observe flag is a convenience flag used to run a program with a
set of options which are often useful for debugging under Observatory.
These options are currently:
--enable-vm-service[=<port>[/<bind-address>]]
--pause-isolates-on-exit
--pause-isolates-on-unhandled-exceptions
--warn-on-pause-with-no-debugger
This set is subject to change.
Please see these options for further documentation.
It depends on what exactly you want to do, but as far as I know the Observatory just uses this service and if you don't access any of its features, it won't add additional load to the process.
There is a Dart client API https://pub.dartlang.org/packages/vm_service_client and a documentation about the protocol https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md
Perhaps this is what you are looking for
enum EventKind {
// Notification that VM identifying information has changed. Currently used
// to notify of changes to the VM debugging name via setVMName.
VMUpdate,
// Notification that a new isolate has started.
IsolateStart,
used with Events https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md#events

Fn project is missing http operations (CRUD)

I have spent my afternoon getting very excited about the container-native serverless platform 'fn project' - http://fnproject.io/.
I love the idea of the FaaS model but have no intention of locking myself into a particular cloud vendor for most of the lifetime of an app - and several other reasons including the desire to spin up the entire app on a small server anywhere if I choose.
fn project seems great for my needs until I finish perusing the documentation and all the relevant blog posts and suddenly think 'what? Wait....what??? Where are the http operations?'.
I cannot find a single reference anywhere that states if it is even possible to to have http triggers for different http operations (ie POST, PUT, PATCH, DELETE), let alone how I would do it.
I want to build REST api's (or certainly at the very least json-serving http-based RPC apis - if it doesn't have hypermedia links it isn't REST ;) but let's not get into that one in this thread)
Am I missing something here (certainly the correct bit of documentation)??
Can anybody please enlighten me as to how I would do this, or even tell me if I have totally misunderstood what I should use this for?
My excitement has gone soft for now but I'm hoping someone that will change with the right information.
It feels odd that I can't find anyone else complaining about this, so I think that indicates my misunderstanding perhaps.
Other solutions such as OpenFaaS look interesting but I dont wan't to have to learn how to deploy kubernetes and docker swarms if I can avoid it :)
I'm not an expert, but as of now it seems not possible to specify the http method inside the trigger. Check latest trigger spec : as you can see, there is no notion of http method here.
However, handling different HTTP methods can be done inside the function itself.
For example, in Java (with fdk-java v1.0.80), you can use com.fnproject.fn.api.httpgateway.HTTPGatewayContext as the first parameter of the function, as described in the section "Accessing HTTP Information From Functions" of the documentation :
In Fn for Java, when your function is being served by an HTTP trigger (or another compatible HTTP gateway) you can get access to both the incoming request headers for your function by adding a 'com.fnproject.fn.api.httpgateway.HTTPGatewayContext' parameter to your function's parameters.
Using this allows you to :
...
Access the method and request URL for the trigger
...
You can then retrieve the HTTP method by calling getMethod() on the HTTPGatewayContext passed as parameter.
In other languages (with others fdk), it's possible to do the same :
in Go : example calling RequestMethod() on context
in Ruby : class HTTPContext
in Python : class HTTPGatewayContext
in Node : class HTTPGatewayContext
From this different contexts, you'll then be able to get method parameter passed when fn invoke --method=[GET|POST|...] (via fn-http-method header).
The main drawback here is that all HTTP methods should be handled in the same function. Nonetheless, you can structure your code to have only one class per method.
After some further thought it seems fairly clear now what my actual misunderstanding was....
When I have built Serverless framework services in the past (or built and deployed Lambda functions using terraform) I have been deploying to AWS and so have been using AWS's API Gateway offering (their product is actually called API gateway but its important to recognise that API Gateway is a distributed systems / micro-sevices design pattern).
API gateway makes it possible to route specific http request types including the method (GET,POST,PUT,DELETE) to the desired functions.
Platforms such as Fn project and OpenFaaS do not provide an out of the box api gateway solution and it seems we would need to take care of this ourselves.
These above mentioned platforms are about deployment of functions. We find the other bits via our product of choice.

how work with shinken livestatus API

Good day. I first work with Shinken and similar products in general.So do not judge strictly.
The question is how to get the data through Shinken Livestatus API.
Shinken is installed and running. Livestatus is configured and running on the localhost:50000. Ping is coming.
But I can not understand how to ask something, get some data. The documentation did not shed much light on my question. And whether it is possible through this API to receive metrics which sends CollecD to mod-collectd
After experimenting and studying the source code, I came to this conclusion. In the livestatus module, you can open a port or unixsocket, this is understandable. But here you can refer to it from the commands found in the source code mapping.py in the dictionary livestatus_attribute_map.
The main thing after the request is to put two line breaks !!!
Example thru HTTP:
curl -i -X POST http://host:50000/query -H "Content-Type: text/xml" --data-binary "#/path_to_query/query"
query - this is file, with command.
Example: cat query
----------------------
GET hosts
----------------------
The main thing is not to forget about the transfer line!

Firebase: Access the database from URL

In my Swift app, I am going to be using Vungle for incentivized ads. The way this works is that the Vungle Servers will ping any URL that I give them. For example:
myapp.firebase.com/db_location/section/user_id/?value=123
I have looked around lots of websites and now my head hurts as I cannot seem to find a solution. Is there a way to insert into my Firebase database (securely, without write all access) request that is sent via a URL?
This would be similar I assume to the API Gateway that AWS supplies.
Looking for advice, pointers/tutorials etc.
You can use Firebase REST API which allows you to insert into your database using POST requests.
An example using curl from the documentation:
curl -X POST -d '{"user_id" : "jack", "text" : "Ahoy!"}' \
'https://samplechat.firebaseio-demo.com/message_list.json'

How do I send in a REST request (to use an API)?

I'm writing a small web app for myself in Rails and I want it to use Last.fm's API. I'm incredibly new to web development in general, so I'm not sure where to even begin.
http://www.last.fm/api/rest
I'm not asking for a step-by-step tutorial or anything like that, but a nudge in the right direction would be awesome. Or even just a little example code.
Installing HTTParty will get you started, you might also want to make some calls to the API from the command line using cURL just to understand how it works. Just type cURL and the restful URL on the commandline:
prompt> curl http://www.whatever.com/resource for a get
prompt> curl -d '{ "arg" : "value" }' http://www.whatever.com/ for posts etc.
Often understanding what comes back in each of the calls will help you structure your app. Have fun.
Dupe of this 748614
Simply speaking - use the HTTParty gem, it does literally everything for you.

Resources