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 json | |
| def getSubscriptions(event, context): | |
| """ | |
| Returns a list of subscriptions to the mailing list | |
| """ | |
| # The body that will be returned in the response | |
| body = { | |
| "data": "getSubscriptions" |
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
| def getDotEnv(element): | |
| # import the dotenv functionality we need | |
| from dotenv import load_dotenv, find_dotenv | |
| # import the necessary commands we need to build a path to our .env file | |
| from os.path import join, dirname | |
| # create the path to .env file | |
| dotenv_path = join(dirname(__file__), '.env') |
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
| def getQueryStringElement(element, event, default=None): | |
| if event is None: | |
| return default | |
| elif not('queryStringParameters' in event): | |
| return default | |
| if event['queryStringParameters'] is None: | |
| return default | |
| elif element in event['queryStringParameters']: | |
| return event['queryStringParameters'].get(element) |
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 the boto modules | |
| import botocore | |
| import boto3 | |
| # get our aws credentials from our .env file | |
| aws_access_key_id = str(getDotEnv("ACCESS_KEY_ID")) | |
| aws_secret_access_key = str(getDotEnv("SECRET_ACCESS_KEY")) | |
| region_name = str(getDotEnv("REGION_NAME")) | |
| # create the client of type 'rds-data' |
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
| sql = "select * from registrations" | |
| awsSecretStoreArn=getDotEnv("AWSSECRETSTOREARN") | |
| dbClusterOrInstanceArn=getDotEnv("DBCLUSTERORINSTANCEARN") | |
| database=getDotEnv("DATABASE") | |
| # call data-api to execute sql | |
| response = client.execute_sql( | |
| awsSecretStoreArn=awsSecretStoreArn, | |
| database=database, |
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
| def mungeBoto3Rds(response): | |
| # get a list of all the rows of data returned | |
| records = response.get('sqlStatementResults')[0].get('resultFrame').get('records') | |
| # get a list of keys so that element 0 of keys is the name of the column for | |
| # the data in element 0 of records | |
| keysList = list(map(lambda i: str(i.get('name')), response.get('sqlStatementResults')[0].get('resultFrame').get('resultSetMetadata').get('columnMetadata'))) | |
| # an empty list to hold our newly-munged data |
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
| service: mailinglist # NOTE: update this with your service name | |
| provider: | |
| name: aws | |
| runtime: python3.7 | |
| functions: | |
| postSubscription: | |
| handler: mailinglist.postSubscription | |
| events: |
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 json | |
| import os | |
| import sys | |
| packages_path = os.path.join(os.path.split(__file__)[0], "packages") | |
| sys.path.append(packages_path) | |
| #---------------------------------- | |
| # Handler functions |
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
| server { | |
| server_name <domain name>; | |
| root "<path to repository>"; | |
| index index.html index.htm index.php; | |
| charset utf-8; | |
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
| user www-data; | |
| worker_processes auto; | |
| pid /run/nginx.pid; | |
| include /etc/nginx/modules-enabled/*.conf; | |
| events { | |
| worker_connections 768; | |
| # multi_accept on; | |
| } |
OlderNewer