This file contains 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
#!/bin/bash | |
# Here are some embedded Python examples using Python3. | |
# They are put into functions for separation and clarity. | |
# Simple usage, only using python to print the date. | |
# This is not really a good example, because the `date` | |
# command works just as well. | |
function date_time { |
This file contains 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 boto3 | |
def role_arn_to_session(**args): | |
""" | |
Usage : | |
session = role_arn_to_session( | |
RoleArn='arn:aws:iam::012345678901:role/example-role', | |
RoleSessionName='ExampleSessionName') | |
client = session.client('sqs') | |
""" |
This file contains 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
Copyright 2020 Brad Montgomery | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software | |
and associated documentation files (the "Software"), to deal in the Software without restriction, | |
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, | |
subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial | |
portions of the Software. |
This file contains 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
function check_for_virtual_env { | |
[ -d .git ] || git rev-parse --git-dir &> /dev/null | |
if [ $? -eq 0 ]; then | |
local ENV_NAME=`basename \`pwd\`` | |
if [ "${VIRTUAL_ENV##*/}" != $ENV_NAME ] && [ -e $WORKON_HOME/$ENV_NAME/bin/activate ]; then | |
workon $ENV_NAME && export CD_VIRTUAL_ENV=$ENV_NAME | |
fi | |
elif [ $CD_VIRTUAL_ENV ]; then |
This file contains 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
# Set default aws-profile | |
AWS_PROFILE=myprofile | |
# Run sls with an aws-profile | |
sls_with_aws_profile() { | |
if [ -z ${AWS_PROFILE+x} ]; | |
then printf "\e[1;31mAWS_PROFILE is not set\e[0m\n$ export AWS_PROFILE=profile_name\n" \ | |
&& return; | |
fi | |
export AWS_SDK_LOAD_CONFIG=true; |