Re: Using amber with AWS Lambda Functions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Using amber with AWS Lambda Functions

Dave Mason-2
PharoJS also directly support node apps, although our documentation needs work.

../Dave
On May 17, 2019, 10:37 AM -0400, Stefan Krecher <[hidden email]>, wrote:
Hi,
Since there is an AWS SDK for node/ javascript, it should be possible to write code with amber to interact with the AWS API.
This would be extremly cool and usefull - you could write backend code with amber to orchestrate AWS services. Then expose the backend via AWS API-Gateway/ REST-Resource and access it from the Amber UI that might be hosted in an S3 bucket (or any other static file hosting). If amber was able to use/ include the AWS Amplify framework on the UI part, we'll get authentication/ authorization/ user management and secure calls to the backend for free.
Sounds like a really nice serverless application stack - and it would be a dream to use Smalltalk on the front- and backend.
To get started I would need to export Amber/ Smalltalk code in a way that I can reference single functions to be used as AWS Lambda funtion.
Below is a minimal Lambda function - it's a file that's called index.js. During the deployment to AWS I declare "index.handler" es the entry-point of the Lambda-Function.

exports.handler = async (event) => {
    // TODO implement
    const response = {
        statusCode: 200,
        body: JSON.stringify('Hello from Lambda!'),
    };
    return response;
};

Can anyone point me in the right direction, if it would be possible, to export code from amber that looks like the above snippet?
Dependencies and even own runtimes can be included too if needed.

Sadly (or luckily?) I was able to avoid using Javascript since it became so popular - my experience with javascript/ node and the whole ecosystem is very limited.

Regards
Stefan

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/amber-lang/4258f7d7-d8a8-459c-86ae-78707bd7ebfc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/amber-lang/11cb296b-97cc-4c53-9a7b-bf4d3de256ba%40Spark.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Using amber with AWS Lambda Functions

Herby Vojčík
On 17. 5. 2019 16:37, Stefan Krecher wrote:

> Hi,
> Since there is an AWS SDK for node/ javascript, it should be possible to
> write code with amber to interact with the AWS API.
> This would be extremly cool and usefull - you could write backend code
> with amber to orchestrate AWS services. Then expose the backend via AWS
> API-Gateway/ REST-Resource and access it from the Amber UI that might be
> hosted in an S3 bucket (or any other static file hosting). If amber was
> able to use/ include the AWS Amplify framework on the UI part, we'll get
> authentication/ authorization/ user management and secure calls to the
> backend for free.

Seems like a lot of concepts here.

To use any JS library from UI part of Amber app, it's pretty easy -
include a JS library in a project dependencies, `import:` it in a
package that uses it and call via Smalltalk message; more or less how it
is shown in old wiki article here:
https://github.com/amber-smalltalk/amber/wiki/From-smalltalk-to-javascript-and-back.

> Sounds like a really nice serverless application stack - and it would be
> a dream to use Smalltalk on the front- and backend.
> To get started I would need to export Amber/ Smalltalk code in a way
> that I can reference single functions to be used as AWS Lambda funtion.
> Below is a minimal Lambda function - it's a file that's called index.js.
> During the deployment to AWS I declare "index.handler" es the
> entry-point of the Lambda-Function.
>
> |
> exports.handler = async (event) => {
>      // TODO implement
>      const response = {
>          statusCode: 200,
>          body: JSON.stringify('Hello from Lambda!'),
>      };
>      return response;
> };
> |

If you ask how to compile amber to be run out of browser, there is
possibility to compile Amber project as a node executable (`amber` cli
itself is written in Amber), there is not yet any try of which I know to
wrap it in Lambda-compatible way, but it should be possible. Anyway, any
call would need to load much more than the code itself - the whole
kernel with classes and methods; but similarly to how node apps are
built, an export usable for Lambda should be able to be built as well.
It is basically matter of setting up the JS build stack - `grunt deploy`
building one js file for UI project deployments is one such setup,
`build:cli` task in Amber's own Gruntfile.js which build the
aforementioned `amber` cli as node executable is another such setup; a
third setup that instructs JS build machinery to produce
Lambda-consumable artifact would be third such setup.

