Skip to content

Instantly share code, notes, and snippets.

@michaelbrewer
michaelbrewer / Makefile
Last active April 3, 2021 20:16
aws-lambda powertools cdk
# cdk/Makefile
dev:
# Installs peotry and the dependencies
pip install --upgrade pip poetry
poetry install
@michaelbrewer
michaelbrewer / app-validator.py
Created April 13, 2021 00:40
08 - Validator
import json
import os
import time
from typing import Any, Callable, Dict
from aws_lambda_powertools import Logger, Metrics, Tracer
from aws_lambda_powertools.logging import correlation_paths
from aws_lambda_powertools.metrics import MetricUnit
from aws_lambda_powertools.middleware_factory import lambda_handler_decorator
from aws_lambda_powertools.utilities.data_classes import APIGatewayProxyEvent
@michaelbrewer
michaelbrewer / app.py
Created April 13, 2021 01:05
app - modular
import os
from typing import Any, Callable, Dict
from aws_lambda_powertools import Logger, Metrics, Tracer
from aws_lambda_powertools.logging import correlation_paths
from aws_lambda_powertools.middleware_factory import lambda_handler_decorator
from aws_lambda_powertools.utilities.data_classes import APIGatewayProxyEvent
from aws_lambda_powertools.utilities.idempotency import DynamoDBPersistenceLayer, IdempotencyConfig, idempotent
from aws_lambda_powertools.utilities.idempotency.exceptions import (
IdempotencyAlreadyInProgressError,
@michaelbrewer
michaelbrewer / app-parameter.py
Created April 13, 2021 05:59
09 - Parmaters
import os
from aws_lambda_powertools.utilities.parameters import get_parameter
credentials = get_parameter(f"payment_credentials_{os.environ['ENVIRONMENT']}", transform="json", decrypt=True)
assert isinstance(credentials, dict)
payment_client = PaymentService(**credentials)
...