From 6de47cadbd60a63608337829ea5265bb615ce82b Mon Sep 17 00:00:00 2001 From: Pronomita Dey Date: Mon, 22 Apr 2024 15:42:48 +0530 Subject: [PATCH 1/2] propagating tags from service to tasks --- .../deployment/service_template_generator.py | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/cloudlift/deployment/service_template_generator.py b/cloudlift/deployment/service_template_generator.py index 474accfd..be061faa 100644 --- a/cloudlift/deployment/service_template_generator.py +++ b/cloudlift/deployment/service_template_generator.py @@ -345,7 +345,7 @@ def _add_service(self, service_name, config): ContainerDefinitions=[cd] + sidecar_container_defs, ExecutionRoleArn=boto3.resource('iam').Role('ecsTaskExecutionRole').arn, TaskRoleArn=Ref(task_role), - Tags=Tags(Team=self.team_name, environment=self.env), + Tags=Tags(Team=self.team_name, environment=self.env, ServiceName=service_name), **launch_type_td ) if 'custom_metrics' in config: @@ -400,7 +400,7 @@ def _add_service(self, service_name, config): }], VpcId=Ref(self.vpc), GroupDescription=pascalcase("FargateService" + self.env + service_name), - Tags=Tags(Team=self.team_name, environment=self.env) + Tags=Tags(Team=self.team_name, environment=self.env, ServiceName=service_name) ) self.template.add_resource(service_security_group) @@ -452,7 +452,9 @@ def _add_service(self, service_name, config): DependsOn=service_listener.title, LaunchType=launch_type, **launch_type_svc, - Tags=Tags(Team=self.team_name, environment=self.env), + Tags=Tags(Team=self.team_name, environment=self.env, ServiceName=service_name), + PropagateTags='SERVICE', + EnableECSManagedTags=True, **placement_constraint ) self.template.add_output( @@ -502,7 +504,7 @@ def _add_service(self, service_name, config): SecurityGroupIngress=[], VpcId=Ref(self.vpc), GroupDescription=pascalcase("FargateService" + self.env + service_name), - Tags=Tags(Team=self.team_name, environment=self.env) + Tags=Tags(Team=self.team_name, environment=self.env,ServiceName=service_name) ) self.template.add_resource(service_security_group) launch_type_svc = { @@ -552,7 +554,7 @@ def _add_service(self, service_name, config): DeploymentConfiguration=deployment_configuration, LaunchType=launch_type, **launch_type_svc, - Tags=Tags(Team=self.team_name, environment=self.env), + Tags=Tags(Team=self.team_name, environment=self.env, ServiceName=service_name), **placement_constraint ) self.template.add_output( @@ -602,7 +604,7 @@ def _add_alb(self, cd, service_name, config, launch_type): ), VpcId=Ref(self.vpc), GroupDescription=Sub(service_name + "-alb-sg"), - Tags=Tags(Team=self.team_name, environment=self.env) + Tags=Tags(Team=self.team_name, environment=self.env, ServiceName=service_name) ) self.template.add_resource(svc_alb_sg) alb_name = service_name + pascalcase(self.env) @@ -629,7 +631,8 @@ def _add_alb(self, cd, service_name, config, launch_type): Tags=[ {'Value': alb_name, 'Key': 'Name'}, {"Key": "Team", "Value": self.team_name}, - {'Key': 'environment', 'Value': self.env} + {'Key': 'environment', 'Value': self.env}, + {'Key': 'ServiceName', 'Value': service_name} ], Scheme=scheme ) @@ -651,7 +654,8 @@ def _add_alb(self, cd, service_name, config, launch_type): Tags=[ {'Value': alb_name, 'Key': 'Name'}, {"Key": "Team", "Value": self.team_name}, - {'Key': 'environment', 'Value': self.env} + {'Key': 'environment', 'Value': self.env}, + {'Key': 'ServiceName', 'Value': service_name} ] ) @@ -686,7 +690,8 @@ def _add_alb(self, cd, service_name, config, launch_type): **target_group_config, Tags=[ {"Key": "Team", "Value": self.team_name}, - {'Key': 'environment', 'Value': self.env} + {'Key': 'environment', 'Value': self.env}, + {'Key': 'ServiceName', 'Value': service_name} ] ) From 490159e53e68c7a98412afa939eeb87a3385d819 Mon Sep 17 00:00:00 2001 From: Pronomita Dey Date: Mon, 22 Apr 2024 15:45:43 +0530 Subject: [PATCH 2/2] minor version updated --- cloudlift/version/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudlift/version/__init__.py b/cloudlift/version/__init__.py index fa8968b1..f1f5a0ea 100644 --- a/cloudlift/version/__init__.py +++ b/cloudlift/version/__init__.py @@ -1 +1 @@ -VERSION = '2.0.5' +VERSION = '2.0.6'