# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: emr_create_cluster
description: |
  Creates an Elastic Map Reduce (EMR) cluster in sepcific region.
inputs:
  - {name: region,          description: 'The EMR region in which to handle the request.'}
  - {name: name,            description: 'The EMR cluster name. Cluster names within a region must be unique. Names of deleted clusters can be reused'}
  - {name: release_label,   description: 'The EMR version.', default: 'emr-5.23.0'}
  - {name: log_s3_uri,      description: 'The path to the Amazon S3 location where logs for this cluster are stored.'}
  - {name: instance_type,   description: 'The EC2 instance type of master, the core and task nodes.', default: 'm4.xlarge'}
  - {name: instance_count,  description: 'The number of EC2 instances in the cluster.', default: '3'}
outputs:
  - {name: cluster_name,    description: 'The cluster name of the created cluster.'}
implementation:
  container:
    image: seedjeffwan/kubeflow-pipeline-aws-emr:20190507
    command: ['python', 'create_cluster.py']
    args: [
      --region, {inputValue: region},
      --name, {inputValue: name},
      --release_label, {inputValue: release_label},
      --log_s3_uri, {inputValue: log_s3_uri},
      --instance_type, {inputValue: instance_type},
      --instance_count, {inputValue: instance_count}
    ]
    fileOutputs:
      cluster_name: /output.txt