title: boto EMR add step and auto terminate
body: <p>Python 2.7.12</p>
  
  <p>boto3==1.3.1</p>
  
  <p>How can I add a step to a running EMR cluster <em>and</em> have the cluster terminated after the step is complete, regardless of it fails or succeeds?</p>
  
  <p><strong>Create the cluster</strong></p>
  
  <pre><code>response = client.run_job_flow(
      Name=name,
      LogUri='s3://mybucket/emr/',
      ReleaseLabel='emr-5.9.0',
      Instances={
          'MasterInstanceType': instance_type,
          'SlaveInstanceType': instance_type,
          'InstanceCount': instance_count,
          'KeepJobFlowAliveWhenNoSteps': True,
          'Ec2KeyName': 'KeyPair',
          'EmrManagedSlaveSecurityGroup': 'sg-1234',
          'EmrManagedMasterSecurityGroup': 'sg-1234',
          'Ec2SubnetId': 'subnet-1q234',
      },
      Applications=[
          {'Name': 'Spark'},
          {'Name': 'Hadoop'}
      ],
      BootstrapActions=[
          {
              'Name': 'Install Python packages',
              'ScriptBootstrapAction': {
                  'Path': 's3://mybucket/code/spark/bootstrap_spark_cluster.sh'
              }
          }
      ],
      VisibleToAllUsers=True,
      JobFlowRole='EMR_EC2_DefaultRole',
      ServiceRole='EMR_DefaultRole',
      Configurations=[
          {
              'Classification': 'spark',
              'Properties': {
                  'maximizeResourceAllocation': 'true'
              }
          },
      ],
  )
  </code></pre>
  
  <p><strong>Add a step</strong></p>
  
  <pre><code>response = client.add_job_flow_steps(
      JobFlowId=cluster_id,
      Steps=[
          {
              'Name': 'Run Step',
              'ActionOnFailure': 'TERMINATE_CLUSTER',
              'HadoopJarStep': {
                  'Args': [
                      'spark-submit',
                      '--deploy-mode', 'cluster',
                      '--py-files',
                      's3://mybucket/code/spark/spark_udfs.py',
                      's3://mybucket/code/spark/{}'.format(spark_script),
                      '--some-arg'
                  ],
                  'Jar': 'command-runner.jar'
              }
          }
      ]
  )
  </code></pre>
  
  <p>This successfully adds a step and runs, however, when the step completes successfully, I would like the cluster to auto-terminate as noted in the AWS CLI: <a href="http://docs.aws.amazon.com/cli/latest/reference/emr/create-cluster.html" rel="noreferrer">http://docs.aws.amazon.com/cli/latest/reference/emr/create-cluster.html</a></p>