Question

I have a bootstrap script which runs with my EMR job. I need to pass a parameter to this script so I can configure a path for different environments The following line in my script needs to use it path=OVA/{EnvironmentName}/Scripts/UniqueUsers

I am using C# to invoke a streaming EMR job. how do I pass this argument while I create the job?

  HadoopJarStepConfig config = new StreamingStep()
                .WithInputs(input)
                .WithOutput(output)
                .WithMapper(configMapperLocation)
                .WithReducer(configReducerLocation)
                .ToHadoopJarStepConfig();

            string configName = string.Format("Unique_Users_config_{0}", outputFolder);
            StepConfig uniqueUsersDaily = new StepConfig()
                .WithName(configName)
                .WithActionOnFailure("TERMINATE_JOB_FLOW")
                .WithHadoopJarStep(config);

            ScriptBootstrapActionConfig bootstrapActionScript = new ScriptBootstrapActionConfig()
                .WithPath(configBootStrapScriptLocation);

            BootstrapActionConfig bootstrapAction = new BootstrapActionConfig()
                .WithName("CustomAction")
                .WithScriptBootstrapAction(bootstrapActionScript);

            string jobName = string.Format("Unique_User_DailyJob_{0}", outputFolder);
            RunJobFlowRequest jobRequest = new RunJobFlowRequest()
                .WithName(jobName)
                .WithBootstrapActions(bootstrapAction)
                .WithSteps(uniqueUsersDaily)
                .WithLogUri(configHadoopLogLocation)
                .WithInstances(new JobFlowInstancesConfig()
                                   .WithHadoopVersion(configHadoopVersion)
                                   .WithInstanceCount(2)
                                   .WithKeepJobFlowAliveWhenNoSteps(false)
                                   .WithMasterInstanceType(configMasterInstanceType)
                                   .WithSlaveInstanceType(configSlaveInstanceType));
Was it helpful?

Solution

You can use withArgs() of ScriptBootstrapActionConfig, in Java you can do as follows, I am sure there is a similar method for C#:

 ScriptBootstrapActionConfig bootstrapActionScript = new ScriptBootstrapActionConfig()
                .WithPath(configBootStrapScriptLocation)
                .WithArgs(List<String> args);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top