Skip to content

Instantly share code, notes, and snippets.

View arnathan2k's full-sized avatar

Anand R arnathan2k

View GitHub Profile
#!/bin/bash
yum install httpd -y
/sbin/chkconfig --levels 235 httpd on
service httpd start
instanceId=$(curl http://169.254.169.254/latest/meta-data/instance-id)
region=$(curl http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | awk -F\" '{print $4}')
echo "<h1>$instanceId</h1>" > /var/www/html/index.html
aws ec2 create-tags --resources "$instanceId" --tags Key=Name,Value="Test-$instanceId" --region "$region"
https://artillery.io/
USE Your ARNS - ARN here are dummies
aws lambda add-permission --function-name CaptureLogLambda --statement-id rad-log-event --action lambda:InvokeFunction --principal events.amazonaws.com --source-arn arn:aws:events:us-west-1:6500000000:rule/rad-log-rule"
arn:aws:lambda:us-west-1:65000000000:function:CaptureLogLambda
aws events put-targets --rule rad-log-rule --targets Id=1,Arn=arn:aws:lambda:us-west-1:6586000000:function:CaptureLogLambda
{
"source": [ "aws.autoscaling" ],
"detail-type": [ "EC2 Instance-launch Lifecycle Action" ]
}
@arnathan2k
arnathan2k / Python-pip-aws-cli-win
Created April 18, 2018 19:31
AWS python pip install Windows
AWS - CLI Link https://docs.aws.amazon.com/cli/latest/userguide/awscli-install-windows.html
Install Python using msi
# Check python version
python -version
# Check pip version
pip -version
# install aws cli
@arnathan2k
arnathan2k / aws-asg-from-running-instance
Last active April 18, 2018 19:48
Create AWS autoscaling Launch configuration from running instance
# creating launch config from running instance
aws autoscaling create-launch-configuration --launch-configuration-name web-demo-launch-config --instance-id i-a8exxxxxx
# Creating ASG from running instance
aws autoscaling create-auto-scaling-group --auto-scaling-group-name web-demo-asg --instance-id i-7f12e649 --min-size 1 --max-size 2 --desired-capacity 2
@arnathan2k
arnathan2k / CloudWatchEventLambda
Last active April 19, 2018 02:27
Auto Scaling Life Cycle Event processing with Lambda
//RunCommandlambda.java Source Code
package net.anandus.captureloglamda;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import java.util.List;
public class RunCommandLambda implements RequestHandler<Request, Response> {
/**
@arnathan2k
arnathan2k / gist:30c8fc5b3fda7e3e100877bdd1eef995
Last active October 6, 2022 01:56
Lambda SSM Send Command Boto3
from __future__ import print_function
import json
import boto3
import urllib.request
print('Loading function')
Attach IGW to a VPC
aws ec2 attach-internet-gateway --vpc-id "vpc-f3cbfe8a" --internet-gateway-id "igw-6a631b0c" --region us-west-2
#top of the file
sed -i '1s/^/your text\n/' file
#End of the file
sed -i "2i192.241.xx.xx venus.example.com radious" /etc/hosts
or
echo "192.241.xx.xx venus.example.com radious" >> /etc/hosts