Skip to content

Instantly share code, notes, and snippets.

View heitorlessa's full-sized avatar

Heitor Lessa heitorlessa

View GitHub Profile
@heitorlessa
heitorlessa / READE.md
Last active July 3, 2022 23:59
powertools_issue_409

Export custom flag PT_409 when running locally to log in plain text and write output into log.txt file

PT_409="1" python prod.py 

Output should look like this:

2021-05-13 19:05:25,506+0200 — INFO — main:32 — Hello - {'context': {'device_id': '11e9034354f', 'device_location': 'London'}} - - 
@heitorlessa
heitorlessa / pattern.json
Created August 26, 2020 12:26
Catch-all rule for Event Bridge
{
"source": [
{
"exists": true
}
]
}
@heitorlessa
heitorlessa / decorator_factory.py
Last active July 1, 2023 06:07
Decorator factory
import functools
from typing import Callable, Dict, Any
# def lambda_handler_decorator(decorator: Callable):
# """Decorator factory for decorating Lambda handlers."""
# @functools.wraps(decorator)
# def final_decorator(func: Callable = None, **kwargs):
# if func is None:
# return functools.partial(final_decorator, **kwargs)
@heitorlessa
heitorlessa / __init__.py
Last active April 7, 2020 16:35
Draft - Metrics EMF
"""CloudWatch Embedded Metric Format utility
"""
from lambda_python_powertools.helper.models import MetricUnit
from .exceptions import (
MetricUnitError,
MetricValueError,
SchemaValidationError,
UniqueNamespaceError,
)
@heitorlessa
heitorlessa / Makefile
Last active April 3, 2020 15:38
L@E - Aggregate Logs from all regions
## Lambda-Edge centralize log stacks
STACKSET_REGIONS = eu-west-2 eu-central-1 ap-south-1 ap-northeast-2 ap-northeast-1 ap-southeast-1 ap-southeast-2 sa-east-1 us-east-1 us-east-2 us-west-2
centralize-auth-logs:
$(info [+] Deploying Log centralization for Lambda@Edge - Log aggregation across regions)
export STACK_SET=$(shell aws cloudformation list-stack-sets --query 'Summaries[?Status==`ACTIVE` && StackSetName==`lambda-edge-log-groups-stackset`].StackSetName' --output text)
echo $(STACK_SET)
# If CloudFormation Stackset already exists, execute new version only
@heitorlessa
heitorlessa / template.yaml
Created February 26, 2020 11:05
Amplify-Console-Simon-AWS-Blog
AWSTemplateFormatVersion: 2010-09-09
Parameters:
Repository:
Type: String
Description: GitHub Repository URL
OauthToken:
Type: String
Description: GitHub Repository URL
@heitorlessa
heitorlessa / appsync_axios.js
Created August 9, 2019 12:58
axios_appsync_snippet
const user = {
credentials: rootState.profile.user.signInUserSession.accessToken.jwtToken,
id: rootState.profile.user.attributes.sub
}
const fetchLoyaltyQuery = `query getLoyalty_status($cust_id: ID!) {
getLoyalty_status(cust_id: $cust_id) {
cust_id
points
tier
@heitorlessa
heitorlessa / README.md
Last active April 25, 2023 09:01
Webpack+SAM+Typescript example

Thread: https://twitter.com/heitor_lessa/status/1137361365818060800

  • Local prototyping with hot-reloading and step through debugging: npm run watch
  • Bundle, minify and valid structure for SAM package/deploy: npm run build

TL;DR

  • Webpack is instructed to dynamically look up for index.ts within src folder -- (src/function1/index.ts, src/function2/index.ts)
  • Webpack builds a bundle per function to build/function1/index.js, build/function2/index.js...
  • SAM CodeUri is set to the build folder build/function1
@heitorlessa
heitorlessa / App.vue
Last active March 24, 2023 14:33
AWS Amplify JS with Quasar Framework
<template>
<div id="app">
<router-view/>
</div>
</template>
<style>
</style>
<script>