DEV Community

Yoandy Rodriguez Martinez
Yoandy Rodriguez Martinez

Posted on • Originally published at yorodm.github.io on

2

Trucos Aws Lambda (parte 2)

Trucos con AWS Lambda (II).

Truco 1. Utiliza las tags.

Los tags en AWS nos permiten:

  1. Tener asociados un máximo de 50 a cada recurso.
  2. Llaves de hasta 128 caracteres Unicode.
  3. Valores de hasta 256 caracteres Unicode.
  4. Distinción entre mayúsculas y minúsculas para llaves y valores.

Basicamente todo lo que necesitamos para hacernos un caché:

lambda_cient = boto3.client('lambda')
def save_cache(tags): # tags is a dict of string:string
    lambda_client.tag_resource(
        Resource=self_arn, # get it from handler context
        Tags=json.dumps(tags)
    )

def get_cache():
    return lambda_client.list_tags(
        Resource=self_arn # get it from handler context
    )

def invalidate_cache(keys):
    return lambda_client.untag_resource(
        Resource=self_arn,
        Tags=json.dumps(keys)
    )

Truco 2. Desarrolla tus Lambdas en otros lenguajes.

Los lenguajes soportados oficialmente por AWS Lambda son (en el momento en que escribo este artículo):

  1. Javascript (Node.js).
  2. Python (2 y 3).
  3. Java.
  4. C#.
  5. Go.

¿No está el lenguaje de tu preferencia? Pues no te preocupes, esa lista se puede extender a:

  1. Kotlin, Groovy, Ruby Clojure y todo lo que soporte la JVM.
  2. Cualquier lenguaje soportado por la plataforma .NET, incluido PHP.
  3. Rust sobre lando o crowbar incluso con integración con serverless.
  4. Cualquier cosa que genere WASM

Más trucos

¿Tienes algún otro que compartir? Deja tu comentario aquí o en DEV.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay