Skip to content

Commit

Permalink
Merge commit '43c7def09a6ce05753a4fd8a54da7ee98128554b' into stage-re…
Browse files Browse the repository at this point in the history
…lease-develop

* commit '43c7def09a6ce05753a4fd8a54da7ee98128554b':
  Update EMR add-steps API to accept ExecutionRoleArn
  • Loading branch information
aws-sdk-python-automation committed Jun 30, 2022
2 parents 9d4cc92 + 43c7def commit ce14b7b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
7 changes: 7 additions & 0 deletions awscli/customizations/emr/addsteps.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class AddSteps(Command):
'nargs': '+',
'schema': argumentschema.STEPS_SCHEMA,
'help_text': helptext.STEPS
},
{'name': 'execution-role-arn',
'required': False,
'help_text': helptext.EXECUTION_ROLE_ARN
}
]

Expand All @@ -48,6 +52,9 @@ def _run_main_command(self, parsed_args, parsed_globals):
'Steps': step_list
}

if parsed_args.execution_role_arn is not None:
parameters['ExecutionRoleArn'] = parsed_args.execution_role_arn

emrutils.call_and_display_response(self._session, 'AddJobFlowSteps',
parameters, parsed_globals)
return 0
6 changes: 6 additions & 0 deletions awscli/customizations/emr/helptext.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,3 +506,9 @@
'The configuration specifies the termination idle timeout'
'threshold for an cluster.</p> '
)

EXECUTION_ROLE_ARN = (
'<p>You must grant the execution role the permissions needed '
'to access the same IAM resources that the step can access. '
'The execution role can be a cross-account IAM Role.</p> '
)
21 changes: 21 additions & 0 deletions tests/unit/customizations/emr/test_add_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,27 @@ def test_streaming_step_with_default_fields(self):
cmd=cmd, expected_result=expected_result,
expected_result_release=expected_result_release)

def test_step_with_execution_role_arn(self):
cmd = self.prefix + 'Type=Streaming,' + self.STREAMING_ARGS
cmd += ' --execution-role-arn arn:aws:iam::123456789010:role/sample '
expected_result = {
'ExecutionRoleArn': 'arn:aws:iam::123456789010:role/sample',
'JobFlowId': 'j-ABC',
'Steps': [
{'Name': 'Streaming program',
'ActionOnFailure': 'CONTINUE',
'HadoopJarStep': self.STREAMING_HADOOP_SCRIPT_RUNNER_STEP
}
]
}
expected_result_release = copy.deepcopy(expected_result)
expected_result_release['Steps'][0]['HadoopJarStep'] = \
self.STREAMING_HADOOP_COMMAND_RUNNER_STEP

self.assert_params_for_ami_and_release_based_clusters(
cmd=cmd, expected_result=expected_result,
expected_result_release=expected_result_release)

def test_streaming_step_missing_args(self):
cmd = self.prefix + 'Type=Streaming'
expected_error_msg = '\naws: error: The following ' + \
Expand Down

0 comments on commit ce14b7b

Please sign in to comment.