Skip to content

Instantly share code, notes, and snippets.

View jsbonso's full-sized avatar
🎯
portal.tutorialsdojo.com

Jon Bonso jsbonso

🎯
portal.tutorialsdojo.com
View GitHub Profile
@jsbonso
jsbonso / gist:fe22ba159acfef6a1dad6fc65129866b
Created May 13, 2019 09:33
Transfer data to and from EC2 using SCP
Transfer Data TO EC2
scp -i ~/.ssh/<your pem keyname>.pem <data to transfer> ec2-user@<IP Address>:<desired folder>/<data to transfer>
scp -i ~/.ssh/ec2.pem users.json ec2-user@192.28.25.144:app/users.json
Transfer Data FROM EC2 (Take note that there is a dot (.) on the end)
scp -i ~/.ssh/ec2.pem ec2-user@192.28.25.44:app/users.txt .
@jsbonso
jsbonso / lambda_function.py
Last active February 11, 2024 02:27
Dynamic Start and Stop Lambda Scheduler Functions
import boto3, os, json, time
REGION = os.environ['REGION']
ASG_NAME = os.environ['ASG_NAME']
SSM_PARAMETER_NAME = os.environ['SSM_PARAMETER_NAME']
ssm = boto3.client('ssm', region_name=REGION)
autoscaling = boto3.client('autoscaling', region_name=REGION)
ec2 = boto3.client('ec2', region_name=REGION)
def lambda_handler(event, context):
@jsbonso
jsbonso / start_scheduler_function.py
Last active February 11, 2024 02:26
Dynamic Start and Stop Scheduler Lambda Functions
import boto3, os, json, time
REGION = os.environ['REGION']
ASG_NAME = os.environ['ASG_NAME']
SSM_PARAMETER_NAME = os.environ['SSM_PARAMETER_NAME']
ssm = boto3.client('ssm', region_name=REGION)
ec2 = boto3.client('ec2', region_name=REGION)
autoscaling = boto3.client('autoscaling', region_name=REGION)
def lambda_handler(event, context):
@jsbonso
jsbonso / AWS Lambda SSM Parameter Store Updater function.py
Last active February 11, 2024 02:25
AWS Lambda SSM Parameter Store Updater function
import boto3, os, json
REGION = os.environ['REGION']
ASG_NAME = os.environ['ASG_NAME']
SSM_PARAMETER_NAME = os.environ['SSM_PARAMETER_NAME']
ssm = boto3.client('ssm', region_name=REGION)
autoscaling = boto3.client('autoscaling', region_name=REGION)
def lambda_handler(event, context):
@jsbonso
jsbonso / aws-lambda-send-notif-to-tdojo-slack.py
Created July 11, 2022 23:03
Lambda Function that sends CloudWatch Logs notification to Slack
#
# Real-time Monitoring of 5XX Errors using AWS Lambda, CloudWatch Logs and Slack
# Author: Tutorials Dojo Team
#
import json
import urllib3
import base64, zlib
http = urllib3.PoolManager()
@jsbonso
jsbonso / automated_serverresponse_check.sh
Created December 20, 2022 00:14
Automated Script to Check TTFB for N Times
#!/bin/bash
for i in {1..250}
do
curl -o /dev/null \
-w "%{time_starttransfer}\n" \
https://google.com >> prod.txt
done
@jsbonso
jsbonso / uploadToS3.sh
Created December 20, 2022 03:00
Upload new file to Amazon S3 via AWS CLI
# Get the latest file that's added in the folder
LATEST_FILE=`ls -tp | grep -v /$ | head -1`
echo $LATEST_FILE
# Upload the new file to your Amazon S3 Bucket.
# In this example, the "jonbonso-media" S3 bucket has an associated CloudFront distribution
# with a custom domain of "media.jonbonso.com"
aws s3 cp $LATEST_FILE s3://jonbonso-media
@jsbonso
jsbonso / Dynamic Start and Stop Scheduler Functions.json
Last active February 11, 2024 02:20
Dynamic Start and Stop Scheduler Functions
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "Dynamic Start and Stop Scheduler Functions - Tutorials Dojo",
"Action": [
"autoscaling:EnterStandby",
"autoscaling:ExitStandby",
"autoscaling:PutScalingPolicy",
"autoscaling:SetDesiredCapacity"
],
@jsbonso
jsbonso / addMyIp.sh
Last active February 27, 2023 22:36
Shell Script to add your IP to your EC2 Security Group using AWS CLI
MY_IP=`curl checkip.amazonaws.com`
echo $MY_IP
aws ec2 authorize-security-group-ingress \
--group-id sg-01298cde13c80c75 \
--protocol tcp \
--port 22 \
--cidr $MY_IP/32 \
--region us-east-1
@jsbonso
jsbonso / AWS Certified Solutions Architect-Professional SAP-C01 New Feb 2019 Version Exam Notes.txt
Last active November 18, 2022 05:17
AWS Certified Solutions Architect-Professional SAP-C01 New Feb 2019 Version Exam Notes
# AWS Certified Solutions Architect-Professional SAP-C01 New Feb 2019 Version Exam
## Final Tips:
1. Don't cram! If you are not ready to take the SAP-C01 exam, then just re-schedule it to a later date. Haste makes waste!
2. Read the question first and then look at the options. Most of the time, you will notice that there are two seemingly similar options which only differs in one or several keywords. This will help you eliminate the wrong options much easier.
3. Take the free AWS Exam Readiness course in https://aws.training and other free courses/videos there.
## Exam Notes:
- The new exam has *75* questions that you have to finish within *3* hours (180 minutes) with a minimum passing score of 750 out of 1000. The official AWS exam page says the exam is 170 minutes, but that is actually incorrect. I took the exam and it is 180 minutes and not 170 minutes.