New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Twilio Runtime to create templates #6467
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @stefanjudis thanks for working on this! This looks really great 👍 💯
Could you add a unit test in create.test.js
so that we can be sure that the correct files are generated? Furthermore you might want to do a global search for another template name (e.g. google-nodejs
) to find other places we usually update when adding new templates.
Thanks again for working on this and let us know if you have any issues!
Hey @pmuens, thanks so much for the swift reply... :) 👌 (sorry that I missed the tests initially - I was mainly following a previous PR) I added a unit test, and searched the project. Unfortunately, I have to admit I'm a bit overwhelmed with the shell/docker magic in the integration tests i found. 😊 https://github.com/serverless/serverless/pull/6467/files#diff-4e5e90c6228fd48698d074241c2ba760R127 👆 Twilio functions run in Edited: |
Great! Thanks for the update @stefanjudis 👍
Yes, picking the matching Node version number for the image should be sufficient. TBH we don't use such tests that often (we might even want to remove them in the future). |
@pmuens I took the closed Node image now... (I think that's good enough for now). Is there anything else that I should have a look into? As mentioned there's no rush on my end. :) Just want to be ready when we open the API. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @stefanjudis, thanks for updating the PR! 👍
@pmuens I took the closed Node image now... (I think that's good enough for now).
Yes, that should do the trick!
Is there anything else that I should have a look into?
We might want to add docs, but I'm not sure if this is strictly necessary for the first step, so I'd put it on hold for the time being.
As mentioned there's no rush on my end. :) Just want to be ready when we open the API. :)
Sounds good. Excited for the official announcement.
@@ -0,0 +1,11 @@ | |||
const logo = require('asciiart-logo'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the code for this dependency coming from? Shouldn't this be listed in the package.json
dependencies section? Or is this available in the Twilio Runtime? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's defined in the serverless.yml
.
I didn't want to mix this with the dependencies defined in the package.json
. Several other parts of our tooling define the function dependencies in a separated config. For the case of serverless framework I thought this makes sense to have all the config in the serverless.yml
. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Haven't seen that 🤔
Thanks for clarifying 👍
The other provider plugins are implemented in a way that one has to explicitly define them in package.json
(or whatever runtime / package manager you're using).
I know that this is not well documented but we suggest to put everything proprietary (which is not part of the original serverless.yml
spec) under the custom
property. This way the Framework can be extended alter on without causing name collision.
TBH I'm fine with either way (whatever is best for Twilio), but I'd suggest to move this property to custom
:
custom:
dependencies:
asciiart-logo: '*'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for having another look. @pmuens
Your points are very interesting and bring up an additional question on my end. I had a look at the initial AWS serverless.yml
and it turns out my proposal is different not only in the dependency part.
I defined the following different properties:
provider.environment
- which has a completely different meaning then in the AWS config (the reason for that is that in the twilio runtimeenvironment
is similar to what astage
in AWS is – I decided to follow naming conventions in our docs)provider.config
- needed configuration token (I more or less copied that approach from the cloudflare serverless plugin implementation 🙈)provider.environmentVars
- the environment variables available in the serviceprovider.dependencies
- needed npm deps which will be provided
I feel like it will be tough to match the AWS keys/properties because there are some major differences and not everything is mappable.
About the custom
approach – I don't have strong feeling about this but I'm not sure if that's not more confusing to users to have important things in a not related custom
property. Dependency definitions, auth credentials and environment configuration belongs on the provider level for me.
I also looked at the other providers and it feels like there a many differences already. :)
Long story short – it feels like I won't be able to match every needed config in Twilio Runtime to AWS properties and am not sure about the custom
property. 🙈 I'm more than happy to rename keys but for now would prefer to have everything in the provider
(if it's really cool for you?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Friendly ping @pmuens. 😊
As far as I see this is the missing part to move forward with this PR. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @stefanjudis,
sorry for the slow response on my end. This somehow slipped through the cracks, so thanks for pinging me 👍
I agree after reading your comment here. Since this is a provider plugin it's fine to have the important config parts at the provider
level. I furthermore agree that putting things into different places will just cause confusion, so the choices you made here are absolutely right 👌
I'm assuming you're talking about this area? I was not sure if you folks would be up for that, but I'm happy to add docs in another PR. 🎉 |
Yes, exactly 👍
Having such docs would be super valuable! |
Nice! 🎉 Let's tackle docs then right after we have this here shipped. :) 🎉 |
Sounds good! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM
Thanks again for taking the time to work on this @stefanjudis 👍
Just wanted to mention that we have an examples
GitHub project where we share some common example projects with the community. It might be a good idea to add some basic example over there as well since it's quite popular among newcomers.
Eagerly waiting for the docs. Let us know if you need any help from us!
Just another quick question after working with the Twilio Runtime. Does this runtime focus on Node.js? Will it be possible to use other languages as well? I'm asking since our naming schema for Serverless templates usually is Given that it might be worthwhile to rename the template to |
We'll only Node and this is a very valid point. Will push an update in the next 2h and give you another ping. :) Thanks!!! 🎉 |
@pmuens Alright. I just gave it another local try after renaming and everything still works. :) I think we're ready to go. 🎉🎉🎉 I'll add an example to the examples repo after we merged this PR and after the example, I'll have a look at the docs section. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pmuens Alright. I just gave it another local try after renaming and everything still works. :)
I think we're ready to go. 🎉🎉🎉
Great! Thanks for updating this @stefanjudis 👍
I'll add an example to the examples repo after we merged this PR and after the example, I'll have a look at the docs section.
That sounds great! Thanks again for working so hard on this! We really appreciate that! 💯 🥇
What did you implement:
Added a new template to initialize projects using the Twilio Runtime. :)
How did you implement it:
Added a new
serverless.yml
,package.json
, a function and an asset to the pluginscreate
directory.How can we verify it:
export TWILIO_ACCOUNT_SID=YOUR_TWILIO_ACCOUNT_SID
andTWILIO_AUTH_TOKEN=YOUR_TWILIO_AUTH_TOKEN
– you'll find both in the Twilio consolegit clone https://github.com/pinkerton/serverless.git
cd serverless
npm install
cd ..
./serverless/bin/serverless create --template twilio-runtime --path my-project
cd my-project
npm install
serverless deploy
serverless invoke -f hello-world
serverless info
Screenshots
Create
Twilio-runtime
with local binaryRun initial deploy
Invoke deployed functions
Retrieve invormation about the new service
New asset available in Firefox
Todos:
Note: Run
npm run test-ci
to run all validation checks on proposed changesValidate via
npm test
Validate via
npm run lint-updated
Note: Some reported issues can be automatically fixed by running
npm run lint:fix
Validate via
npm run prettier-check-updated
Note: All reported issues can be automatically fixed by running
npm run prettify-updated
Is this ready for review?: YES
Is it a breaking change?: NO