This file contains hidden or 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
| """ Make a dictionary that maps timezone abbreviations to timezone names. | |
| The timezone_lookup module supplies a single dictionary, timezone_lookup. For example, | |
| >>> timezone_lookup['EST'] | |
| 'US/Michigan' | |
| """ | |
| from datetime import datetime | |
| import pytz |
- Two AWS RDS MySQL databases - moving databases from source to destination.
- Both databases are not publicly accessible, only via an EC2 instance(s) - e.g. you have setup your security groups.
- Can SSH to a target EC2 instance (but of course).
- Sets up two SSH port forwards on local machine - one to source database, another to target.
- Via calls to
transferDatabase():
This file contains hidden or 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
| import django_filters | |
| class CommaSeparatedValueFilter(django_filters.CharFilter): | |
| """Accept comma separated string as value and convert it to list. | |
| It's useful for __in lookups. | |
| """ | |
| def filter(self, qs, value): |
When unsing docker compose you can have a problem with the order of dependent linked containers
The solution is to start a script which tries to access a service and waits until it gets ready before loading your program
Requires
- aws-cli - https://aws.amazon.com/cli/
- jq - https://stedolan.github.io/jq/
Configure path to your ECS SSH key file ~/.bashrc
echo 'export ECS_PEM_FILE=$HOME/docker.pem' >> ~/.bashrc
This file contains hidden or 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
| __author__ = 'dkarchmer' | |
| ''' | |
| This script emulates a stand-alone Python based client. It relies on Boto3 to access AWS, but | |
| requires your Django server to have an API for your user to access Cognito based credentials | |
| Because of Cognito, the client (this script) will only get temporary AWS credentials associated | |
| to your user and only your user, and based on whatever you configure your AIM Policy to be. | |
| Most Cognito examples demonstrate how to use Cognito for Mobile Apps, so this scripts demonstrate | |
| how to create a stand-alone Python script but operating similarly to these apps. |
This file contains hidden or 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
| from __future__ import print_function | |
| import json | |
| import boto3 | |
| import logging | |
| #setup simple logging for INFO | |
| logger = logging.getLogger() | |
| logger.setLevel(logging.ERROR) |
This file contains hidden or 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
| from boto.cloudfront.distribution import Distribution | |
| from cryptography.hazmat.primitives.asymmetric import padding | |
| from cryptography.hazmat.primitives import serialization | |
| from cryptography.hazmat.backends import default_backend | |
| from cryptography.hazmat.primitives import hashes | |
| import base64 | |
| class BetterThanBoto(Distribution): | |
| def sign_rsa(self, message): |
This file contains hidden or 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
| ''' | |
| 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 |

