From aac7a13b4829d532b6ab635f6f1f4f71fbf43e60 Mon Sep 17 00:00:00 2001 From: Hsing-Hui Hsu Date: Thu, 18 Oct 2018 15:37:24 -0700 Subject: [PATCH] Clarify help text for load balancer flags Addresses #359 --- ecs-cli/modules/cli/compose/entity/service/service.go | 9 +++++++-- .../compose/service/compose_service_command.go | 10 +++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ecs-cli/modules/cli/compose/entity/service/service.go b/ecs-cli/modules/cli/compose/entity/service/service.go index b99ae79d2..20bff0e59 100644 --- a/ecs-cli/modules/cli/compose/entity/service/service.go +++ b/ecs-cli/modules/cli/compose/entity/service/service.go @@ -108,8 +108,13 @@ func (s *Service) LoadContext() error { } s.healthCheckGP = healthCheckGP - // Validates LoadBalancerName and TargetGroupArn cannot exist at the same time - // The rest will be taken care off by the API call + // Validates LoadBalancerName and TargetGroupArn cannot exist at the same time. + // Other validation is taken care of by the API call. This currently + // includes errors on absence of container name and port if target + // group or ELB name is specified or if the load balancing resources + // specified do not exist. + // TODO: Add validation on targetGroupArn or loadBalancerName being + // present if containerName or containerPort are specified if role != "" || targetGroupArn != "" || loadBalancerName != "" || containerName != "" || containerPort != nil { if targetGroupArn != "" && loadBalancerName != "" { return errors.Errorf("[--%s] and [--%s] flags cannot both be specified", flags.LoadBalancerNameFlag, flags.TargetGroupArnFlag) diff --git a/ecs-cli/modules/commands/compose/service/compose_service_command.go b/ecs-cli/modules/commands/compose/service/compose_service_command.go index 47a97b174..e0508cbec 100644 --- a/ecs-cli/modules/commands/compose/service/compose_service_command.go +++ b/ecs-cli/modules/commands/compose/service/compose_service_command.go @@ -220,11 +220,11 @@ func deploymentConfigFlags(specifyDefaults bool) []cli.Flag { } func loadBalancerFlags() []cli.Flag { - targetGroupArnUsageString := "[Optional] Specifies the full Amazon Resource Name (ARN) of a previously configured Elastic Load Balancing target group to associate with your service." - containerNameUsageString := "[Optional] Specifies the container name (as it appears in a container definition). This parameter is required if a load balancer or target group is specified." - containerPortUsageString := "[Optional] Specifies the port on the container to associate with the load balancer. This port must correspond to a containerPort in the service's task definition. This parameter is required if a load balancer or target group is specified." - loadBalancerNameUsageString := "[Optional] Specifies the name of a previously configured Elastic Load Balancing load balancer to associate with your service." - roleUsageString := "[Optional] Specifies the name or full Amazon Resource Name (ARN) of the IAM role that allows Amazon ECS to make calls to your load balancer or target group on your behalf. This parameter is required if you are using a load balancer or target group with your service. If you specify the role parameter, you must also specify a load balancer name or target group ARN, along with a container name and container port." + targetGroupArnUsageString := fmt.Sprintf("[Optional] Specifies the full Amazon Resource Name (ARN) of a previously configured target group for an Application Load Balancer or Network Load Balancer to associate with your service. NOTE: For Classic Load Balancers, use the --%s flag.", flags.LoadBalancerNameFlag) + containerNameUsageString := fmt.Sprintf("[Optional] Specifies the container name (as it appears in a container definition). This parameter is required if --%s or --%s is specified.", flags.LoadBalancerNameFlag, flags.TargetGroupArnFlag) + containerPortUsageString := fmt.Sprintf("[Optional] Specifies the port on the container to associate with the load balancer. This port must correspond to a containerPort in the service's task definition. This parameter is required if --%s or --%s is specified.", flags.LoadBalancerNameFlag, flags.TargetGroupArnFlag) + loadBalancerNameUsageString := fmt.Sprintf("[Optional] Specifies the name of a previously configured Classic Elastic Load Balancing load balancer to associate with your service. NOTE: For Application Load Balancers or Network Load Balancers, use the --%s flag.", flags.TargetGroupArnFlag) + roleUsageString := fmt.Sprintf("[Optional] Specifies the name or full Amazon Resource Name (ARN) of the IAM role that allows Amazon ECS to make calls to your load balancer or target group on your behalf. This parameter requires either --%s or --%s to be specified.", flags.LoadBalancerNameFlag, flags.TargetGroupArnFlag) healthCheckGracePeriodString := "[Optional] Specifies the period of time, in seconds, that the Amazon ECS service scheduler should ignore unhealthy Elastic Load Balancing target health checks after a task has first started." return []cli.Flag{