From 25422ba39c1e2db5130aa940a0110a7574aea5f4 Mon Sep 17 00:00:00 2001 From: Austin Drenski Date: Tue, 7 May 2024 14:53:02 -0400 Subject: [PATCH 1/2] Avoid creating no-op service discovery entries Skipping these can reduce the number of resources in CF templates for simple deployments by ~20% which is useful given the CF limit of 500 resources per (non-nested) stack. --- ecs/cloudformation.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ecs/cloudformation.go b/ecs/cloudformation.go index 774724a9b..7ae734782 100644 --- a/ecs/cloudformation.go +++ b/ecs/cloudformation.go @@ -191,9 +191,6 @@ func (b *ecsAPIService) createService(project *types.Project, service types.Serv taskDefinition := fmt.Sprintf("%sTaskDefinition", normalizeResourceName(service.Name)) template.Resources[taskDefinition] = definition - var healthCheck *cloudmap.Service_HealthCheckConfig - serviceRegistry := b.createServiceRegistry(service, template, healthCheck) - var ( dependsOn []string serviceLB []ecs.Service_LoadBalancer @@ -269,7 +266,7 @@ func (b *ecsAPIService) createService(project *types.Project, service types.Serv PlatformVersion: platformVersion, PropagateTags: ecsapi.PropagateTagsService, SchedulingStrategy: ecsapi.SchedulingStrategyReplica, - ServiceRegistries: []ecs.Service_ServiceRegistry{serviceRegistry}, + ServiceRegistries: b.createServiceRegistries(service, template), Tags: serviceTags(project, service), TaskDefinition: cloudformation.Ref(normalizeResourceName(taskDefinition)), } @@ -414,7 +411,11 @@ func (b *ecsAPIService) createTargetGroup(project *types.Project, service types. return targetGroupName } -func (b *ecsAPIService) createServiceRegistry(service types.ServiceConfig, template *cloudformation.Template, healthCheck *cloudmap.Service_HealthCheckConfig) ecs.Service_ServiceRegistry { +func (b *ecsAPIService) createServiceRegistries(service types.ServiceConfig, template *cloudformation.Template) []ecs.Service_ServiceRegistry { + if len(service.Ports) == 0 { + return []ecs.Service_ServiceRegistry{} + } + serviceRegistration := fmt.Sprintf("%sServiceDiscoveryEntry", normalizeResourceName(service.Name)) serviceRegistry := ecs.Service_ServiceRegistry{ RegistryArn: cloudformation.GetAtt(serviceRegistration, "Arn"), @@ -422,7 +423,7 @@ func (b *ecsAPIService) createServiceRegistry(service types.ServiceConfig, templ template.Resources[serviceRegistration] = &cloudmap.Service{ Description: fmt.Sprintf("%q service discovery entry in Cloud Map", service.Name), - HealthCheckConfig: healthCheck, + HealthCheckConfig: nil, HealthCheckCustomConfig: &cloudmap.Service_HealthCheckCustomConfig{ FailureThreshold: 1, }, @@ -438,7 +439,7 @@ func (b *ecsAPIService) createServiceRegistry(service types.ServiceConfig, templ RoutingPolicy: cloudmapapi.RoutingPolicyMultivalue, }, } - return serviceRegistry + return []ecs.Service_ServiceRegistry{serviceRegistry} } func (b *ecsAPIService) createTaskExecutionRole(project *types.Project, service types.ServiceConfig, template *cloudformation.Template) string { From 2b30b118c5002216afc593cba24b7aadb747caaa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 May 2024 19:07:15 +0000 Subject: [PATCH 2/2] build(deps): bump google.golang.org/protobuf from 1.28.1 to 1.33.0 Bumps google.golang.org/protobuf from 1.28.1 to 1.33.0. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a048042e6..98e8a87a5 100644 --- a/go.mod +++ b/go.mod @@ -53,7 +53,7 @@ require ( golang.org/x/sync v0.1.0 golang.org/x/sys v0.4.0 google.golang.org/grpc v1.52.3 - google.golang.org/protobuf v1.28.1 + google.golang.org/protobuf v1.33.0 gopkg.in/ini.v1 v1.67.0 gopkg.in/yaml.v3 v3.0.1 gotest.tools/v3 v3.4.0 diff --git a/go.sum b/go.sum index ef01314c7..13c943997 100644 --- a/go.sum +++ b/go.sum @@ -1889,8 +1889,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=