Skip to content

Instantly share code, notes, and snippets.

View alichherawalla's full-sized avatar

Mohammed Ali Chherawalla alichherawalla

View GitHub Profile
@alichherawalla
alichherawalla / s3_list_and_delete.sh
Created August 16, 2023 10:08
Bash script to list, empty and delete s3 buckets
#!/bin/bash
# List all buckets
buckets=$(aws s3api list-buckets --query 'Buckets[].Name' --output text)
for bucket in $buckets; do
echo "Processing bucket: $bucket"
# Prompt user for action
read -p "Do you want to empty and delete the bucket $bucket? (y/n): " response
@alichherawalla
alichherawalla / cd.yml
Created August 14, 2023 20:33
This is the updated cd file
name: build-and-deploy
# Controls when the action will run. Triggers the workflow on push
# but only for the master branch.
on:
push:
branches:
- main
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
@alichherawalla
alichherawalla / build-lib.sh
Last active September 6, 2023 11:33
This script will create a distributable python library
#!/bin/bash
python3 -m pip install wheel
python3 setup.py bdist_wheel
export "BUCKET_NAME=$(yq e '.bucket_name' config/properties.yml)"
for JOB_DIR in ./src/jobs/job*; do
JOB_NAME_RAW=$(basename $JOB_DIR)
JOB_NAME="$(tr '[:lower:]' '[:upper:]' <<< ${JOB_NAME_RAW:0:1})${JOB_NAME_RAW:1}" # Capitalizing the first letter
YAML_PATH=".Resources.Glue${JOB_NAME}.Properties.DefaultArguments"
@alichherawalla
alichherawalla / env.py
Last active August 14, 2023 21:43
Reusable env related functions
import os
import sys
from awsglue.utils import getResolvedOptions
def load_env(environment):
if environment == "local":
from dotenv import load_dotenv
load_dotenv(".env")
def get_env_or_args(env_name):
@alichherawalla
alichherawalla / setup.py
Created August 14, 2023 13:44
This setup script allows you to build your own distributable library
from setuptools import setup
setup(
packages=["utils"],
name="utilities",
version="0.1",
install_requires=[]
)
@alichherawalla
alichherawalla / task-definition-svc-gateway.json
Created March 23, 2023 15:54
task-definition-svc-gateway
{
"containerDefinitions": [
{
"name": "service-gateway",
"image": "840364872350.dkr.ecr.ap-southeast-1.amazonaws.com/aws-appmesh-envoy:v1.25.1.0-prod",
"cpu": 0,
"portMappings": [
{
"name": "service-gateway-9080-tcp",
"containerPort": 9080,
@alichherawalla
alichherawalla / task-definition-svc2.json
Last active March 23, 2023 15:46
task-definition-svc2
{
"ipcMode": null,
"executionRoleArn": "arn:aws:iam::<AWS_ACCOUNT_ID>:role/ecsTaskExecutionRole",
"containerDefinitions": [
{
"dnsSearchDomains": null,
"environmentFiles": null,
"logConfiguration": {
"logDriver": "awslogs",
"secretOptions": null,
@alichherawalla
alichherawalla / task-definition-svc1.json
Last active March 23, 2023 15:46
sample-app-mesh-svc1-task-definition
{
"ipcMode": null,
"executionRoleArn": "arn:aws:iam::<AWS_ACCOUNT_ID>:role/ecsTaskExecutionRole",
"containerDefinitions": [
{
"dnsSearchDomains": null,
"environmentFiles": null,
"logConfiguration": {
"logDriver": "awslogs",
"secretOptions": null,