Created
August 8, 2018 23:31
-
-
Save danielchalef/0ba909a782e0c69d20fba339903ee668 to your computer and use it in GitHub Desktop.
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 os | |
import configparser | |
config = configparser.ConfigParser() | |
config.read(os.path.expanduser("~/.aws/credentials")) | |
aws_profile = 'default' # your AWS profile to use | |
aws_region = "us-west-2" | |
access_id = config.get(aws_profile, "aws_access_key_id") | |
access_key = config.get(aws_profile, "aws_secret_access_key") | |
hadoop_conf=spark.sparkContext._jsc.hadoopConfiguration() | |
# see https://stackoverflow.com/questions/43454117/how-do-you-use-s3a-with-spark-2-1-0-on-aws-us-east-2 | |
hadoop_conf.set("fs.s3a.impl", "org.apache.hadoop.fs.s3a.S3AFileSystem") | |
hadoop_conf.set("com.amazonaws.services.s3.enableV4", "true") | |
hadoop_conf.set("fs.s3a.access.key", access_id) | |
hadoop_conf.set("fs.s3a.secret.key", access_key) | |
# see http://blog.encomiabile.it/2015/10/29/apache-spark-amazon-s3-and-apache-mesos/ | |
hadoop_conf.set("fs.s3a.connection.maximum", "100000") | |
# see https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region | |
hadoop_conf.set("fs.s3a.endpoint", "s3." + aws_region + ".amazonaws.com") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment