AWS isn't the cheapest Cloud anymore. Or is it?

Published on

Hey there,
It’s Shivam here.

It’s been four weeks since the first LearnAWS Weekly Newsletter. Actually, five.
I missed an edition in between.

Don’t pull a shocked gorilla face, it happens to the best of newscasters!
I’ll make it up to you with some exciting AWS news and ghastly guides.

AWS sign in is getting a new look meme.jpg
This week, let’s not rest. Let’s overthink as developers shouldn’t, and stay up thinking about these topics:

Is Cognito your new Firebase alternative?

Are you a developer who has always used Google Firebase for your auth needs?
Well, Amazon Cognito is going to blow your mind with its possibilities.

Cognito provides a customisable, hosted user interface so that your product gets to market faster, and then to your users.

Tired of users blowing up your emails, saying they can’t register?

In Cognito, you get to choose a custom self-registration solution.

cognito-user-authentication-flow.png
Users can sign-up using an email, phone number, or username for your application. Leave handling the backend (user data validation) to AWS. I’m serious.

Yeah, fine. But can Amazon Cognito seriously dethrone Firebase?

Yes and yes.

Cognito is a strong alternative to Firebase, especially when combined with other AWS services.

Cognito is the industry choice — specially when it comes to user authentication and authorization.

And when coupled with its fellow AWS service brothers and sisters, it’s near to invincible.

Not to brag, but here are all the duties Amazon Cognito can do better than Google Firebase:

  • User sign-up, sign-in, multi-factor authentication (MFA), and account recovery
  • Social identity providers (Google, Facebook, etc.) and enterprise identity providers (SAML 2.0)
  • Integrates well with other AWS services like API Gateway, Lambda, and DynamoDB
  • High scalability and reliability for handling large volumes of users and requests
  • Developers can create custom authentication flows using AWS Lambda triggers
  • Compliance and Security (HIPAA + GDPR)

Are you an AWS developer who’s still using Firebase for things you didn’t know Cognito could do for you?
It’s time you make the jump switch.

No more VTL - use AppSync for GraphQL with JS resolvers

Gone are the days when you had to learn an entirely alien language to meet your development needs, and unwillingly call yourself a polyglot.

If you are not aware, I’m talking about VTL resolver mapping templates in AWS AppSync, for mapping requests and responses.

If GraphQL already wasn’t hard enough, you’d need to baptise yourself with the new language called Apache Velocity, which used to be the only way you could get an AppSync resolver ready.

You ask me:

Where would I even need this resolver mapping template?

  • Amazon DynamoDB
  • AWS Lambda
  • Amazon OpenSearch
  • Amazon API Gateway
  • RDS (Amazon Aurora)
  • Pipeline
  • Delta Sync (it’s okay if you don’t know this AWS service exists, me neither)

Ask me where you wouldn’t need this!

Not anymore, thankfully. AWS heard your cry.

Now we can use the existing JavaScript knowledge we have to write our GraphQL resolvers (phew).

Now we’ll not feel like an imposter every time our resolver would not resolve, throw a 403 Access Denied.

Make us want to pull out our hairs in frustration turn on CloudWatch logs in hoping. That too with a decadent flavour of TypeScript.

AppSync GraphQL resolvers: Before JavaScript (VTL)

GraphQL mutation schema:

type Mutation {
  updatePost(
    id: ID!
    author: String!
    title: String!
    content: String!
    url: String!
  ): Post
  addPost(
    author: String!
    title: String!
    content: String!
    url: String!
  ): Post!
}

Request mapping template for updating an item in DynamoDB:

{
    "version" : "2017-02-28",
    "operation" : "UpdateItem",
    "key" : {
        "id" : $util.dynamodb.toDynamoDBJson($context.arguments.id)
    },
    "update" : {
        "expression" : "SET author = :author, title = :title, content = :content, #url = :url ADD version :one",
        "expressionNames": {
            "#url" : "url"
        },
        "expressionValues": {
            ":author" : $util.dynamodb.toDynamoDBJson($context.arguments.author),
            ":title" : $util.dynamodb.toDynamoDBJson($context.arguments.title),
            ":content" : $util.dynamodb.toDynamoDBJson($context.arguments.content),
            ":url" : $util.dynamodb.toDynamoDBJson($context.arguments.url),
            ":one" : { "N": 1 }
        }
    }
}

