Skip to content

Commit

Permalink
Add support for EBS volume configuration in EMR resources (#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
A. Alonso Dominguez authored and markpeek committed Apr 14, 2016
1 parent 0288add commit 12ab349
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
14 changes: 13 additions & 1 deletion examples/EMR_Cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
cluster = template.add_resource(emr.Cluster(
"EMRSampleCluster",
Name="EMR Sample Cluster",
ReleaseLabel='emr-4.3.0',
ReleaseLabel='emr-4.4.0',
BootstrapActions=[emr.BootstrapActionConfig(
Name='Dummy bootstrap action',
ScriptBootstrapAction=emr.ScriptBootstrapActionConfig(
Expand Down Expand Up @@ -122,6 +122,18 @@
]
)
],
EbsConfiguration=emr.EbsConfiguration(
EbsBlockDeviceConfig=[
emr.EbsBlockDeviceConfig(
VolumeSpecification=emr.VolumeSpecification(
SizeInGB="100",
VolumeType="standard"
),
VolumesPerInstance="1"
)
],
EbsOptimized="true"
),
JobFlowRole=Ref(emr_instance_profile),
ServiceRole=Ref(emr_service_role),
Instances=emr.JobFlowInstancesConfig(
Expand Down
14 changes: 13 additions & 1 deletion tests/examples_output/EMR_Cluster.template
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@
]
}
],
"EbsConfiguration": {
"EbsBlockDeviceConfig": [
{
"VolumeSpecification": {
"SizeInGB": "100",
"VolumeType": "standard"
},
"VolumesPerInstance": "1"
}
],
"EbsOptimized": "true"
},
"Instances": {
"CoreInstanceGroup": {
"BidPrice": "20",
Expand All @@ -134,7 +146,7 @@
"Ref": "EMRInstanceProfile"
},
"Name": "EMR Sample Cluster",
"ReleaseLabel": "emr-4.3.0",
"ReleaseLabel": "emr-4.4.0",
"ServiceRole": {
"Ref": "EMRServiceRole"
},
Expand Down
32 changes: 32 additions & 0 deletions troposphere/emr.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,36 @@ class JobFlowInstancesConfig(AWSProperty):
}


def volume_type_validator(x):
valid_values = ['standard', 'io1']
if x not in valid_values:
raise ValueError("VolumeType must be one of: %s" %
', '.join(valid_values))
return x


class VolumeSpecification(AWSProperty):
props = {
'Iops': (integer, False),
'SizeInGB': (integer, True),
'VolumeType': (volume_type_validator, True)
}


class EbsBlockDeviceConfig(AWSProperty):
props = {
'VolumeSpecification': (VolumeSpecification, True),
'VolumesPerInstance': (integer, False)
}


class EbsConfiguration(AWSProperty):
props = {
'EbsBlockDeviceConfig': ([EbsBlockDeviceConfig], False),
'EbsOptimized': (boolean, False)
}


class Cluster(AWSObject):
resource_type = "AWS::EMR::Cluster"

Expand All @@ -133,6 +163,7 @@ class Cluster(AWSObject):
'Applications': ([Application], False),
'BootstrapActions': ([BootstrapActionConfig], False),
'Configurations': (configurations_validator, False),
'EbsConfiguration': (EbsConfiguration, False),
'Instances': (JobFlowInstancesConfig, True),
'JobFlowRole': (basestring, True),
'LogUri': (basestring, False),
Expand All @@ -150,6 +181,7 @@ class InstanceGroupConfig(AWSObject):
props = {
'BidPrice': (basestring, False),
'Configurations': (configurations_validator, False),
'EbsConfiguration': (EbsConfiguration, False),
'InstanceCount': (integer, True),
'InstanceRole': (basestring, True),
'InstanceType': (basestring, True),
Expand Down

0 comments on commit 12ab349

Please sign in to comment.