Skip to content

Instantly share code, notes, and snippets.

View EmmanuelTsouris's full-sized avatar

Emmanuel Tsouris EmmanuelTsouris

View GitHub Profile
@jordanfarrer
jordanfarrer / aws-lambda-ami-lookup.js
Created November 11, 2015 06:38
A sample Lambda function that looks up the latest AMI ID for a given region and architecture.
/**
* A sample Lambda function that looks up the latest AMI ID for a given region and architecture.
**/
// Map instance architectures to an AMI name pattern
var archToAMINamePattern = {
"PV64": "amzn-ami-pv*.x86_64-ebs",
"HVM64": "amzn-ami-hvm*.x86_64-gp2",
"HVMG2": "amzn-ami-graphics-hvm-*x86_64-ebs*"
};
@bkozora
bkozora / lambdaAMIBackups.py
Last active October 29, 2024 02:54
AWS Lambda AMI Backups
# Automated AMI Backups
#
# @author Bobby Kozora
#
# This script will search for all instances having a tag with the name "backup"
# and value "Backup" on it. As soon as we have the instances list, we loop
# through each instance
# and create an AMI of it. Also, it will look for a "Retention" tag key which
# will be used as a retention policy number in days. If there is no tag with
# that name, it will use a 7 days default value for each AMI.
@bkozora
bkozora / lambdaAMICleanup.py
Last active October 29, 2024 02:53
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.
@gurunars
gurunars / find_latest_ami_name.py
Last active October 30, 2020 01:41
AWS lambda function to find the latest Amazon AMI
"""
Publish the function to S3:
cd $DIR_WITH_THIS_SCRIPT
zip find_latest_ami_name.zip find_latest_ami_name.py
aws s3 cp find_latest_ami_name.zip s3://$YOUR_S3_BUCKET/find_latest_ami_name.zip
"""
import json
@justinpawela
justinpawela / config
Created August 3, 2016 01:39
AWS CodeCommit Multiple Account Config
# This file is: ~/.ssh/config
# You may have other (non-CodeCommit) SSH credentials stored in this
# config file – in addition to the CodeCommit settings shown below.
# NOTE: Make sure to run [ chmod 600 ~/.ssh/config ] after creating this file!
# Credentials for Account1
Host awscc-account1 # 'awscc-account1' is a name you pick
Hostname git-codecommit.us-east-1.amazonaws.com # This points to CodeCommit in the 'US East' region
@030
030 / lambda-vpc-internet-access-cloudformation.yml
Created June 25, 2019 16:36 — forked from romaninsh/lambda-vpc-internet-access-cloudformation.yml
CloudFormation template implementing Private network which can be used by Serverless to deploy Lambda into VPCs an maintaining internet access
# Add the following to your existing VPC CF stack
# create 2 subnets, lambdas like to be in multiple subnets
Private1:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [ 0, !GetAZs ]
CidrBlock: !Ref Private1CIDR