Skip to content

Instantly share code, notes, and snippets.

@naveen-vijay
naveen-vijay / EC2-SG-PublicIP-Fixer
Last active March 16, 2020 08:11
Python Boto Code to update your EC2 instance's Security Group to be in sync with your changing Public IP
# Python Boto Script to Update the EC2 security group to make the instance
# to be open to your public IP although ISP change
# Can be automated in CRON everyday
import boto
import urllib2
def get_public_ip():
ext_ip = urllib2.urlopen("http://curlmyip.com").read()
return ext_ip.strip()
@naveen-vijay
naveen-vijay / aws-lambda-CloudTrail2CloudSearch
Last active July 16, 2020 13:53
AWS Lambda - CloudTrail to CloudSearch Pusher
var AWS = require('aws-sdk');
var zlib = require('zlib');
//Lambda Configurations
var awsParam = {region:"us-east-1"};
AWS.config.sslEnabled = false;
//Declarations
var s3 = new AWS.S3(awsParam);
var bucketName = "bucket-cloud-trail";
@naveen-vijay
naveen-vijay / sg-route53-health-check-tcp.json
Last active August 29, 2015 14:27
CloudFormation Template Create Security Group for the AWS Specified IP Range - TCP Only
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "TCP - Security Group for Route53 Health - TCP checks",
"Parameters" :
{
"VPC" :
{
"Type" : "AWS::EC2::VPC::Id",
"Description" : "VPC where the Security Group will belong"
},
@naveen-vijay
naveen-vijay / sg-route53-health-check-http.json
Created August 13, 2015 11:15
CloudFormation Template to create Security Group for the AWS Specified IP Range - HTTP Only
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "HTTP - Security Group for Route53 Health - http checks",
"Parameters" :
{
"VPC" :
{
"Type" : "AWS::EC2::VPC::Id",
"Description" : "VPC where the Security Group will belong"
},
@naveen-vijay
naveen-vijay / sg-route53-health-check-https.json
Created August 13, 2015 11:17
CloudFormation Template to create Security Group for the AWS Specified IP Range - HTTPS Only
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "HTTPS - Security Group for Route53 Health - https checks",
"Parameters" :
{
"VPC" :
{
"Type" : "AWS::EC2::VPC::Id",
"Description" : "VPC where the Security Group will belong"
},
@naveen-vijay
naveen-vijay / sg-route53-health-check-all.json
Created August 13, 2015 11:34
CloudFormation Template to create Security Group for the AWS Specified IP Range - HTTP, HTTPS, TCP PORT Range
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "TCP - Security Group for Route53 Health - HTTP,HTTPS,TCP checks",
"Parameters" :
{
"VPC" :
{
"Type" : "AWS::EC2::VPC::Id",
"Description" : "VPC where the Security Group will belong"
},
"DelayWaitHandle" : {
"Type" : "AWS::CloudFormation::WaitConditionHandle",
"Properties" : {
}
},
"DelayWaitCondition" : {
"Type" : "AWS::CloudFormation::WaitCondition",
"DependsOn" : "RemoteDesktopServer",
"Properties" : {
"Handle" : { "Ref" : "DelayWaitHandle" },
exports.handler = function(event, context) { //Respond with a SUCCESS Signal regardless of create/update/delete
if (event.RequestType == "Delete") {
sendResponse(event, context, "SUCCESS");
return;
}
setTimeout(function() {
console.log('Slept');
Data = {"val1":"val1"}; // Some Dummy Value to be returned back to the CloudFormation Stack
return sendResponse(event, context, "SUCCESS",Data);
}, 294000); //slightly less than 5 mins - currently hardcoded but be possible accept dynamically
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Lambda Delay",
"Parameters": {
"SubnetAZ": {
"Description": "CIDR for AZ",
"Type": "AWS::EC2::AvailabilityZone::Name",
"Default": "us-east-1d"
}
},
@naveen-vijay
naveen-vijay / template.json
Created October 23, 2016 00:35
CloudFormer in a separate new VPC (non-default)
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "A custom CloudFormer template forked from AWS provided to extend the capability to provide the ability to specify the VPC. Creates a Separate Stand-Alone VPC, Subnet - 10.0.0.0/16 to launch the CloudFormer Instance. AWS CloudFormer Beta - template creation prototype application. This tool allows you to create an AWS CloudFormation template from the AWS resources in your AWS account. **Warning** This template creates a single EC2 instance in your account to run the application - you will be billed for the instance at normal AWS EC2 rates.",
"Parameters" : {
"Username" : {
"Description" : "Username to log in to CloudFormer",
"Type" : "String"