I have an EMR PySpark job which needs to access an s3 bucket owned by 3rd party.
The PySpark job is stored on s3://mybucket/job.py
and submitted as a step
{
"Name": "Process promo_regs",
"ActionOnFailure": "TERMINATE_CLUSTER",
"HadoopJarStep": {
"Jar": "command-runner.jar",
"Args": ["spark-submit", "--master", "yarn", "--deploy-mode cluster", "s3://mybucket.job.py"],
}
}
In the job.py
I configure a boto3 s3 client.
from pyspark.sql import SparkSession
import boto3
# How to inject this?
env = {
'AWS_ACCESS_KEY_ID': '',
'#AWS_SECRET_ACCESS_KEY': '',
'AWS_REGION_NAME': ''
}
s3 = boto3.client(
's3',
aws_access_key_id=env['AWS_ACCESS_KEY_ID'],
aws_secret_access_key=env['#AWS_SECRET_ACCESS_KEY'],
region_name=env['AWS_REGION_NAME'],
spark = (SparkSession
.builder
.appName("Test processing dummy data")
.getOrCreate())
What are my options of securely injecting the access keys into the script?
I am starting the cluster and submitting the job using boto3.client('emr').run_job_flow()
if that matters