Skip to content

Instantly share code, notes, and snippets.

View filipeandre's full-sized avatar

Filipe Ferreira filipeandre

View GitHub Profile
@filipeandre
filipeandre / concurrent_lambda_executions.py
Created July 16, 2025 15:38
Force lambda concurrent executions quota increase
import boto3
import json
import multiprocessing
from botocore.exceptions import ClientError
function_name = "hello-world-quota-limit"
payload = {
"key1": "test-key1",
"key2": "test-key2",
"key3": "test-key3"
@filipeandre
filipeandre / create_temp_aws_credentials.py
Last active August 7, 2025 08:35
Temp AWS credentials
import boto3
import os
def export_temp_credentials():
session = boto3.Session()
credentials = session.get_credentials().get_frozen_credentials()
print(f'os.environ["AWS_ACCESS_KEY_ID"] = "{credentials.access_key}"')
print(f'os.environ["AWS_SECRET_ACCESS_KEY"] = "{credentials.secret_key}"')
@filipeandre
filipeandre / admin_iam_external.py
Created June 25, 2025 01:09
Python script to automate the external AWS account setup for IAM Identity Center SAML federation, granting AdministratorAcces
import boto3
import json
# --- CONFIGURATION ---
SAML_PROVIDER_NAME = "IAMIdentityCenterProvider" # must already exist
ROLE_NAME = "SAMLAdminAccessRole"
POLICY_NAME = "SAMLAdministratorAccessPolicy"
POLICY_DESCRIPTION = "Full admin access for SAML federated users"
USE_MANAGED_ADMIN_POLICY = True # set False to use a custom inline policy
@filipeandre
filipeandre / clone_deleted_stack.sh
Last active June 19, 2025 00:47
Clone delete stack
#!/bin/bash
# Usage:
# ./clone_deleted_stack.sh <stack-id-or-name> [new-stack-name] [optional-role-arn]
set -euo pipefail
INPUT_ID="${1:-}"
NEW_STACK_NAME="${2:-}"
ROLE_ARN="${3:-}"
@filipeandre
filipeandre / extract_excel_info.py
Last active May 15, 2025 22:20
Excel Table Data Extractor
import boto3
import tempfile
import os
import sys
from urllib.parse import urlparse
import openpyxl
def parse_s3_uri(s3_uri):
parsed = urlparse(s3_uri)
bucket = parsed.netloc
@filipeandre
filipeandre / test1.yaml
Last active May 2, 2025 19:54
Test substitution logic for IP construction with dummy resource (sub, select, ssm)
AWSTemplateFormatVersion: '2010-09-09'
Description: Test substitution logic for IP construction with dummy resource.
Resources:
DummyResource:
Type: AWS::CloudFormation::WaitConditionHandle
Outputs:
FabricComponentsStaticIP:
Value: !Sub
@filipeandre
filipeandre / detete-redis-cache.js
Last active May 15, 2025 09:04
Helper script to delete redis cache
const redis = require('redis');
const readline = require('readline');
async function connectRedis(host, port, db, password) {
const client = redis.createClient({
socket: { host, port },
database: db,
password
});
await client.connect();
@filipeandre
filipeandre / extract_data_frame_paddleocr.py
Created April 21, 2025 14:52
PaddleOCR aims to create multilingual, awesome, leading, and practical OCR tools that help users train better models and apply them into practice.
# define functions to run the ocr,
# annotate the images with the bounding boxes
# consolidate the results to a dataframe
# and iterate over a folder of images
from PIL import Image, ImageDraw
import pandas as pd
from paddleocr import PaddleOCR
import os
import traceback
@filipeandre
filipeandre / verify_latency.sh
Created March 26, 2025 16:20
Inside ECS, this allow to verify the latency to the AIM endpoint
while true; do
curl -o /dev/null -s -w "%{http_code}, %{time_total}s\n" \
http://169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
sleep 5
done
@filipeandre
filipeandre / install_pgbadger.sh
Created March 17, 2025 17:19
Install pgbadger on Amazon Linux 2023
#!/bin/bash
echo "Updating package lists..."
dnf update -y
echo "Installing required dependencies..."
dnf install -y perl perl-core perl-FindBin perl-Time-HiRes perl-JSON \
perl-Digest-MD5 perl-Text-CSV perl-LWP-Protocol-https \
perl-DBI perl-DBD-Pg tar gzip make