It seems to me that starting with "node app" setup is the easiest way -
maybe install Amber for development (as shown in
https://lolg.it/amber/amber/src/master/CONTRIBUTING.md#setup-your-amber-clone)
and take your clues from the way `amber` cli is built, changing the
wrapping so the output is lambda-compatible.

> Can anyone point me in the right direction, if it would be possible, to
> export code from amber that looks like the above snippet?
> Dependencies and even own runtimes can be included too if needed.
>
> Sadly (or luckily?) I was able to avoid using Javascript since it became
> so popular - my experience with javascript/ node and the whole ecosystem
> is very limited.
>
> Regards
> Stefan

Herby

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/amber-lang/46c703a0-e1a3-e3b9-f368-6dddfedb99d0%40mailbox.sk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Using amber with AWS Lambda Functions

Herby Vojčík
On 17. 5. 2019 20:51, Stefan Krecher wrote:

> Herby,
> Thank you so much for taking the time to write such a detailed answer!
> I’ll follow your instructions.
> I’ve been developing these kind of applications with react for the UI
> and with python for the backend - using Smalltalk on both sides would be
> so cool!
> Serverless + Smalltalk - sounds like a Perfect match ;-)
> Regards
> Stefan
>
> Herby Vojčík <[hidden email] <mailto:[hidden email]>> schrieb am Fr.
> 17. Mai 2019 um 19:52:
>
>     On 17. 5. 2019 16:37, Stefan Krecher wrote:
>      > Hi,
>      > Since there is an AWS SDK for node/ javascript, it should be
>     possible to
>      > write code with amber to interact with the AWS API.
>      > This would be extremly cool and usefull - you could write backend
>     code
>      > with amber to orchestrate AWS services. Then expose the backend
>     via AWS
>      > API-Gateway/ REST-Resource and access it from the Amber UI that
>     might be
>      > hosted in an S3 bucket (or any other static file hosting). If
>     amber was
>      > able to use/ include the AWS Amplify framework on the UI part,
>     we'll get
>      > authentication/ authorization/ user management and secure calls
>     to the
>      > backend for free.
>
>     Seems like a lot of concepts here.
>
>     To use any JS library from UI part of Amber app, it's pretty easy -
>     include a JS library in a project dependencies, `import:` it in a
>     package that uses it and call via Smalltalk message; more or less
>     how it
>     is shown in old wiki article here:
>     https://github.com/amber-smalltalk/amber/wiki/From-smalltalk-to-javascript-and-back.
>
>      > Sounds like a really nice serverless application stack - and it
>     would be
>      > a dream to use Smalltalk on the front- and backend.
>      > To get started I would need to export Amber/ Smalltalk code in a way
>      > that I can reference single functions to be used as AWS Lambda
>     funtion.
>      > Below is a minimal Lambda function - it's a file that's called
>     index.js.
>      > During the deployment to AWS I declare "index.handler" es the
>      > entry-point of the Lambda-Function.
>      >
>      > |
>      > exports.handler = async (event) => {
>      >      // TODO implement
>      >      const response = {
>      >          statusCode: 200,
>      >          body: JSON.stringify('Hello from Lambda!'),
>      >      };
>      >      return response;
>      > };
>      > |

BTW. If Lambda accepts AMD format as well (I don't know, just saying)
then it should be even easier as the current ecosystem of Amber is built
around AMD and uses RequireJS to build - in that case starting from
`deploy` task of standard `amber init`-created project would be probably
easier / faster. In case you need node's CommonJS format, then of course
starting with nodejs type build is the way.

Herby

>
>     If you ask how to compile amber to be run out of browser, there is
>     possibility to compile Amber project as a node executable (`amber` cli
>     itself is written in Amber), there is not yet any try of which I
>     know to
>     wrap it in Lambda-compatible way, but it should be possible. Anyway,
>     any
>     call would need to load much more than the code itself - the whole
>     kernel with classes and methods; but similarly to how node apps are
>     built, an export usable for Lambda should be able to be built as well.
>     It is basically matter of setting up the JS build stack - `grunt
>     deploy`
>     building one js file for UI project deployments is one such setup,
>     `build:cli` task in Amber's own Gruntfile.js which build the
>     aforementioned `amber` cli as node executable is another such setup; a
>     third setup that instructs JS build machinery to produce
>     Lambda-consumable artifact would be third such setup.
>
>     It seems to me that starting with "node app" setup is the easiest way -
>     maybe install Amber for development (as shown in
>     https://lolg.it/amber/amber/src/master/CONTRIBUTING.md#setup-your-amber-clone)
>
>     and take your clues from the way `amber` cli is built, changing the
>     wrapping so the output is lambda-compatible.
>
>      > Can anyone point me in the right direction, if it would be
>     possible, to
>      > export code from amber that looks like the above snippet?
>      > Dependencies and even own runtimes can be included too if needed.
>      >
>      > Sadly (or luckily?) I was able to avoid using Javascript since it
>     became
>      > so popular - my experience with javascript/ node and the whole
>     ecosystem
>      > is very limited.
>      >
>      > Regards
>      > Stefan
>
>     Herby
>
> --
> Dipl.-Wirtsch.-Inf. Stefan Krecher
> Neulander Str. 17, 27374 Visselhövede
> Tel +49(0)4262 958848
> mobil +49(0)172 4396852
>
> --
> You received this message because you are subscribed to the Google
> Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [hidden email]
> <mailto:[hidden email]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/amber-lang/CADB_sZzcdXovJAjk9xmrMvLm4oKaOCfxA%3DrRo%2BtDg1XE0kprng%40mail.gmail.com 
> <https://groups.google.com/d/msgid/amber-lang/CADB_sZzcdXovJAjk9xmrMvLm4oKaOCfxA%3DrRo%2BtDg1XE0kprng%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/amber-lang/83501ae5-d15b-7b3f-3380-5e778aa04032%40mailbox.sk.
For more options, visit https://groups.google.com/d/optout.