Response mapping template for updating an item in DynamoDB:

$utils.toJson($context.result);

AppSync GraphQL resolvers: After JavaScript

Request and response mapping template for updating an item in DynamoDB (combined in a JS file):

import { util } from "@aws-appsync/utils";
import * as ddb from "@aws-appsync/utils/dynamodb";

export function request(ctx) {
  const { id, expectedVersion, ...rest } = ctx.args;
  const values = Object.entries(rest).reduce((obj, [key, value]) => {
    obj[key] = value ?? ddb.operations.remove();
    return obj;
  }, {});

  return ddb.update({
    key: { id },
    condition: { version: { eq: expectedVersion } },
    update: { ...values, version: ddb.operations.increment(1) },
  });
}

export function response(ctx) {
  const { error, result } = ctx;
  if (error) {
    util.appendError(error.message, error.type);
  }
  return result;
}

Tell me the difference isn’t striking.

How to deploy NextJS to EC2? So easy - your Grandma can do it.

nextjs-deployment-on-ec2.webp

Learn how to deploy NextJS on EC2 from LearnAWS blog

The cheapest VPS provider is not AWS, but a German cloud provider. You won’t believe their prices.

I hate to break it to you, but AWS is not the cheapest cloud provider in the world anymore.

As of June 2024, I’ve found Hetzner to be the cheapest cloud provider, specially when it comes to their shared vCPUs.

If you want an ARM64 processor with your system configuration having 2 vCPUs, 4 GB RAM, a disk space of 40 GB and a traffic bandwidth limit of 20 TB.

However, like any other fisherman would say, there is a catch:

  • You will not get your AWS features like Load Balancer, IAM here.
  • Nor will you get the vast array of locations that AWS provides you services in.

Hetzner has datacenters just in:

  • Nuremberg (Germany)
  • Falkenstein (Germany)
  • Helsinki (Finland)
  • Ashburn (USA)
  • Hillsboro (USA)

For most of you, this might be a goldmine.
If you’re okay with these peeves, give this new boy a shot.

hetzner-cloud-hosting-pricing-for-arm-cpu.png

ARM for the win.

Amazon Cloudfront gets its new CLI

CloudFront Hosting Toolkit offers the convenience of a managed frontend
hosting service while retaining full control over the hosting and
deployment infrastructure to make it your own.

Why did Cloudfront even need a new CLI?

Weren’t AWS developers using the GUI just fine - caching requests, using functions at edge for speed, and restricting access with signed URLs and policies? No.

cloudfront-toolkit-arch-diagram.jpg
There’s only so much you could do in Amplify, lest having granular control over your config.

It’s like an Amplify alternative.
In the Cloudfront hosting toolkit, you can individually choose the configuration you want to have for your system.

It’s Meme Time! Just kidding, we’ll just be bullying AWS CDK.

Last week, there was no newsletter.
This week, I would like to apologise with a meme that’ll definitely hit home for thousands of AWS developers.

If you are an AWS Solutions Architect and claim to correctly understand this meme: you’re not a solutions architect — you’re a muggle.

Let’s see AWS CDK for what it really is.

grus-plan-cdk-to-cloudfromation-to-api.png

Your AWS infrastructure is just CDK. Your CDK code is just Cloudformation. Your Cloudformation is just YAML / JSON. And that YAML / JSON just calls AWS APIs.

Funny, ain’t it?

That’s it for this newsletter.
It took me 6 hours to write, and would take you just 5 seconds to reply.


Hills 🏔 and Skills, What's Common?

They both need you to be on top.

You will get lifetime access with:

All yours, just at:

$149

Just type and your search result will magically appear here