Skip to content

Instantly share code, notes, and snippets.

@leadelngalame1611
leadelngalame1611 / Makefile
Created March 12, 2023 07:46 — forked from mpneuried/Makefile
Simple Makefile to build, run, tag and publish a docker containier to AWS-ECR
# import config.
# You can change the default config with `make cnf="config_special.env" build`
cnf ?= config.env
include $(cnf)
export $(shell sed 's/=.*//' $(cnf))
# import deploy config
# You can change the default deploy config with `make cnf="deploy_special.env" release`
dpl ?= deploy.env
include $(dpl)
@leadelngalame1611
leadelngalame1611 / verify_sig
Created February 25, 2023 23:53
verify sig before downlaoding the aws command line tool
#!/usr/bin/env bash
set -Eeo pipefail
function check_sig() {
gpg --import ./ci/synced/aws-cli/aws_pub_key.txt \
&& curl -o awscliv2.sig https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip.sig \
&& gpg --verify awscliv2.sig awscliv2.zip \
&& echo "GOOD" || echo "BAD"
}
@leadelngalame1611
leadelngalame1611 / kubectl-command.sh
Last active February 8, 2023 12:35
kubectl_commands
## Delete a namespace that get stuck
> NS=`kubectl get ns |grep Terminating | awk 'NR==1 {print $1}'` && kubectl get namespace "$NS" -o json | tr -d "\n" | sed "s/\"finalizers\": \[[^]]\+\]/\"finalizers\": []/" | kubectl replace --raw /api/v1/namespaces/$NS/finalize -f -
## Delete a Pod that get stock
# Create the namespace if not exist
> kubectl create namespace <namespace_name>
@leadelngalame1611
leadelngalame1611 / account_factory.py
Created November 21, 2022 15:03
Account Factory
####
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this
# software and associated documentation files (the "Software"), to deal in the Software
# without restriction, including without limitation the rights to use, copy, modify,
# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so.
#
@leadelngalame1611
leadelngalame1611 / modify_role.sh
Created September 8, 2022 07:01
MOdify role in kubernetes
ROLE_ARN="arn:aws:iam::XXXXXXXXXXXX:role/developer
USERNAME="developer"
ROLE=" - rolearn: ${ROLE_ARN}\n username: ${USERNAME}\n groups:\n - system:masters"
kubectl get -n kube-system configmap/aws-auth -o yaml | awk "/mapRoles: \|/{print;print \"$ROLE\";next}1" > /tmp/aws-auth-patch.yml
kubectl patch configmap/aws-auth -n kube-system --patch "$(cat /tmp/aws-auth-patch.yml)"
def assume_lookup_role(zone, account_id):
DNS_DELEGATION_READONLY_ROLE = (
f"arn:aws:iam::{account_id}:role/dns-delegation-readonly-role"
)
sts = boto3.client("sts")
credentials = sts.assume_role(
RoleArn=DNS_DELEGATION_READONLY_ROLE,
RoleSessionName=f"DnsDelegationLookup-{zone}",
)["Credentials"]
@leadelngalame1611
leadelngalame1611 / python-csv-s3.py
Created March 29, 2022 07:35
create data from csv file uploaded to s3 and load to dynamodb
#!/usr/bin/python3
import os
import boto3
import csv
from datetime import datetime, timezone
s3_resource = boto3.resource('s3')

Initialising an sns client

import boto3

AWS_REGION = "us-east-1"

sns_client = boto3.client("sns", region_name=AWS_REGION)

Initialising an sns Resource

@leadelngalame1611
leadelngalame1611 / ternary.js
Last active March 13, 2022 04:50
Ternary Operators
# The ternary operator is a for of syntatic sugar for an inline if/else
#Javascript:
const color = "blue"
console.log(color === "blue" ? "Show blue" : "Show red")
//output: Show blue
#Python
color = "blue"
@leadelngalame1611
leadelngalame1611 / postman_token.sh
Last active March 6, 2022 05:47
[POSTMAN] Copy Token to environment variable
## This should be placed inside the test section in your postman
# It will provide the Token retrieved as Environment variable
var jsonData = pm.response.json();
token = jsonData.access_token
console.log(token)
pm.environment.set("TOKEN", token);