AWS AppSync added new $utils to VTL.

Let's look at the new and existing AppSync $utils with 9 code examples!

A thread 🧵👇
VTL, the Velocity Template Language, is used to build JSONs for AppSync Resolvers. VTL allows putting logic in the Resolvers' behavior.

$util provides a set of functions with rich capabilities to enhance this logic without utilizing additional Lambda functions.
Btw, VTL is not the easiest or most developer-friendly language.

But this RFC gives us hope for the JavaScript-based Resolvers in the future:
github.com/aws/aws-appsyn…
Now, to the point - $util functions in AppSync VTL 👇
1️⃣ Debug logs - newly added (finally!)

AppSync writes logs to the CloudWatch depending on the log level set:
- ERROR: error logs only
- ALL: info and error logs
2️⃣ Generating IDs

$util.autoKsuid() is newly added, K-Sortable Unique IDentifier generator.

ULID and KSUID generate unique but sortable (by creation time) identifiers!

More about KSUID: github.com/segmentio/ksuid
3️⃣ Working with JSON

Serializing and deserializing objects to/from JSON is common with any Data Sources AppSync connects to.
4️⃣ Suppressing functions output

In VTL, Lists and Maps are Java objects.
You can use Java API to work with them.

Many Map and List methods return values that you don't want to include in the template output. Therefore, you need to discard or "suppress" them.
5️⃣ Throwing error
6️⃣ Validating data

$util.validate() function will throw an error if the condition is not fulfilled. No #if blocks are needed.
7️⃣ Default value fallback

Perfect for handling optional query arguments.
8️⃣ String conversions

Only the basics are available - uppercase, lowercase, and find and replace.

Btw, I understand that "toReplace" name was supposed to match "toUpper" and "toLower"...
9️⃣ Generating timestamps

Please use ISO 8601 wherever you can...
That's not all!

There are also helpers for working with Lists, Maps, DynamoDB, RDS, HTTP, and XML.

But this thread is long enough, so maybe next time? 😉
If you found it useful:

1. Follow me @radzikowski_m for more like this
2. Please ❤️ and 🔁 the 1st tweet above to share

Thank you!

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Maciej Radzikowski

Maciej Radzikowski Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @radzikowski_m

Apr 12
A handy Decision Tree for choosing the right messaging service on AWS.

As per my calculations, following it gives you a 90% chance of making the right choice.

Read more in the thread 🧵👇 Image
I did a summary and comparison of SQS, SNS, EventBridge, and Kinesis in a thread a while ago.
Now, this Decision Tree is an extension of it, helping make the decision.

But there is still this 10% chance it won't help you!
Read 5 tweets
Feb 9
AWS Step Functions overview

A thread 🧵👇
(with images!)
1️⃣ What is AWS Step Functions?

Serverless, low-code service to build and visualize workflows orchestration.
But what does it mean?

- serverless - you pay only for the number of step transitions executed
- low-code - defined in JSON/YAML or visual builder
- workflows - multi-step processes
- orchestration - centralized coordination across multiple services
Read 19 tweets
Jan 13
This week I passed the AWS DevOps Professional exam 🎉

Here is a little guide - scope, what to pay attention to, and how I prepared for it in less than 2 weeks.

A thread 🧵👇
📖 Learning

While I generally don't like video courses, I did not find any better way for preparing for the exams. They provide condensed knowledge on the exam scope.

My choice: @StephaneMaarek course on Udemy.
Don't just watch. Make notes ✍️

I use the (simplified) Zettelkasten method. Google it and get back.

During the course, I make all notes in a single document, as a nested list.

Important: use your own words to make notes meaningful to you. My AWS Certified DevOps Engineer Professional course notes.
Read 22 tweets
May 18, 2021
AWS messaging solutions - where to use which one 🤔

SQS vs SNS vs Kinesis vs EventBridge

A thread 🧵 👇
A common goal for all messaging solutions is to decouple the Producer and the Consumer.

The Producer does not know about the Consumer(s), and vice versa.

But depending on the use case, we have to choose an appropriate solution.
SQS: Simple Queue Service

- consumer pulls messages
- message is consumed only once, by a single consumer, and then removed
- no need to provision throughput
- price per number of messages
Read 12 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(