I am trying to run a bash script as a step after EMR completes bootstrapping. Following is my terraform code:
step { action_on_failure = "CONTINUE"
name = "Setup Hadoop configuration"
hadoop_jar_step {
jar = "command-runner.jar"
args = ["bash,-c,'cd /mnt; chmod +x ./userdata.sh; ./userdata.sh'"]
}}
This isn't working and keeps on failing mentioning that No file found. Are args correctly provided ? What about script-runner.jar? Any help is highly appreciated. :(
Submit a custom JAR step to run a script or commandjar on Amazon EMR. When you use command-runner. jar , you specify commands, options, and values in your step's list of arguments. The following AWS CLI example submits a step to a running cluster that invokes command-runner.
Choose File, New, and Other. In the Select a wizard dialog, choose AWS Java Project and Next. In the New AWS Java Project dialog, in the Project name: field, enter the name of your new project, for example EMR-sample-code . Choose Configure AWS accounts…, enter your public and private access keys, and choose Finish.
With command-runner.jar
you can execute many programs like bash script,
and you do not have to know its full path as was the case with script-runner.jar
. It is recommended to use command-runner.jar
.
EMR is in cluster mode, you do not know which nodes execute the shell script, so push it to S3 :
{ "Name": "Setup Hadoop configuration", "ActionOnFailure": "CONTINUE", "HadoopJarStep": { "Jar": "command-runner.jar", "Args": [ "bash", "-c", " aws s3 cp s3://path_to_bucket_S3/userdata.sh .; chmod +x userdata.sh; ./userdata.sh args...; rm userdata.sh " ] } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With