Skip to content

Instantly share code, notes, and snippets.

View bhalothia's full-sized avatar
🛠️
Building something cool. ;)

Virendra Singh Bhalothia bhalothia

🛠️
Building something cool. ;)
View GitHub Profile
@ivawzh
ivawzh / ALB-template.yaml
Created February 24, 2017 01:38
Stand alone ALB Cloudformation setup. For ECS service to consume.
Resources:
# ============================ Application Load Balancer ============================
LoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Name: !Ref AWS::StackName
Scheme: internet-facing
Subnets: !Split
@nathanmalishev
nathanmalishev / createAndExecuteRoles.yaml
Last active January 25, 2019 17:19
A set of policies, used to create an initial ci user
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- 'cloudformation:CreateChangeSet'
- 'cloudformation:DescribeChangeSet'
- 'cloudformation:ExecuteChangeSet'
- 'cloudformation:DescribeStacks'
Resource:
- 'arn:aws:cloudformation:<region>:<account_no>:stack/<roles_permission_stack_name>/*'
@bknowles
bknowles / README.md
Created October 25, 2011 23:09 — forked from atomic-penguin/README.md
multi-knife-howto

Overview

Here is an example shared configuration for knife. You can drop this off in your chef-repo/.chef/ directory, and multiple developers can use the same knife configuration to interact with more than one Chef server, or the Opscode platform.

By using Bash functions and environment variables we can change the chef server, which knife is configured to use, on the fly.

NOTE: knife will probably ignore your ~/.chef/knife.rb once you begin using a shared knife.rb in your chef-repo directory.

Preparation

@babo
babo / aws_resources.py
Created December 20, 2015 12:50
Skeleton to list all AWS resources by security group.
#!/usr/bin/env python3
import json
import boto3
def main():
all_ec2 = {}
all_rds = {}
all_cache = {}
all_elb = {}
@bwhaley
bwhaley / peer_routes.py
Last active October 6, 2021 17:18
A script to configure routes in in a VPC peering connection
# Quick script to configure routes for a VPC peering connection
# Searches a region for all peering connection and prompts to choose one
# Configures routes between the peered networks for all routing tables
# STS/AssumeRole not implemented cross-account peering. Instead,
# Choose accepter/requestor depending on which credentials are set in the environment
# Enter either IPv4 and IPv6 route destinations
# Example usage:
# ( Assuming boto credentials are configured)
# $ pip install boto3
# $ python3.6 peer_routes.py
@kaievns
kaievns / gist:acb23149b66418ba340c
Created July 29, 2014 00:44
How to populate PostgreSQL with dummy data
CREATE TABLE t_random AS SELECT s, md5(random()::text) FROM generate_Series(1,5) s;
INSERT INTO t_random VALUES (generate_series(1,1000000000), md5(random()::text));
SELECT pg_size_pretty(pg_relation_size('t_random'));
@mlapida
mlapida / EC2-Stopped-Tagged-Lambda.py
Last active January 30, 2023 15:09
Using a lambda function, stop all instances that are tagged appropriately.
import boto3
import logging
#setup simple logging for INFO
logger = logging.getLogger()
logger.setLevel(logging.INFO)
#define the connection
ec2 = boto3.resource('ec2')
@bkozora
bkozora / lambdaAMICleanup.py
Last active March 12, 2023 11:55
AWS Lambda Function to Delete AMIs and Snapshots
# Automated AMI and Snapshot Deletion
#
# @author Bobby Kozora
#
# This script will search for all instances having a tag named "Backup" with a value of "Backup".
# As soon as we have the instances list, we loop through each instance
# and reference the AMIs of that instance. We check that the latest daily backup
# succeeded then we store every image that's reached its DeleteOn tag's date for
# deletion. We then loop through the AMIs, deregister them and remove all the
# snapshots associated with that AMI.
@nmarley
nmarley / dec.py
Last active August 8, 2023 13:55
AWS KMS encryption/decryption using Python/Boto3
import boto3
import base64
if __name__ == '__main__':
session = boto3.session.Session()
kms = session.client('kms')
encrypted_password = 'AQECAHjgTiiE7TYRGp5Irf8jQ3HzlaQaHGYgsUJDaavnHcFm0gAAAGswaQYJKoZIhvcNAQcGoFwwWgIBADBVBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDDwxVQuG0oVwpkU7nQIBEIAoVGk1/wpserb+GVUOzE7PiL/Nr9fTDFKZfpKpF0ip2ct4B2q0Wn6ZZw=='
binary_data = base64.b64decode(encrypted_password)