🤷♂️
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import boto3 | |
import datetime | |
from pathlib import Path | |
from typing import Dict, List, Tuple | |
import humanize | |
import logging | |
logging.basicConfig(level=logging.INFO) | |
logger = logging.getLogger(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Nombre del script: cleanup.sh | |
# Descripción: Elimina recursivamente directorios .ipynb_checkpoints y node_modules | |
# Colores para mensajes | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
YELLOW='\033[1;33m' | |
NC='\033[0m' # No Color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A vantablack friday: How to be prepared to stop DDoS Attacks after Halloween | |
# https://blog.evereven.tech | |
# Create a cloudwatch alarm | |
aws cloudwatch put-metric-alarm \ | |
--alarm-name High-CPU-Utilization \ | |
--metric-name CPUUtilization \ | |
--namespace AWS/EC2 \ | |
--period 300 \ | |
--evaluation-periods 1 \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A vantablack friday: How to be prepared to stop DDoS Attacks after Halloween | |
# https://blog.evereven.tech | |
# Create a WebACL Group Rule (replace [SUSPICIOUS_AGENT_IN_BASE64]) | |
aws wafv2 create-rule-group \ | |
--name "pattern-matching-rules" \ | |
--scope REGIONAL \ | |
--capacity 1000 \ | |
--visibility-config \ | |
MetricName=DDOSRuleMetric,SampledRequestsEnabled=true,CloudWatchMetricsEnabled=true \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A vantablack friday: How to be prepared to stop DDoS Attacks after Halloween | |
# https://blog.evereven.tech | |
# Create a local json file with the configuration | |
cat > dashboard.json << 'EOL' | |
{ | |
"widgets": [ | |
{ | |
"type": "metric", | |
"properties": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A vantablack friday: How to be prepared to stop DDoS Attacks after Halloween | |
# https://blog.evereven.tech | |
# Get API GW IDs and stage names | |
aws apigateway get-rest-apis --query 'items[*].[id,name]' --output json | |
> [ | |
> [ | |
> "abc123xyz", | |
> "my-api" | |
> ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A vantablack friday: How to be prepared to stop DDoS Attacks after Halloween | |
# https://blog.evereven.tech | |
# Obtain Auto Scaling Group Name | |
aws autoscaling describe-auto-scaling-groups \ | |
--query 'AutoScalingGroups[*].[AutoScalingGroupName,MinSize,MaxSize,DesiredCapacity]' \ | |
--output json | |
> [ | |
> [ | |
> "my-asg-cool-name", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A vantablack friday: How to be prepared to stop DDoS Attacks after Halloween | |
# https://blog.evereven.tech | |
# Obtain distribution ID | |
aws cloudfront list-distributions --query 'DistributionList.Items[*].Id' --output json | |
> [ | |
> "E1PI*******PNY" | |
> ] | |
# Obtain codes from: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A vantablack friday: How to be prepared to stop DDoS Attacks after Halloween | |
# https://blog.evereven.tech | |
# Create a WebACL Group Rule | |
aws wafv2 create-rule-group \ | |
--name "emergency-ddos-rules" \ | |
--scope REGIONAL \ | |
--capacity 1000 \ | |
--visibility-config \ | |
MetricName=DDOSRuleMetric,SampledRequestsEnabled=true,CloudWatchMetricsEnabled=true \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Ensure this script its used by consola or exit process | |
if (php_sapi_name() !== 'cli') { | |
die('This script can only be run from the command line.'); | |
} | |
// Load SDK de AWS | |
require 'vendor/autoload.php'; | |
use Aws\Exception\AwsException; |
NewerOlder