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 file is your Lambda function | |
| import base64 | |
| import json | |
| import boto3 | |
| def save_to_bucket(event, context): | |
| AWS_BUCKET_NAME = 'my-bucket-name' | |
| s3 = boto3.resource('s3') |
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 boto3 | |
| connection = boto3.client( | |
| 'emr', | |
| region_name='us-east-1', | |
| aws_access_key_id='YOUR ACCESS KEY', | |
| ws_secret_access_key='YOUR SECRET KEY', | |
| ) | |
| cluster_id = 'give the cluster id' |
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 boto3 | |
| connection = boto3.client( | |
| 'emr', | |
| region_name='us-east-1', | |
| aws_access_key_id='YOUR ACCESS KEY', | |
| ws_secret_access_key='YOUR SECRET KEY', | |
| ) | |
| cluster_id = 'give the cluster id' |
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 sys | |
| import time | |
| import boto3 | |
| def lambda_handler(event, context): | |
| conn = boto3.client("emr") | |
| # chooses the first cluster which is Running or Waiting | |
| # possibly can also choose by name or already have the cluster id | |
| clusters = conn.list_clusters() |
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 pg8000 as dbapi | |
| from pprint import pprint | |
| def getconnection(database,host,port,user,password): | |
| conn= None | |
| try: | |
| conn=dbapi.connect(database=database,host=host, port=port,\ | |
| user=user,password=password,ssl=True) | |
| except Exception as err: |
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 sys | |
| from awsglue.transforms import * | |
| from awsglue.utils import getResolvedOptions | |
| from pyspark.context import SparkContext | |
| from awsglue.context import GlueContext | |
| from awsglue.job import Job | |
| args = getResolvedOptions(sys.argv, ['TempDir','JOB_NAME']) | |
| ## Initialize the GlueContext and SparkContext |
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 sys | |
| import pydevd | |
| from awsglue.transforms import * | |
| from awsglue.utils import getResolvedOptions | |
| from pyspark.context import SparkContext | |
| from awsglue.context import GlueContext | |
| from awsglue.dynamicframe import DynamicFrame | |
| from pyspark.sql.functions import col | |
| from awsglue.job import Job |