From 8644b2ff1d48cc326cbf20dc423289964ea84d68 Mon Sep 17 00:00:00 2001 From: Jessie Nadler Date: Mon, 25 Mar 2019 19:11:06 -0400 Subject: [PATCH 1/2] Add get_cfn_attribute support for ECS Cluster and Service --- moto/ecs/models.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/moto/ecs/models.py b/moto/ecs/models.py index 4a6737ceb..f51493c3f 100644 --- a/moto/ecs/models.py +++ b/moto/ecs/models.py @@ -94,6 +94,12 @@ class Cluster(BaseObject): # no-op when nothing changed between old and new resources return original_resource + def get_cfn_attribute(self, attribute_name): + from moto.cloudformation.exceptions import UnformattedGetAttTemplateException + if attribute_name == 'Arn': + return self.arn + raise UnformattedGetAttTemplateException() + class TaskDefinition(BaseObject): @@ -271,6 +277,12 @@ class Service(BaseObject): else: return ecs_backend.update_service(cluster_name, service_name, task_definition, desired_count) + def get_cfn_attribute(self, attribute_name): + from moto.cloudformation.exceptions import UnformattedGetAttTemplateException + if attribute_name == 'Name': + return self.name + raise UnformattedGetAttTemplateException() + class ContainerInstance(BaseObject): From 497965fadc6f1463da63820dfafd3bee9fd50ffb Mon Sep 17 00:00:00 2001 From: Jessie Nadler Date: Tue, 26 Mar 2019 14:36:31 -0400 Subject: [PATCH 2/2] Return InstanceProfile arn instead of NotImplementedError for get_cfn_attribute --- moto/iam/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moto/iam/models.py b/moto/iam/models.py index 92ac19da7..8937d262d 100644 --- a/moto/iam/models.py +++ b/moto/iam/models.py @@ -213,7 +213,7 @@ class InstanceProfile(BaseModel): def get_cfn_attribute(self, attribute_name): from moto.cloudformation.exceptions import UnformattedGetAttTemplateException if attribute_name == 'Arn': - raise NotImplementedError('"Fn::GetAtt" : [ "{0}" , "Arn" ]"') + return self.arn raise UnformattedGetAttTemplateException()