Skip to content

Commit 2de83fe

Browse files
committed
Bug fix: Service Discovery Service Name is correctly set from ECS Params
1 parent 289237b commit 2de83fe

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

ecs-cli/modules/cli/servicediscovery/servicediscovery_app_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
const (
3838
testClusterName = "cluster"
3939
testServiceName = "service"
40+
otherTestServiceName = "some-other-name"
4041
testDescription = "clyde loves pudding"
4142
otherTestDescription = "pudding plays hard to get"
4243
testNamespaceStackName = "amazon-ecs-cli-setup-private-dns-namespace-cluster-service"
@@ -231,7 +232,7 @@ func TestCreateServiceDiscoveryWithECSParams(t *testing.T) {
231232
Description: testDescription,
232233
},
233234
ServiceDiscoveryService: utils.ServiceDiscoveryService{
234-
Name: testServiceName,
235+
Name: otherTestServiceName,
235236
Description: testDescription,
236237
DNSConfig: utils.DNSConfig{
237238
TTL: aws.Int64(60),
@@ -250,7 +251,7 @@ func TestCreateServiceDiscoveryWithECSParams(t *testing.T) {
250251
}
251252
var validateSDS validateSDSParamsFunc = func(t *testing.T, cfnParams *cloudformation.CfnStackParams) {
252253
validateCFNParam(testNamespaceID, parameterKeyNamespaceID, cfnParams, t)
253-
validateCFNParam(testServiceName, parameterKeySDSName, cfnParams, t)
254+
validateCFNParam(otherTestServiceName, parameterKeySDSName, cfnParams, t)
254255
validateCFNParam(servicediscovery.RecordTypeSrv, parameterKeyDNSType, cfnParams, t)
255256
validateCFNParam(testDescription, parameterKeySDSDescription, cfnParams, t)
256257
validateCFNParam("60", parameterKeyDNSTTL, cfnParams, t)

ecs-cli/modules/cli/servicediscovery/servicediscovery_helper.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,14 @@ func truncate(s string, length int) string {
242242
return s
243243
}
244244

245-
func getSDSCFNParams(namespaceID, sdsName, networkMode string, input *utils.ServiceDiscovery) *cloudformation.CfnStackParams {
245+
func getSDSCFNParams(namespaceID, ecsServiceName, networkMode string, input *utils.ServiceDiscovery) *cloudformation.CfnStackParams {
246246
cfnParams := cloudformation.NewCfnStackParams(requiredParamsSDS)
247247

248+
sdsName := input.ServiceDiscoveryService.Name
249+
if sdsName == "" {
250+
sdsName = ecsServiceName
251+
}
252+
248253
cfnParams.Add(parameterKeyNamespaceID, namespaceID)
249254
cfnParams.Add(parameterKeySDSName, sdsName)
250255

0 commit comments

Comments
 (0)