Skip to content

Instantly share code, notes, and snippets.

View tomarv2's full-sized avatar

Varun Tomar tomarv2

View GitHub Profile
@tomarv2
tomarv2 / setup.py
Last active June 1, 2020 19:21
setup file
import os
from setuptools import find_packages, setup
VERSION = "0.0.1.dev4"
ROOT_PATH = os.path.abspath(os.path.dirname(__file__))
def get_requirements(env):
with open("requirements-{}.txt".format(env)) as fp:
@tomarv2
tomarv2 / cli.py
Last active June 1, 2020 19:20
click cli
import click
from .manage_secrets import get_value_from_parameter_store as get_ssm
@click.group()
def entrypoint():
pass
@entrypoint.command()
@tomarv2
tomarv2 / manage_secerts.py
Last active June 1, 2020 14:47
get value from parameter store
import boto3
def get_value_from_parameter_store(name):
client = boto3.client('ssm')
try:
parameter = client.get_parameter(Name=name, WithDecryption=True)
return parameter['Parameter']['Value']
except client.exceptions.ParameterNotFound:
print("parameter not found")
@tomarv2
tomarv2 / output
Created May 28, 2020 04:22
codepipeline source stage as github
{
"name": "Source",
"actions": [
{
"name": "Source",
"actionTypeId": {
"category": "Source",
"owner": "ThirdParty",
"provider": "GitHub",
"version": "1"
@tomarv2
tomarv2 / Logic Apps Designer
Last active April 30, 2020 03:25
Logic Apps Designer gmail body customization
"body": {
"Body": "<p><span style=\"font-size: 16px\"><strong>Demo Name: </strong></span>@{triggerBody()['PolicyName']}<br>\n<span style=\"font-size: 16px\"><strong>Description:</strong></span><strong> </strong>@{triggerBody()['Description']}<br>\n<strong><br>\n</strong><span style=\"font-size: 16px\"><strong>Resource</strong></span><strong><br>\n--------------<br>\nName: </strong>@{triggerBody()['Resource']['Name']}<br>\n<strong>Location: </strong>@{triggerBody()['Resource']['Location']}<br>\n<strong>Owner: </strong>@{triggerBody()['Resource']['Owner']}<br>\n<strong>VmSize: </strong>@{triggerBody()['Resource']['VmSize']}<br>\n<br>\n</p>",
"Subject": "Demo: @{triggerBody()['PolicyName']}",
"To": "@{triggerBody()['Resource']['Owner']}"
},
<p align="center">
<img width="600" height="370" src="https://files.gitter.im/tomarv2/J2GJ/Screen-Shot-2020-04-23-at-8.22.42-PM.png">
</p>
@tomarv2
tomarv2 / alertmanager.yaml
Created April 24, 2020 02:30
alertmanager config.yaml part4
receivers:
- name: 'default-email'
email_configs:
- send_resolved: true
to: demo@demo.com
from: demo@demo.com
smarthost: smtp.gmail.com:587
headers:
From: demo@demo.com
Subject: '{{ template "email.default.subject" . }}'
@tomarv2
tomarv2 / alertmanager.yaml
Created April 24, 2020 02:29
alertmanager config.yaml part3
route:
receiver: 'default-email'
group_by: ['alertname', 'cluster', 'service']
group_wait: 10s
group_interval: 5m
repeat_interval: 4h
routes:
# - receiver: 'infrastructure-monitoring-email'
# match_re:
# service: ^(infrastructure*)$
@tomarv2
tomarv2 / alertmanager.yaml
Created April 24, 2020 02:28
alertmanager config.yaml
inhibit_rules:
- source_match:
severity: critical
target_match:
severity: warning
equal:
- alertname
- cluster
- service
@tomarv2
tomarv2 / alertmanager.yaml
Created April 24, 2020 02:27
alertmanager config file
global:
resolve_timeout: 1h
smtp_from: demo@demo.com
smtp_smarthost: smtp.gmail.com:587 #465(SSL) or 465(TLS) based on requirement
#smtp_require_tls: false
smtp_auth_username: demo@demo.com
smtp_auth_password: password
pagerduty_url: https://events.pagerduty.com/v2/enqueue
slack_api_url: https://hooks.slack.com/services/T12345/T12345/12345