Skip to content

Placeholders

Harshad Ranganathan edited this page Jan 21, 2020 · 5 revisions

Each application has a varying set of arguments. To accommodate this, the applications can define the yaml config with placeholders and supply the values as input variables when invoking the EMR Launcher script.

Consider below example where we have defined a config with placeholders:

Emr:
  Name: &EmrName '${ENVIRONMENT}-data-loading-cluster'
  Steps:
    - Name: Spark Application
      ActionOnFailure: *ContinueCluster
      Args: [spark-submit,
            --deploy-mode, cluster,
            --class, com.example,
            --driver-java-options,
            '-Dconfig.resource=/config/${ENVIRONMENT}.conf',
            's3://elasticmapreduce/amiroller/AWSJavaClientRuntime-${VERSION}.jar']

where the placeholders defined are ENVIRONMENT & VERSION.

Note: Placeholder names must match regex ${([A-Z_0-9]*)}

When invoking the script, you will have to pass the placeholder values as a dict:

{
    'ENVIRONMENT': 'prod',
    'VERSION': '1.0'
}

The script will substitute the placeholders in the configuration files with the input values and will launch the EMR cluster.

Note: All the input variable values must be of type str. Based on the placeholder definition in yaml files they will be treated as string or integer.

e.g.

BidPrice: ${BID_PRICE} 

Here, the value will be substituted as-is. If the placeholder value is a number then it will be treated as an integer otherwise a string

BidPrice: '${BID_PRICE}' 

Here, we explicitly define the value as a string by surrounding the placeholder within single quotes. So, even if the placeholder value is an integer it will be treated as a string.

Runtime Placeholders

Apart from the custom placeholders that you define, below runtime placeholders are also available. Values for these placeholders will be substituted in the configuration files based on the information that's available at that point of time.

Placeholder Name Description
REGION Region for which the cluster is being created
Clone this wiki locally