I'm trying to run a job flow using AmazonElasticMapReduce and I'm receiving the following error:
Exception in thread "main" com.amazonaws.services.elasticmapreduce.model.AmazonElasticMapReduceException:
The supplied ami version is invalid.
(Service: AmazonElasticMapReduce; Status Code: 400; Error Code: ValidationException; Request ID:
9e5d5d67-cc98-4002-989e-a0df55517d62)
Here is my code:
public static void main(String[] args) throws Exception {
AmazonElasticMapReduce mapReduce = new AmazonElasticMapReduceClient();
HadoopJarStepConfig hadoopJarStep = new HadoopJarStepConfig()
.withJar("s3n://bucket/jar")
.withMainClass("some.pack.MainClass")
.withArgs("s3n://bucket/input/", "s3n://bucket/output/");
StepConfig stepConfig = new StepConfig()
.withName("stepname")
.withHadoopJarStep(hadoopJarStep)
.withActionOnFailure("TERMINATE_JOB_FLOW");
JobFlowInstancesConfig instances = new JobFlowInstancesConfig()
.withInstanceCount(2)
.withMasterInstanceType(InstanceType.M1_SMALL.toString())
.withSlaveInstanceType(InstanceType.M1_SMALL.toString())
.withHadoopVersion("2.6.0").withEc2KeyName("mykey")
.withKeepJobFlowAliveWhenNoSteps(false)
.withPlacement(new PlacementType("us-east-1a"));
RunJobFlowRequest runFlowRequest = new RunJobFlowRequest()
.withName("jobname")
.withInstances(instances)
.withSteps(stepConfig)
.withLogUri("s3n://bucket/logs/");
runFlowRequest.setServiceRole("EMR_DefaultRole");
runFlowRequest.setJobFlowRole("EMR_EC2_DefaultRole");
RunJobFlowResult runJobFlowResult = mapReduce.runJobFlow(runFlowRequest);
String jobFlowId = runJobFlowResult.getJobFlowId();
System.out.println("Ran job flow with id: " + jobFlowId);
}
I tried adding .withAmiVersion()
to RunJobFlowRequest
with different ami versions but that didn't help.
I solved it by adding .withReleaseLabel("emr-4.0.0")
to RunJobFlowRequest
.
I found which emr release version compatible with my Hadoop version here:
https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-release-components.html