How to ensure that all EMR core nodes contain a keystore file at all times?

Viewed 356

I need all the core nodes on an EMR to contain a keystore file in the /usr/local/spark/conf/ directory. This particularly becomes challenging when core node resizing goes on because any newly brought up core node will not have the keystore file and won't even have the /usr/local/spark/conf/ directory. I need to automate the process of populating this directory with the keystore file on any newly brought up core node.

I've created a shell script to create the /usr/local/spark/conf directory and then populate that with the keystore file by fetching it from Amazon S3. The problem is getting this shell script to automatically run on any newly brought up EMR core node.

mkdir -p /usr/local/spark/conf/
cd /usr/local/spark/conf/
aws s3 cp s3://my_bucket/certs/cacerts .
aws s3 cp s3://my_bucket/certs/keystore.jks .
1 Answers

Yes, you can use the bootstrap action feature, to run a predefined script from S3:

You can use a bootstrap action to install additional software or customize the configuration of cluster instances. Bootstrap actions are scripts that run on cluster after Amazon EMR launches the instance using the Amazon Linux Amazon Machine Image (AMI). Bootstrap actions run before Amazon EMR installs the applications that you specify when you create the cluster and before cluster nodes begin processing data. If you add nodes to a running cluster, bootstrap actions also run on those nodes in the same way. You can create custom bootstrap actions and specify them when you create your cluster.

See https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-plan-bootstrap.html

Related