Skip to content

Instantly share code, notes, and snippets.

@ozgurakan
ozgurakan / cf_mapping_helper.py
Last active July 10, 2017 18:04
Creates mapping in YAML for AWS CloudFormation
# searches all regions and creates a CloudFormation "Mappings"
# YAML template with;
# - AMI IDs
# - zones for regions
#
# Usage:
# modify images dictionary
# structure is like below;
#
# 'alias': {
@ozgurakan
ozgurakan / lambda_assume_role.py
Last active January 12, 2023 08:55
Assume Role within A Lambda function (Python)
import boto3
# you can assign role in the function like below
# ROLE_ARN = 'arn:aws:iam::01234567890:role/my_role'
#
# or you can pass role as an evironment varibale
# ROLE_ARN = os.environ['role_arn']
ROLE_ARN = = os.environ['role_arn']
@ozgurakan
ozgurakan / tries.py
Last active April 18, 2017 20:50
simple tries implementation
#!/bin/python3
class Node(object):
def __init__(self, key=None, count=0):
self._key = key
self._count = count
self._children = dict()
@property
def children(self):
#!/bin/python3
def is_s3_enabled(result):
attributes = result['Attributes']
s3_logs_enabled = False
for attribute in attributes:
if attribute['Key'] == 'access_logs.s3.enabled':
if attribute['Value'].title() == 'True':
s3_logs_enabled = True
break
@ozgurakan
ozgurakan / json_example.py
Last active April 13, 2017 01:25
json example
#!/bin/python3
#
# Related API
# http://docs.aws.amazon.com/cli/latest/reference/elb/describe-load-balancer-attributes.html
#
import json
json_doc = '''{
"Attributes": [
{
@ozgurakan
ozgurakan / Salt Formula Development Workflow
Created February 18, 2015 21:59
salt formula workflow
<p>SaltStack Formula Development Workflow</p>
<div class="flow-chart"><svg height="1547.9765625" version="1.1" width="546.275390625" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="overflow: hidden; position: relative; top: -0.796875px;"><desc style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Created with Raphaël 2.1.2</desc><defs style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path><marker id="raphael-marker-endblock33-obj24" markerHeight="3" markerWidth="3" orient="auto" refX="1.5" refY="1.5" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#raphael-marker-block" transform="rotate(180 1.5 1.5) scale(0.6,0.6)" stroke-width="1.6667" fill="black" stroke="none" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></use></marker><marker id="raphael-marker-endblock3
@ozgurakan
ozgurakan / salt_example.md
Last active August 29, 2015 14:11
SaltStack MongoDB in 30 minutes

Install Salt and Configure MongoDB

Create two servers

We assume you already have two Ubuntu Linux 14.04 servers. salt-master has hostname master and salt-minion has hostname as minion

Configure passwordless ssh login

This is optional and if you like so just google to learn how to do it.

Configure hosts so master minion is easy to access

Edit /etc/hosts file in order to be able to login to master and minion servers

@ozgurakan
ozgurakan / marconi-installation-guide.md
Last active August 29, 2015 13:56
Marconi Installation Guide.md

Configure Queuing Service

Contents

  • System Requirements
  • Queuing Service Concepts
  • Install Queuing Service
  • Configure Shards
  • Create A Queue

System Requirements

@ozgurakan
ozgurakan / marconi-sample.py
Created July 19, 2013 19:55
Openstack Marconi Python Example
import requests
import json
username = 'my-user'
apikey = 'my-api-key'
url = 'https://test.my-marconi-server.com:443'
class Queue_Connection(object):
def __init__(self, username, apikey):