Page 1 of 1

AWS Switch Scripting Project

Posted: Tue Dec 23, 2014 4:50 am
by gabrielp
I'd really like to get a solid collection of Amazon Web Services (AWS) scripts that work with Switch. Imagine being able to store files easily into S3, build queue-centric workflows with SQS, or response to events in Switch with a decoupled compute service like Lambda.

My original plan was to wait until I got my hands on Switch 12 Update 3's new HTTP class. But as soon as I had access to it, I realized that reinventing a RESTful wheel Amazon has already made with their SDK would be a fool's errand. So instead, after a bit of thought, I've decided to write each method in Node.js as a command line utility. Then, Switch will then simply pass arguments into a Process.execute() to invoke Node. So, a base requirement is having Node.js installed.

I already have one Script working: S3 Upload. It takes an input file and uploads it to an S3 bucket of your choosing, returning the URL on S3. I need to add some ACL settings so you can choose whether or not you want it to be public-read.

If this interests any of you, I'd love it if you joined the repo and pitched in. This could be a great tool for all of us.

Here is my repo: https://github.com/dominickp/SwitchAWS

Questions, comments, complaints? Looking forward to discussing this.

AWS Switch Scripting Project

Posted: Thu Dec 25, 2014 5:17 pm
by gabrielp
After giving this some thought, I'm not sure what I was thinking making a CLI in Node. I think I wanted to take advantage of the AWS-SDK hoping I could do work to the request/files somehow, but if I continue with this model of invoking a CLI then I can do lots of that within the Switch script... So I don't see the point in re-making the CLI in Node since AWS CLI is really good already available. I'll make an update soon to update the S3 Upload configurator I already made.

AWS Switch Scripting Project

Posted: Fri Dec 26, 2014 9:25 am
by ArielRauch
I am quite curious to see your progress.

Probably the only one these days:)

AWS Switch Scripting Project

Posted: Fri Dec 26, 2014 6:13 pm
by dkelly
Should we create issues for each of the features that folks want to implement? That way we can track status & assignments, avoid duplicate effort, etla.

AWS Switch Scripting Project

Posted: Sun Dec 28, 2014 12:34 am
by gabrielp
ArielRauch wrote: I am quite curious to see your progress.
Make sure to click "Watch" on the repo!



dkelly wrote: Should we create issues for each of the features that folks want to implement? That way we can track status & assignments, avoid duplicate effort, etla.


That's a great idea. I will put in some issues of ideas I have in the works.

AWS Switch Scripting Project

Posted: Sun Dec 28, 2014 12:40 am
by gabrielp
Is everyone cool with the MIT license? https://github.com/dominickp/SwitchAWS/ ... er/LICENSE

Re: AWS Switch Scripting Project

Posted: Tue Feb 24, 2015 4:57 pm
by jugganaut
@gabrielp - this sounds pretty interesting. Just wondering what sort of uses you envisioned this connection to have?

Also, another service that you might check out that I've just recently finished an API project with is DreamFactory - it's an open source API framework of sorts that you can connect to any database type.

Re: AWS Switch Scripting Project

Posted: Fri Apr 24, 2015 1:54 pm
by tz8
for you mac guys out there, some nice person actually included awscli in the macports

to install (given that you have macports installed already):

Code: Select all

sudo port selfupdate
sudo port install py27-awscli py27-pip
port select --set pip pip27
sudo -H pip install awscli
then you can work with aws on the command line, try it by opening the help page with:

Code: Select all

/opt/local/bin/aws-2.7 help

Re: AWS Switch Scripting Project

Posted: Wed Aug 12, 2015 4:17 pm
by gabrielp
Hey guys,
We're running into an issue with the S3 Download script: https://github.com/dominickp/SwitchAWS/ ... ownload.js

The issue seems to be that when a timerFired event occurs and the script executes, it opens a process but that process is never released. If I leave the flow on overnight with the timerFired set to two minutes, it eventually hits the process limit on the machine and the only way to clear it out is to restart the machine.

Could someone with timerFired script experience take a quick look at that script and let me know if I forgot anything glaring? Is there something I'm supposed to do to tell Switch to exit the process?

Re: AWS Switch Scripting Project

Posted: Wed Aug 12, 2015 5:50 pm
by dkelly
Have you been able to determine if the unterminated processes are Switch or AWS scripts?

Re: AWS Switch Scripting Project

Posted: Wed Aug 12, 2015 6:19 pm
by gabrielp
dkelly wrote:Have you been able to determine if the unterminated processes are Switch or AWS scripts?
If you do a ps -A, the processes show up like this:

Code: Select all

10815	??	0:00.00 (SwitchScriptExec)
10830	??	0:00.00 (SwitchScriptExec)
10846	??	0:00.00 (SwitchScriptExec)
So it seems the processes are Switch processes.

Re: AWS Switch Scripting Project

Posted: Thu Aug 13, 2015 11:57 pm
by gabrielp
gabrielp wrote:Hey guys,
The issue seems to be that when a timerFired event occurs and the script executes, it opens a process but that process is never released. If I leave the flow on overnight with the timerFired set to two minutes, it eventually hits the process limit on the machine and the only way to clear it out is to restart the machine.
This is now fixed: https://github.com/dominickp/SwitchAWS/issues/8

Re: AWS Switch Scripting Project

Posted: Tue Jul 12, 2016 8:27 pm
by gabrielp
I've added SES Send, which acts as a drop-in replacement for Switch's "Mail send" configurator. More here: https://github.com/open-automation/SwitchAWS