Skip to content

Instantly share code, notes, and snippets.

View MrHassanMurtaza's full-sized avatar
🎯
Focusing

Hassan Murtaza MrHassanMurtaza

🎯
Focusing
View GitHub Profile
@MrHassanMurtaza
MrHassanMurtaza / Deny_If_No_Purpose_Tag.json
Created January 30, 2020 08:47
Deny_If_No_Purpose_Tag
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "NoPurposeTag",
"Effect": "Deny",
"Action": [
"ec2:RunInstances",
"ec2:CreateVolume"
],
@MrHassanMurtaza
MrHassanMurtaza / athena_routetable_query
Created January 24, 2020 12:52
Audit Routetable changes using CloudTrail and Athena
SELECT eventname, useridentity.username, sourceIPAddress, eventtime, requestparameters
FROM cloudtrail_logs_athena_table
WHERE (requestparameters like '%rtb-xxxxxxx%') limit 10;
@MrHassanMurtaza
MrHassanMurtaza / athena_routetable_query
Created January 24, 2020 12:52
Audit Routetable changes using CloudTrail and Athena
SELECT eventname, useridentity.username, sourceIPAddress, eventtime, requestparameters
FROM cloudtrail_logs_athena_table
WHERE (requestparameters like '%rtb-xxxxxxx%') limit 10;
@MrHassanMurtaza
MrHassanMurtaza / aws-codepipeline-executor.py
Last active January 10, 2020 12:40
AWS CodePipeline Executor Python
import json, os
import boto3
from botocore.exceptions import ClientError
def lambda_handler(event, context):
"""
Lambda Handler
Triggers AWS CodePipeline
:param event: takes event triggered by cloudwatch rule
@MrHassanMurtaza
MrHassanMurtaza / serverless-deploy-iam.json
Created November 21, 2019 13:07
Serverless Deploy Permissions with SQS as a Trigger
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"apigateway:GET",
"apigateway:POST",
"apigateway:PUT",
@MrHassanMurtaza
MrHassanMurtaza / secret-manager-policy.json
Last active October 24, 2019 09:58
Secret manager attribute based access control
{
"Version":"2012-10-17",
"Statement":[
{
"Effect":"Allow",
"Action": "secretsmanager:GetSecretValue",
"Resource": "*",
"Condition": {
"secretsmanager:ResourceTag/Project": "${aws:PrincipalTag/Project}"
}
@MrHassanMurtaza
MrHassanMurtaza / secret-manager-to-env.js
Created October 17, 2019 10:46
secret-manager-to-env
// Use this code snippet in your app.
// If you need more information about configurations or implementing the sample code, visit the AWS docs:
// https://aws.amazon.com/developers/getting-started/nodejs/
// Load the AWS SDK
DEPLOYMENT_GROUP_NAME = process.env.DEPLOYMENT_GROUP_NAME
var AWS = require('aws-sdk'),
region = "us-west-2",
secretName = `${DEPLOYMENT_GROUP_NAME}`,
Autoscaling.
◾Understand autoscaling inside and out.
◾Make sure you know the differences between deploying with and without Cloudformation (as there are some deployment methods you can do with Cloudformation that you can’t without) and the command or JSON syntax to perform them.
◾Understand lifecycle hooks and the autoscaling stages they run in
◾Understand launch configurations and how they work and are updated (hint: You must replace them)
◾Understand why you may need to place an instance into STANDBY state
•Elastic Beanstalk.
◾You’ll need to know this to an advanced level.
◾Understand what stacks Beanstalk supports natively and how you would deploy a stack it doesn’t (hint: Use Docker).
@MrHassanMurtaza
MrHassanMurtaza / csv-to-json.js
Last active August 17, 2019 22:05
Convert CSV to JSON based on Delimeter
const removeSpaces = (str) => {
return str.replace(/^\s+|\s+$/g, "");
}
const DELIMITER = '|';
const csvJSON = (csv) => {
let lines = csv.split("\n");
@MrHassanMurtaza
MrHassanMurtaza / circleci.yml
Created July 24, 2019 11:42 — forked from statico/circleci.yml
Node.js 10 + PostgreSQL CircleCI config
version: 2
workflows:
version: 2
build:
jobs:
- test
jobs:
test: