diff --git a/moto/emr/models.py b/moto/emr/models.py index 1f2459d6c..6f9963df1 100644 --- a/moto/emr/models.py +++ b/moto/emr/models.py @@ -7,7 +7,7 @@ import warnings import pytz from boto3 import Session from dateutil.parser import parse as dtparse -from moto.core import BaseBackend, BaseModel +from moto.core import ACCOUNT_ID, BaseBackend, BaseModel from moto.emr.exceptions import EmrError, InvalidRequestException from .utils import ( random_instance_group_id, @@ -272,6 +272,12 @@ class FakeCluster(BaseModel): ) self.kerberos_attributes = kerberos_attributes + @property + def arn(self): + return "arn:aws:elasticmapreduce:{0}:{1}:cluster/{2}".format( + self.emr_backend.region_name, ACCOUNT_ID, self.id + ) + @property def instance_groups(self): return self.emr_backend.get_instance_groups(self.instance_group_ids) diff --git a/moto/emr/responses.py b/moto/emr/responses.py index 3eaa3b49c..9ef593649 100644 --- a/moto/emr/responses.py +++ b/moto/emr/responses.py @@ -529,13 +529,16 @@ class ElasticMapReduceResponse(BaseResponse): @generate_boto3_response("PutAutoScalingPolicy") def put_auto_scaling_policy(self): cluster_id = self._get_param("ClusterId") + cluster = self.backend.get_cluster(cluster_id) instance_group_id = self._get_param("InstanceGroupId") auto_scaling_policy = self._get_param("AutoScalingPolicy") instance_group = self.backend.put_auto_scaling_policy( instance_group_id, auto_scaling_policy ) template = self.response_template(PUT_AUTO_SCALING_POLICY) - return template.render(cluster_id=cluster_id, instance_group=instance_group) + return template.render( + cluster_id=cluster_id, cluster=cluster, instance_group=instance_group + ) @generate_boto3_response("RemoveAutoScalingPolicy") def remove_auto_scaling_policy(self): @@ -691,6 +694,7 @@ DESCRIBE_CLUSTER_TEMPLATE = """ {{ cluster.id }} + {{ cluster.arn }} 8296d8b8-ed85-11dd-9877-6fad448a8419 @@ -1378,6 +1384,7 @@ PUT_AUTO_SCALING_POLICY = """