Skip to content

Instantly share code, notes, and snippets.

View artem-hatchenko's full-sized avatar

Artem Hatchenko artem-hatchenko

View GitHub Profile
import boto3
custom_ec2_filter = [
{
'Name': 'instance-state-name',
'Values': ['running', 'pending']
}
]
# Combination of tag key and value to prevent shutdown/downscale resources
{
"Version": "2012-10-17",
"Id": "certbot-dns-route53",
"Statement": [
{
"Effect": "Allow",
"Action": [
"route53:ListHostedZones",
"route53:GetChange"
],
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ec2:AttachNetworkInterface",
"ec2:DetachNetworkInterface",
"ec2:DescribeInstances",
"ec2:DescribeNetworkInterfaces",
"ec2:AssignPrivateIpAddresses",
from __future__ import print_function
from datetime import datetime
import sys
import boto3
import botocore
import urllib.request
ec2 = boto3.client('ec2', region_name='eu-west-1')
def create_snapshot(app):
properties([
parameters([
choice(
name: 'PYTHON',
description: 'Choose Python version',
choices: ["python2.7", "python3.6", "python3.7", "python3.8", "python3.9"].join("\n")
),
base64File(
name: 'REQUIREMENTS_FILE',
description: 'Upload requirements file (Optional)'
import boto3
import json
import csv
import datetime
from pkg_resources import resource_filename
ReportFile = './report.csv'
CpuThreshold = 40 # If we reduce instance size, CPU utilization will be twice. e.g. 40*2=80% CPU utilization
# EC2 filter, we will skip terminated instances