Skip to content

Instantly share code, notes, and snippets.

@kp7425
kp7425 / slack_webhook_post.py
Created November 6, 2020 04:01 — forked from devStepsize/slack_webhook_post.py
POST a JSON payload to a Slack Incoming Webhook using Python requests
'''
This is an example of how to send data to Slack webhooks in Python with the
requests module.
Detailed documentation of Slack Incoming Webhooks:
https://api.slack.com/incoming-webhooks
'''
import json
import requests
@kp7425
kp7425 / jinja2_file_less.py
Created October 14, 2020 16:40 — forked from wrunk/jinja2_file_less.py
python jinja2 examples
#!/usr/bin/env/python
#
# More of a reference of using jinaj2 without actual template files.
# This is great for a simple output transformation to standard out.
#
# Of course you will need to "sudo pip install jinja2" first!
#
# I like to refer to the following to remember how to use jinja2 :)
# http://jinja.pocoo.org/docs/templates/
#
@kp7425
kp7425 / vault-agent.tpl
Created September 21, 2020 22:06 — forked from mehdilaruelle/vault-agent.tpl
Vault agent template for demonstration with apache server under Amazon Linux 2
auto_auth {
method {
type = "aws"
config = {
type = "ec2"
role = "web"
}
}
sink {
@kp7425
kp7425 / consul-template.tpl
Created September 21, 2020 22:05 — forked from mehdilaruelle/consul-template.tpl
Consul template for demonstration with apache server under Amazon Linux 2
log_level = "info"
vault {
address = "_VAULT_ADDR_"
vault_agent_token_file = "/home/ec2-user/.vault-token"
# unwrap_token = true
# renew_token = true
@kp7425
kp7425 / list_monitoring_configuration.py
Created June 3, 2020 17:38 — forked from cktricky/list_monitoring_configuration.py
List Configuration of Monitoring Services in AWS
import boto3
import pprint
pp = pprint.PrettyPrinter(indent=5, width=80, compact=False)
#http://docs.aws.amazon.com/general/latest/gr/rande.html
regions = ['us-east-1', 'us-west-2', 'ap-northeast-2', 'ap-southeast-1', 'ap-southeast-2', 'ap-northeast-1', 'eu-central-1', 'eu-west-1']
'''
@kp7425
kp7425 / s3_bucket_stats.py
Created May 3, 2020 03:10 — forked from rwiggins/s3_bucket_stats.py
Lists the storage size (for all storage types) and tags of all S3 buckets in an account using CloudWatch's GetMetricStatistics. Uses the default AWS credentials in your environment. (See awscli configuration for more information.)
import boto3
import botocore
import datetime
import progressbar
import itertools
# from https://docs.aws.amazon.com/AmazonS3/latest/dev/cloudwatch-monitoring.html
STORAGE_TYPES = [
"StandardStorage",
"IntelligentTieringStorage",
@kp7425
kp7425 / set-intelligent-lifecycle.py
Created April 24, 2020 04:27 — forked from reecestart/set-intelligent-lifecycle.py
Gets all S3 Buckets and creates an Intelligent Tiering Lifecycle Rule on all of them.
import boto3
from datetime import date
from datetime import datetime
today = date.today()
today = datetime.combine(today, datetime.min.time())
client = boto3.client('s3')
# Get all buckets
response = client.list_buckets()
#!/usr/bin/env python
import os
import boto3
s3Client = boto3.client('s3')
buckets = s3Client.list_buckets()
DAYS = int(os.environ['DAYS'])
def setType(key):
if key == "NoncurrentVersionTransitions":