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 pandas as pd | |
import boto3 | |
import requests | |
import io | |
from requests.structures import CaseInsensitiveDict | |
from boto3.dynamodb.conditions import Key | |
def lambda_handler(event, context): | |
def _getParameters(paramName): |
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 json, boto3, os, re | |
import gzip | |
import base64 | |
import ipinfo | |
from io import BytesIO | |
from botocore.exceptions import ClientError | |
def lambda_handler(event, context): | |
dynamodbclient = boto3.client('dynamodb') |
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
# Description: Enumerates short codes and long names for AWS services | |
# Code modified from https://www.sentiatechblog.com/retrieving-all-region-codes-and-names-with-boto3 | |
class Services: | |
@classmethod | |
def get_services(cls): | |
short_codes = cls._get_service_short_codes() | |
services = [{ | |
'name': cls._get_service_long_name(sc), | |
'code': sc |
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 io, json | |
import brevitycore.core | |
def generateInstallScriptAxiom(inputBucketName): | |
# Load AWS access keys for s3 synchronization | |
secretName = 'brevity-aws-recon' | |
regionName = 'us-east-1' | |
secretRetrieved = brevitycore.core.get_secret(secretName,regionName) | |
secretjson = json.loads(secretRetrieved) | |
awsAccessKeyId = secretjson['AWS_ACCESS_KEY_ID'] |
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
def generateParameterStore(dataBucketName,graphBucketName,inputBucketName,presentationBucketName,ATHENA_BUCKET,ATHENA_DB,ATHENA_TABLE): | |
graphBucketPath = 's3://' + dataBucketName + '/graph/' | |
rawBucketPath = 's3://' + dataBucketName + '/raw/' | |
refinedBucketPath = 's3://' + dataBucketName + '/refined/' | |
inputBucketPath = 's3://' + inputBucketName + '/' | |
programInputBucketPath = 's3://' + inputBucketName + '/programs/' | |
presentationBucketPath = 's3://' + presentationBucketName + '/presentation/' | |
variableStatus = 'Variables successfully assigned.' |
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 json, boto3, os | |
def lambda_handler(event, context): | |
if event['program'] is None: | |
return {"isBase64Encoded":False,"statusCode":400,"body":json.dumps({"error":"Missing program name."})} | |
if event['operation'] is None: | |
return {"isBase64Encoded":False,"statusCode":400,"body":json.dumps({"error":"Missing operation name."})} | |
else: | |
operationName = str(event['operation']) |
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
# NetworkX with Bokeh example | |
import networkx as nx | |
import pandas as pd | |
from bokeh.io import output_notebook, show, save | |
from bokeh.models import Range1d, Circle, ColumnDataSource, MultiLine | |
from bokeh.plotting import figure | |
from bokeh.plotting import from_networkx | |
# https://docs.bokeh.org/en/latest/docs/reference/palettes.html |
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
def processHttpx(programName, refinedBucketPath, inputBucketPath, presentationBucketPath, operationName, programInputBucketPath): | |
fileName = programName + '-httpx-' + operationName + '.json' | |
presentationFilePath = presentationBucketPath + 'httpx-json/' + fileName | |
df = pd.read_json(presentationFilePath, lines=True) | |
df['program'] = programName | |
if (operationName == 'initial'): | |
storePathUrl = programInputBucketPath + programName + '/' + programName + '-httpx.csv' | |
df.to_csv(storePathUrl, header=False, index=False, sep='\n') |
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
def _getParameters(paramName): | |
client = boto3.client('ssm') | |
response = client.get_parameter( | |
Name=paramName | |
) | |
return response['Parameter']['Value'] | |
rawBucketPath = _getParameters('rawBucketPath') | |
refinedBucketPath = _getParameters('refinedBucketPath') | |
inputBucketPath = _getParameters('inputBucketPath') |
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 | |
import logging | |
import ClientError | |
import json | |
from botocore.exceptions import ClientError | |
# update a secret value within AWS Secrets Manager | |
def put_secret(secretName,secretValue,regionName): | |
# Create a Secrets Manager client | |
session = boto3.session.Session() |
NewerOlder