Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
be55095
Edited files
Aug 11, 2020
1a385d7
Edited files
Aug 11, 2020
c31c95f
Edited files
Aug 11, 2020
219cdd1
Edited files
Aug 11, 2020
6bcc212
Edited file 'python-clusters/emr-create-cluster/cluster.py'
Aug 11, 2020
72f1cb4
Edited files
Aug 11, 2020
739fc46
Edited files
Aug 11, 2020
67f8892
Edited files
Aug 11, 2020
7ccb3ed
Edited file 'python-clusters/emr-create-cluster/cluster.json'
Aug 11, 2020
3b70741
Edited files
Aug 11, 2020
f10522b
Update plugin.json
xaaaaav Nov 5, 2020
e9269b3
Edited file 'python-clusters/emr-create-cluster/cluster.json'
Nov 5, 2020
82961e2
Edited file 'python-clusters/emr-create-cluster/cluster.py'
Nov 5, 2020
1789794
Edited file 'python-clusters/emr-create-cluster/cluster.py'
Nov 5, 2020
9ea68bb
Edited file 'python-clusters/emr-create-cluster/cluster.py'
Nov 5, 2020
60adb82
Edited file 'python-clusters/emr-create-cluster/cluster.py'
Nov 5, 2020
8faa065
Edited file 'python-clusters/emr-create-cluster/cluster.json'
Nov 6, 2020
a254200
Edited file 'python-clusters/emr-create-cluster/cluster.json'
Nov 6, 2020
ca7b6f4
Edited file 'python-clusters/emr-create-cluster/cluster.json'
Nov 6, 2020
947378f
Edited file 'python-clusters/emr-create-cluster/cluster.json'
Nov 6, 2020
f5323cf
Edited file 'python-clusters/emr-create-cluster/cluster.py'
Jan 8, 2021
ecabe39
Edited file 'python-clusters/emr-create-cluster/cluster.py'
Jan 8, 2021
7f9b275
Edited file 'python-clusters/emr-create-cluster/cluster.py'
Jan 8, 2021
fed408e
Edited file 'python-clusters/emr-create-cluster/cluster.py'
Jan 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "emr-clusters",
"version": "0.0.2",
"version": "0.0.3",
"meta": {
"label": "EMR clusters",
"description": "Dynamically create Amazon EMR clusters or attach to existing ones.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"name": "secretKey",
"label": "AWS Secret Key",
"description": "If empty, uses AWS credentials from the environment (IAM role, ~/.aws/credentials or AWS_ACCESS_KEY_ID environment variable)",
"type": "STRING",
"type": "PASSWORD",
"visibilityCondition": "!model.useRole"
},
{
Expand Down
43 changes: 41 additions & 2 deletions python-clusters/emr-create-cluster/cluster.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@
"label" : "Instance count (core)",
"defaultValue" : 2
},
{
"name": "enableCoreAutoScaling",
"type": "BOOLEAN",
"label": "Enable Core Node Autoscaling",
"defaultValue": false
},
{
"name": "coreNodeAutoScalingPolicy",
"type": "TEXTAREA",
"label": "Core Node Autoscaling Policy",
"description": "Use JSON format, see here: https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-automatic-scaling.html",
"visibilityCondition": "model.enableCoreAutoScaling"
},
{
"name": "taskInstanceType",
"label" : "Instance type (task)",
Expand All @@ -56,6 +69,19 @@
"label" : "Instance count (task)",
"defaultValue" : 0
},
{
"name": "enableTaskAutoScaling",
"type": "BOOLEAN",
"label": "Enable Task Node Autoscaling",
"defaultValue": false
},
{
"name": "taskNodeAutoScalingPolicy",
"type": "TEXTAREA",
"label": "Task Node Autoscaling Policy",
"description": "Use JSON format, see here: https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-automatic-scaling.html",
"visibilityCondition": "model.enableTaskAutoScaling"
},
{
"name": "emrVersion",
"label" : "EMR Version",
Expand Down Expand Up @@ -121,7 +147,14 @@
"description" : "IAM role to attach to the nodes of the cluster. Needs to have ability to call required AWS services from the cluster, like S3",
"mandatory" : true
},

