Skip to content

Instantly share code, notes, and snippets.

@lcasartelli
lcasartelli / aws-eks-kubeconfig-generator.py
Created August 26, 2021 15:15
Generate a valid kubeconfig file for EKS cluster
import json
import boto3
from datetime import datetime, timedelta
from botocore import session
from awscli.customizations.eks.get_token import STSClientFactory, TokenGenerator, TOKEN_EXPIRATION_MINS
def _get_expiration_time():
t_exp = datetime.utcnow() + timedelta(minutes=TOKEN_EXPIRATION_MINS)
return t_exp.strftime('%Y-%m-%dT%H:%M:%SZ')
@lcasartelli
lcasartelli / deny-not-us-regions.json
Created May 3, 2021 07:36
Deny regions outside US
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Resource": "*",
"Condition": {
"StringNotEquals": {
"aws:RequestedRegion": [
"us-east-1",
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Deny",
"Action": ["iam:*"],
"Resource": "*",
"Condition": {
"ArnNotEquals": {
"aws:PrincipalARN": "arn:aws:iam::*:role/Admin*"
}
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Deny",
"Action": ["iam:*"],
"Resource": "*",
"Condition": {
"ArnEquals": {
"aws:PrincipalARN": "arn:aws:iam::*:user/guest"
}
@lcasartelli
lcasartelli / deny-all-ec2.json
Created May 3, 2021 07:30
Deny All EC2 actions
{
"Statement": [{
"Effect": "Deny",
"Action": "ec2:*",
"Resource": "*"
}]
}
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}
]
}

Keybase proof

I hereby claim:

  • I am lcasartelli on github.
  • I am lcasartelli (https://keybase.io/lcasartelli) on keybase.
  • I have a public key ASDFESuwkhCHUJV6TkrX0qJbtxkY5yy1j_7UKh0dNH7pvwo

To claim this, I am signing this object:

# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@lcasartelli
lcasartelli / emotion-api-lambda.js
Created April 14, 2016 17:46
Lambda code for simple demo with Microsoft Emotion API
const request = require('request');
const POX_EMOTION_API_KEY = '6aad043727374c6d9d7d010eb82f1275'
const exampleImage = 'https://thoughtcatalog.files.wordpress.com/2014/07/harry-potter-and-the-deathly-hallows-trailer-hits-the-web-video-6f199ae35b.jpg';
const handler = exports.handler = (event, context, callback) => {
request({
method: 'POST',
body: JSON.stringify({ "url": exampleImage }),
headers: {
@lcasartelli
lcasartelli / .aliases
Created May 14, 2015 15:02
Shell aliases (require tig)
alias g="git"
alias ga="git add"
alias gaa="git add -A ."
alias gb="git branch"
alias gc="git commit"
alias gcam="tig status; git commit --amend"
alias gce="git commit --allow-empty"
alias gcl="git clone"
alias gcm="git commit -m"
alias gco="git checkout"