Skip to content

Instantly share code, notes, and snippets.

View drAlberT's full-sized avatar

Emiliano 'AlberT' Gabrielli drAlberT

View GitHub Profile
@v-rosa
v-rosa / gist:aa9c8afd44d66c3a81b9920a1bc90e42
Last active September 19, 2024 19:33
Use private GitHub hosted terraform modules with AFT v1.5.1

I'll try to share my approach to use private GitHub hosted terraform modules with AFT v1.5.1. It relies on GH App to create ephemeral tokens during Global Customization stage which will share with the target account so it can be used during Account Customization stage.

Relates to: aws-ia/terraform-aws-control_tower_account_factory#42

Pre-requirements:

  • Create a GH APP:
    • Permissions: allow the clone of repositories
    • Set to a restricted list of terraform modules repos
  • Create parameter store entries for GH_APP pem, id and installation_id under AFT_MGT account
@drAlberT
drAlberT / AWS-IAM-enforce-mfa.policy.json
Created September 7, 2018 14:44
AWS IAM :: Enforce MFA both on Console and CLI
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAllUsersToListAccountAliases",
"Effect": "Allow",
"Action": [
"iam:ListAccountAliases"
],
"Resource": [
@drAlberT
drAlberT / update-docker-compose.sh
Last active September 25, 2020 15:15
Bash script to update docker-compose to the latest release
#!/bin/bash
#
# Updates docker-compose to the latest release
#
# Author: Emiliano Gabrielli <albert@faktiva.com>
DESTINATION_FILE="${DESTINATION_FILE:-$(command -v docker-compose)}"
set -e -o pipefail
@drAlberT
drAlberT / group-by-ip.sql
Created August 17, 2017 10:36 — forked from bennadel/group-by-ip.sql
Grouping The MySQL PROCESSLIST By IP Address To View Connection Counts
SELECT
tmp.ipAddress,
-- Calculate how many connections are being held by this IP address.
COUNT( * ) AS ipAddressCount,
-- For each connection, the TIME column represent how many SECONDS it has been in
-- its current state. Running some aggregates will give us a fuzzy picture of what
-- the connections from this IP address is doing.
FLOOR( AVG( tmp.time ) ) AS timeAVG,
@regilero
regilero / nginx.conf
Last active February 26, 2021 12:22 — forked from thoop/nginx.conf
Altered prerender.io nginx.conf for nginx
# Change YOUR_TOKEN to your prerender token and uncomment that line if you want to cache urls and view crawl stats
# Change example.com (server_name) to your website url
# Change /path/to/your/root to the correct value
# Generate $prerender_ua bool value based on user agent
# indexation bots will get this as 1,
# prerender user agent will always get 0 (avoid loops)
map $http_user_agent $prerender_ua {
default 0;
@rdohms
rdohms / links.md
Last active May 26, 2017 17:32
Object Calisthenics Resources
@geerlingguy
geerlingguy / ansible-role-test.sh
Last active December 14, 2024 17:13
Ansible Role Test Shim Script
#!/bin/bash
#
# Ansible role test shim.
#
# Usage: [OPTIONS] ./tests/test.sh
# - distro: a supported Docker distro version (default = "centos7")
# - playbook: a playbook in the tests directory (default = "test.yml")
# - role_dir: the directory where the role exists (default = $PWD)
# - cleanup: whether to remove the Docker container (default = true)
# - container_id: the --name to set for the container (default = timestamp)
@benkehoe
benkehoe / LambdaBase.py
Last active October 23, 2023 20:30
Code pattern for implementing class-based AWS Lambda handlers in Python
"""Base class for implementing Lambda handlers as classes.
Used across multiple Lambda functions (included in each zip file).
Add additional features here common to all your Lambdas, like logging."""
class LambdaBase(object):
@classmethod
def get_handler(cls, *args, **kwargs):
def handler(event, context):
return cls(*args, **kwargs).handle(event, context)
return handler
@drAlberT
drAlberT / CS_git-commands-reference.md
Last active December 16, 2017 15:55
Git / GitHub CheatSheet

Git / GitHub CheatSheet

Quick reference for git / GitHub daily workflow

Git

create branches

  • create the local branch
@drAlberT
drAlberT / CS_SSL-certs.md
Last active November 13, 2016 05:39
SSL certificates cheatsheets

SSL certificates CheatSheet

Quick reference for SSL certificate workflow handling for commonly used commercial SSL products

General purpose commands

Generate

  • Generate a new private key