{
"name": "autoScalingRole",
"label": "Autoscaling Role",
"type": "STRING",
"description": "IAM role with permissions to add and terminate instances when scaling activities are triggered",
"defaultValue": "EMR_AutoScaling_DefaultRole",
"mandatory" : true
},
{
"type" : "SEPARATOR",
"label": "Hive Metastore"
Expand Down Expand Up @@ -248,14 +281,20 @@
"name": "secretKey",
"label": "AWS Secret Key",
"description": "If empty, uses AWS credentials from the environment (IAM role, ~/.aws/credentials or AWS_ACCESS_KEY_ID environment variable)",
"type": "STRING",
"type": "PASSWORD",
"visibilityCondition": "!model.useRole"
},
{
"name": "securityConfig",
"label": "EMR Security Configuration",
"type": "STRING",
"description": "EMR Security Configuration to use, must already exist"
},
{
"name": "bootstrapActions",
"label": "EMR Bootstrap Actions",
"type": "KEY_VALUE_LIST",
"description": "Key should be S3 path (s3://path/to/file) and value should be comma separated list of args: arg1,arg2,arg3, if needed"
}
],

Expand Down
43 changes: 39 additions & 4 deletions python-clusters/emr-create-cluster/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ def start(self):
extraArgs["SecurityConfiguration"] = self.config["securityConfiguration"]
if self.config.get("ebsRootVolumeSize", 0):
extraArgs["EbsRootVolumeSize"] = int(self.config["ebsRootVolumeSize"])
if "bootstrapActions" in self.config:
extraArgs["BootstrapActions"] = []

for idx, ba in enumerate(self.config["bootstrapActions"]):
if len(ba["to"]) > 0:
args = ba["to"].split(",")
else:
args = []
config = {
"Name": "action_{}".format(idx),
"ScriptBootstrapAction": {
"Path": ba["from"],
"Args": args
}
}
extraArgs["BootstrapActions"].append(config)

security_groups = []
if "additionalSecurityGroups" in self.config:
Expand All @@ -53,20 +69,38 @@ def start(self):
if self.config.get("coreInstanceCount"):
if not self.config.get("coreInstanceType"):
raise Exception("Missing core instance type")
instances['InstanceGroups'].append({
instance_group = {
'InstanceRole': 'CORE',
'InstanceType': self.config["coreInstanceType"],
'InstanceCount': int(self.config["coreInstanceCount"])
})
}

if self.config.get("enableCoreAutoScaling"):
core_node_policy = json.loads(self.config.get("coreNodeAutoScalingPolicy"))

for rule in core_node_policy["Rules"]:
rule["Trigger"]["CloudWatchAlarmDefinition"]["Dimensions"] = [{"Key": "JobFlowId", "Value": "${emr.clusterId}"}]
instance_group["AutoScalingPolicy"] = core_node_policy

instances['InstanceGroups'].append(instance_group)

if self.config.get("taskInstanceCount"):
if not self.config.get("taskInstanceType"):
raise Exception("Missing task instance type")
instances['InstanceGroups'].append({
instance_group = {
'InstanceRole': 'TASK',
'InstanceType': self.config["taskInstanceType"],
'InstanceCount': int(self.config["taskInstanceCount"])
})
}

if self.config.get("enableTaskAutoScaling"):
task_node_policy = json.loads(self.config.get("taskNodeAutoScalingPolicy"))

for rule in task_node_policy["Rules"]:
rule["Trigger"]["CloudWatchAlarmDefinition"]["Dimensions"] = [{"Key": "JobFlowId", "Value": "${emr.clusterId}"}]
instance_group["AutoScalingPolicy"] = task_node_policy

instances['InstanceGroups'].append(instance_group)

if self.config.get("securityConfig"):
extraArgs["SecurityConfiguration"] = self.config.get("securityConfig")
Expand Down Expand Up @@ -145,6 +179,7 @@ def start(self):
VisibleToAllUsers=True,
JobFlowRole=self.config["nodesRole"],
ServiceRole=self.config["serviceRole"],
AutoScalingRole=self.config["autoScalingRole"],
Tags=tags,
**extraArgs
)
Expand Down