I decided that was going to change.
First things first, I have been using AWS for 3+ years and with the exception of a couple of POCs for Hackathons or a fork of a random repo, I’ve never really had a need to use AWS Serverless Application Model (SAM). Personally, I am a bigger fan of the Serverless Framework. But it turns out you can’t publish to the SAR without using SAM, so it looks like I need to learn a thing or two before contributing…
I got caught up on a couple of things by not using the second tutorial and all my reasons for not using it were due to me just wanting to hack this together as fast as possible…jokes on me.
The first reason I didn’t use the second tutorial was that I noticed the console UI for publishing provided license files, but if I used the CLI, I needed to have one locally. Well that didn’t work out so great for me anyways because it turns out I didn’t add my name or copyright year to the template and had to pull my app down and republish after I realized my mistake.
The second reason was that I didn’t want to create another directory and create a new SAM template to deploy the app, I thought one SAM project was enough for the day.
One of the first issues I ran into was building SAM locally. I needed to provide the input variables that a user would provide from SAR. Google was my friend here, I just needed the
sam build --parameter-overrides 'BucketNameParameter=backupbucket, TableNameParameter=table-to-backup'
Next was that when I built with SAM, the S3 bucket for the source code was relative to my project. I needed to overwrite the SAM injected value with the path to an uploaded artifact in S3 after ever build.
Also, I had to zip up
app.js after running
sam build and put it in a public S3 bucket so others could consume it. This means that every time I made a code change, I needed to run
sam build , compress the artifact it generates, upload it to S3, and change the S3 path in the generated template.yaml. Absolutely a place to introduce some CI/CD…but not today…
The best mistake I made when learning about SAM was if you’re trying to learn about IAM integrations with SAM, do not Google
SAM IAM unless you want to enter a Dr. Seuss rabbit hole…
Once I got over those few hurdles, I was able to get my app published and deployed. All and all it took less than 2 hours and was a great learning experience.
Have you published to the Serverless Application Repo? And if not, what’s stopping you?
Check out my app and let me know your thoughts!
Thanks for reading!