Skip to content

Instantly share code, notes, and snippets.

View filipeandre's full-sized avatar

Filipe Ferreira filipeandre

View GitHub Profile
@filipeandre
filipeandre / envoyconf.yaml
Created December 18, 2019 14:29 — forked from Misterhex/envoyconf.yaml
envoy proxy protocol upstream example
admin:
access_log_path: /tmp/admin_access.log
address:
socket_address:
protocol: TCP
address: 0.0.0.0
port_value: 9901
static_resources:
listeners:
- name: tcp_listener
@filipeandre
filipeandre / Makefile
Created December 30, 2019 13:43 — forked from ryu1kn/Makefile
Encrypt/decrypt with AWS KMS using AWS cli
# How to encrypt/decrypt your text/blob secret with AWS KMS with AWS cli
KEY_ID=alias/my-key
SECRET_BLOB_PATH=fileb://my-secret-blob
SECRET_TEXT="my secret text"
ENCRYPTED_SECRET_AS_BLOB=encrypted_secret_blob
DECRYPTED_SECRET_AS_BLOB=decrypted_secret_blob # Result of decrypt-blob target
encrypt-text:
# Systems Manager
aws ssm describe-instance-information --query "InstanceInformationList[*]"
aws ssm get-document --name "AmazonInspector-ManageAWSAgent" --output text > AmazonInspector-ManageAWSAgent.doc
less AmazonInspector-ManageAWSAgent.doc
aws ssm send-command --targets Key=tag:SecurityScan,Values=true --document-name "AmazonInspector-ManageAWSAgent" --query Command.CommandId --output-s3-bucket-name <LoggingBucket>
aws ssm list-command-invocations --details --query "CommandInvocations[*].[InstanceId,DocumentName,Status]" --command-id <CommandId>
# Inspector
aws inspector create-resource-group --resource-group-tags key=SecurityScan,value=true
aws inspector create-assessment-target --assessment-target-name GamesDevTargetGroup --resource-group-arn aws inspector create-assessment-target --assessment-target-name GamesDevTargetGroup --resource-group-arn <ResourceGroupARN>
^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[Tt]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(([Zz])|([\+|\-]([01][0-9]|2[0-3]):[0-5][0-9]))$
# Enable autoscaling for the service
ScalableTarget:
Type: AWS::ApplicationAutoScaling::ScalableTarget
DependsOn: Service
Properties:
ServiceNamespace: 'ecs'
ScalableDimension: 'ecs:service:DesiredCount'
ResourceId:
Fn::Join:
- '/'
@filipeandre
filipeandre / lambda_asg_failover.py
Created March 13, 2020 02:04 — forked from davidglvn/lambda_asg_failover.py
Failover from spot to on-demand group
import boto3
from os import getenv
from json import loads
# AutoScalingGroups Region
REGION = getenv("REGION", "us-east-1")
# Name of On-Demand failover AutoScalingGroup
ON_DEMAND_ASG = getenv("ON_DEMAND_ASG", None)
# Name of Spot AutoScalingGroup
SPOT_ASG = getenv("SPOT_ASG", None)
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Single node MongoDB deployment with a RAID10 storage configuration",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access",
"Type" : "String"
},
@filipeandre
filipeandre / create_and_attach_volume.yaml
Created March 19, 2020 00:45 — forked from ssummer3/create_and_attach_volume.yaml
AWS: Create and Attach a Volume to an EC2 Instance
AWSTemplateFormatVersion: '2010-09-09'
Description: Create a Volume from scratch and attach it to an instance.
Metadata:
AWS::CloudFormation::Interface:
@filipeandre
filipeandre / mongodb-s3-backup.sh
Created March 23, 2020 09:39 — forked from eladnava/mongodb-s3-backup.sh
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh
Resources:
RateLimitACL:
Type: AWS::WAFv2::WebACL
Properties:
Name: rate-limit-acl
Scope: REGIONAL
Description: Auto-generated rate-limiting ACL.
DefaultAction:
Allow: {}
VisibilityConfig: