-
-
Notifications
You must be signed in to change notification settings - Fork 110
Expand file tree
/
Copy pathdeploy.go
More file actions
610 lines (552 loc) · 19.3 KB
/
Copy pathdeploy.go
File metadata and controls
610 lines (552 loc) · 19.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
package ecspresso
import (
"context"
"errors"
"fmt"
"io"
"os"
"os/exec"
"strings"
"github.com/kayac/ecspresso/v2/appspec"
"github.com/samber/lo"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/codedeploy"
cdTypes "github.com/aws/aws-sdk-go-v2/service/codedeploy/types"
"github.com/aws/aws-sdk-go-v2/service/ecs"
"github.com/aws/aws-sdk-go-v2/service/ecs/types"
isatty "github.com/mattn/go-isatty"
)
const (
CodeDeployConsoleURLFmt = "https://%s.console.aws.amazon.com/codesuite/codedeploy/deployments/%s?region=%s"
)
type DeployOption struct {
DryRun bool `help:"dry run" default:"false"`
DesiredCount *int32 `name:"tasks" help:"desired count of tasks" default:"-1"`
SkipTaskDefinition bool `help:"skip register a new task definition" default:"false"`
Revision int64 `help:"revision of the task definition to run when --skip-task-definition" default:"0"`
ForceNewDeployment bool `help:"force a new deployment of the service" default:"false"`
Wait bool `help:"wait for service stable" default:"true" negatable:""`
WaitUntil string `help:"Choose whether to wait for service stable or the deployment finishes. For ECS deployment controller: \"(stable|deployed)\", or \"ecs:*\", this accepts a deployment lifecycle stage (e.g., \"ecs:BAKE_TIME\"); For CodeDeploy deployment controller: \"codedeploy:*\", this accepts CodeDeploy lifecycle event (e.g., \"codedeploy:AfterAllowTraffic\")" default:"deployed"`
SuspendAutoScaling *bool `help:"suspend application auto-scaling attached with the ECS service"`
ResumeAutoScaling *bool `help:"resume application auto-scaling attached with the ECS service"`
AutoScalingMin *int32 `help:"set minimum capacity of application auto-scaling attached with the ECS service"`
AutoScalingMax *int32 `help:"set maximum capacity of application auto-scaling attached with the ECS service"`
RollbackEvents string `help:"roll back when specified events happened (DEPLOYMENT_FAILURE,DEPLOYMENT_STOP_ON_ALARM,DEPLOYMENT_STOP_ON_REQUEST,...) CodeDeploy only." default:""`
UpdateService bool `help:"update service attributes by service definition" default:"true" negatable:""`
LatestTaskDefinition bool `help:"deploy with the latest task definition without registering a new task definition" default:"false"`
}
func (opt DeployOption) DryRunString() string {
if opt.DryRun {
return dryRunStr
}
return ""
}
func (opt DeployOption) Validate() error {
// Validate WaitUntil option
// The reason this validation exists is that the `enum` directive in `DeployOption.WaitUntil` does not support wildcards
u := waitUntil(opt.WaitUntil)
return u.Validate()
}
func (opt DeployOption) ModifyAutoScalingParams() *modifyAutoScalingParams {
p := &modifyAutoScalingParams{
Suspend: nil,
MinCapacity: opt.AutoScalingMin,
MaxCapacity: opt.AutoScalingMax,
}
if opt.SuspendAutoScaling != nil && *opt.SuspendAutoScaling {
p.Suspend = aws.Bool(true)
} else if opt.ResumeAutoScaling != nil && *opt.ResumeAutoScaling {
p.Suspend = aws.Bool(false)
}
return p
}
func calcDesiredCount(sv *Service, opt DeployOption) *int32 {
if sv.SchedulingStrategy == types.SchedulingStrategyDaemon {
return nil
}
if oc := opt.DesiredCount; oc != nil {
if *oc == DefaultDesiredCount {
return sv.DesiredCount
}
return oc // --tasks
}
return nil
}
func (d *App) Deploy(ctx context.Context, opt DeployOption) error {
d.LogDebug("deploy")
d.LogJSON(opt)
ctx, cancel := d.Start(ctx)
defer cancel()
var sv *Service
d.LogInfo("Starting deploy", withDryRun(opt.DryRun)...)
sv, err := d.DescribeServiceStatus(ctx, 0)
if err != nil {
if errors.As(err, &errNotFound) {
d.LogInfo("service not found, creating a new service", withDryRun(opt.DryRun)...)
if d.config.isExpressMode() {
return d.createExpressGatewayService(ctx, opt)
} else {
return d.createService(ctx, opt)
}
}
return err
}
// express mode is handled here
if d.config.isExpressMode() {
return d.DeployExpressGatewayService(ctx, sv, opt)
}
doDeploy, err := d.DeployFunc(sv)
if err != nil {
return err
}
tdArn, err := d.taskDefinitionArnForDeploy(ctx, sv, opt)
if err != nil {
return err
}
doWait, err := d.WaitFunc(sv, d.confirmPrimaryTD(tdArn), waitUntil(opt.WaitUntil))
if err != nil {
return err
}
var count *int32
svInput := &ecs.UpdateServiceInput{
Service: aws.String(d.Service),
Cluster: aws.String(d.Cluster),
}
if d.config.ServiceDefinitionPath != "" && opt.UpdateService {
newSv, err := d.LoadServiceDefinition(d.config.ServiceDefinitionPath)
if err != nil {
return err
}
addedTags, updatedTags, deletedTags := CompareTags(sv.Tags, newSv.Tags)
differ, err := diffServices(ctx, newSv, sv, d.config.ServiceDefinitionPath, &DiffOption{Unified: true, w: io.Discard})
if err != nil {
return fmt.Errorf("failed to diff of service definitions: %w", err)
}
if differ {
svInput = d.BuildServiceAttributes(newSv)
if opt.DryRun {
d.LogInfo("update service input", "input", MustMarshalJSONStringForAPI(svInput))
}
remoteServiceArn := sv.ServiceArn
sv = newSv // updated
sv.ServiceArn = remoteServiceArn
} else {
d.LogInfo("service attributes will not change")
}
if err := d.UpdateServiceTags(ctx, sv, addedTags, updatedTags, deletedTags, opt); err != nil {
return err
}
count = calcDesiredCount(newSv, opt)
} else {
count = calcDesiredCount(sv, opt)
}
if count != nil {
d.LogInfo("desired count", "desired_count", *count)
} else {
d.LogInfo("desired count: unchanged")
}
// fail fast before mutating anything: at this point sv reflects the service
// definition to be deployed, so the strategy check sees the effective value
if until := waitUntil(opt.WaitUntil); until.forECSLifecycleStage() {
stage := types.ServiceDeploymentLifecycleStage(until.ecsLifecycleStage())
if err := validateLifecycleStageSupported(sv, stage); err != nil {
return err
}
}
// manage auto scaling
if err := d.modifyAutoScaling(ctx, opt); err != nil {
return err
}
if opt.DryRun {
d.LogInfo("DRY RUN OK")
return nil
}
if err := doDeploy(ctx, svInput, tdArn, count, sv, opt); err != nil {
return err
}
if !opt.Wait {
d.LogInfo("Service is deployed.")
return nil
}
if err := doWait(ctx, sv); err != nil {
if errors.As(err, &errNotFound) {
d.LogInfo(err.Error())
// no need to wait
return nil
}
return err
}
d.LogInfo("service completed", "status", opt.WaitUntil)
return nil
}
func (d *App) DeployByECS(ctx context.Context, in *ecs.UpdateServiceInput, taskDefinitionArn string, count *int32, sv *Service, opt DeployOption) error {
in.TaskDefinition = aws.String(taskDefinitionArn)
in.DesiredCount = count
in.ForceNewDeployment = opt.ForceNewDeployment
if dc := sv.DeploymentConfiguration; dc != nil {
d.LogInfo("deployment by ECS strategy", "strategy", string(dc.Strategy))
} else {
d.LogInfo("deployment by ECS rolling update")
}
msg := "Updating service"
if opt.ForceNewDeployment {
msg = msg + " with force new deployment"
}
d.LogInfo(msg)
d.LogJSON(in)
_, err := d.ecs.UpdateService(ctx, in)
if err != nil {
return fmt.Errorf("failed to update service tasks: %w", err)
}
sleepContext(ctx, delayForServiceChanged) // wait for service updated
return nil
}
func svToUpdateServiceInput(sv *Service) *ecs.UpdateServiceInput {
in := &ecs.UpdateServiceInput{
AvailabilityZoneRebalancing: sv.AvailabilityZoneRebalancing,
CapacityProviderStrategy: sv.CapacityProviderStrategy,
DeploymentConfiguration: sv.DeploymentConfiguration,
DesiredCount: sv.DesiredCount,
EnableECSManagedTags: &sv.EnableECSManagedTags,
EnableExecuteCommand: &sv.EnableExecuteCommand,
HealthCheckGracePeriodSeconds: sv.HealthCheckGracePeriodSeconds,
LoadBalancers: sv.LoadBalancers,
Monitoring: sv.Monitoring,
NetworkConfiguration: sv.NetworkConfiguration,
PlacementConstraints: sv.PlacementConstraints,
PlacementStrategy: sv.PlacementStrategy,
PlatformVersion: sv.PlatformVersion,
PropagateTags: sv.PropagateTags,
ServiceConnectConfiguration: sv.ServiceConnectConfiguration,
ServiceRegistries: sv.ServiceRegistries,
VolumeConfigurations: sv.VolumeConfigurations,
VpcLatticeConfigurations: sv.VpcLatticeConfigurations,
}
if sv.SchedulingStrategy == types.SchedulingStrategyDaemon {
in.PlacementStrategy = nil
}
// explicitly set empty slice (to remove the load balancers)
if len(sv.LoadBalancers) == 0 {
in.LoadBalancers = []types.LoadBalancer{}
}
// explicitly set empty slice (to remove the attribute)
if len(sv.VolumeConfigurations) == 0 {
in.VolumeConfigurations = []types.ServiceVolumeConfiguration{}
}
if len(sv.VpcLatticeConfigurations) == 0 {
in.VpcLatticeConfigurations = []types.VpcLatticeConfiguration{}
}
// explicitly disable ServiceConnect (to remove the configuration)
if sv.ServiceConnectConfiguration == nil {
in.ServiceConnectConfiguration = &types.ServiceConnectConfiguration{
Enabled: false,
}
}
// in Express Mode, cannot update some configurations
if sv.isExpressMode() {
in.DeploymentConfiguration = nil
in.LoadBalancers = nil
}
return in
}
func (d *App) BuildServiceAttributes(sv *Service) *ecs.UpdateServiceInput {
in := svToUpdateServiceInput(sv)
if sv.isCodeDeploy() {
// unable to update attributes below with a CODE_DEPLOY deployment controller.
in.NetworkConfiguration = nil
in.PlatformVersion = nil
in.LoadBalancers = nil
in.ServiceRegistries = nil
in.CapacityProviderStrategy = nil
}
// Do not set TaskDefinition or ForceNewDeployment here.
// These will be set by the caller (UpdateServiceTasks or Deploy for CodeDeploy).
in.ForceNewDeployment = false
in.TaskDefinition = nil
in.Service = aws.String(d.Service)
in.Cluster = aws.String(d.Cluster)
return in
}
func (d *App) DeployByCodeDeploy(ctx context.Context, in *ecs.UpdateServiceInput, taskDefinitionArn string, count *int32, sv *Service, opt DeployOption) error {
d.LogInfo("deployment by CodeDeploy")
in.DesiredCount = count
if count != nil {
d.LogInfo("updating desired count", "desired_count", *count)
}
d.LogInfo("Updating service...")
d.LogJSON(in)
_, err := d.ecs.UpdateService(ctx, in)
if err != nil {
return fmt.Errorf("failed to update service: %w", err)
}
if opt.SkipTaskDefinition && !opt.UpdateService && !opt.ForceNewDeployment {
// no need to create new deployment.
return nil
}
return d.createDeployment(ctx, sv, taskDefinitionArn, opt.RollbackEvents)
}
func (d *App) findDeploymentInfo(ctx context.Context) (*cdTypes.DeploymentInfo, error) {
// search deploymentGroup in CodeDeploy
d.LogDebug("find applications in CodeDeploy")
apps, err := d.findCodeDeployApplications(ctx)
if err != nil {
return nil, err
}
for _, app := range apps {
groups, err := d.findCodeDeployDeploymentGroups(ctx, *app.ApplicationName)
if err != nil {
return nil, err
}
for _, dg := range groups {
d.LogJSON(dg)
for _, ecsService := range dg.EcsServices {
if *ecsService.ClusterName == d.config.Cluster && *ecsService.ServiceName == d.config.Service {
var configName *string
if d.config.CodeDeploy != nil && d.config.CodeDeploy.DeploymentConfigName != "" {
configName = aws.String(d.config.CodeDeploy.DeploymentConfigName)
} else {
configName = dg.DeploymentConfigName
}
return &cdTypes.DeploymentInfo{
ApplicationName: app.ApplicationName,
DeploymentGroupName: dg.DeploymentGroupName,
DeploymentConfigName: configName,
}, nil
}
}
}
}
return nil, ErrNotFound(fmt.Sprintf(
"failed to find CodeDeploy Application/DeploymentGroup for ECS service %s on cluster %s",
d.config.Service,
d.config.Cluster,
))
}
func (d *App) findCodeDeployApplications(ctx context.Context) ([]cdTypes.ApplicationInfo, error) {
var appNames []string
if cd := d.config.CodeDeploy; cd != nil && cd.ApplicationName != "" {
appNames = []string{cd.ApplicationName}
} else {
pager := codedeploy.NewListApplicationsPaginator(d.codedeploy, &codedeploy.ListApplicationsInput{})
for pager.HasMorePages() {
p, err := pager.NextPage(ctx)
if err != nil {
return nil, fmt.Errorf("failed to list applications: %w", err)
}
appNames = append(appNames, p.Applications...)
}
}
if len(appNames) == 0 {
return nil, ErrNotFound("no CodeDeploy applications found")
}
d.LogDebug("found CodeDeploy applications: %v", appNames)
var apps []cdTypes.ApplicationInfo
// BatchGetApplications accepts applications less than 100
for _, names := range lo.Chunk(appNames, 100) {
res, err := d.codedeploy.BatchGetApplications(ctx, &codedeploy.BatchGetApplicationsInput{
ApplicationNames: names,
})
if err != nil {
return nil, fmt.Errorf("failed to batch get applications in CodeDeploy: %w", err)
}
for _, info := range res.ApplicationsInfo {
d.LogDebug("application %s compute platform %s", *info.ApplicationName, info.ComputePlatform)
if info.ComputePlatform != cdTypes.ComputePlatformEcs {
continue
}
apps = append(apps, info)
}
}
if len(apps) == 0 {
return nil, ErrNotFound("no CodeDeploy applications found")
}
return apps, nil
}
func (d *App) findCodeDeployDeploymentGroups(ctx context.Context, appName string) ([]cdTypes.DeploymentGroupInfo, error) {
var groupNames []string
if cd := d.config.CodeDeploy; cd != nil && cd.DeploymentGroupName != "" {
groupNames = []string{cd.DeploymentGroupName}
} else {
pager := codedeploy.NewListDeploymentGroupsPaginator(d.codedeploy, &codedeploy.ListDeploymentGroupsInput{
ApplicationName: &appName,
})
for pager.HasMorePages() {
p, err := pager.NextPage(ctx)
if err != nil {
return nil, fmt.Errorf("failed to list deployment groups in CodeDeploy: %w", err)
}
groupNames = append(groupNames, p.DeploymentGroups...)
}
}
d.LogDebug("CodeDeploy found deploymentGroups: %v", groupNames)
var groups []cdTypes.DeploymentGroupInfo
// BatchGetDeploymentGroups accepts applications less than 100
for _, names := range lo.Chunk(groupNames, 100) {
gs, err := d.codedeploy.BatchGetDeploymentGroups(ctx, &codedeploy.BatchGetDeploymentGroupsInput{
ApplicationName: &appName,
DeploymentGroupNames: names,
})
if err != nil {
return nil, fmt.Errorf("failed to batch get deployment groups in CodeDeploy: %w", err)
}
groups = append(groups, gs.DeploymentGroupsInfo...)
}
return groups, nil
}
func (d *App) createDeployment(ctx context.Context, sv *Service, taskDefinitionArn string, rollbackEvents string) error {
spec, err := appspec.NewWithService(&sv.Service, taskDefinitionArn)
if err != nil {
return fmt.Errorf("failed to create appspec: %w", err)
}
if d.config.AppSpec != nil {
spec.Hooks = d.config.AppSpec.Hooks
}
d.LogDebug("appSpecContent: %s", spec.String())
// deployment
dp, err := d.findDeploymentInfo(ctx)
if err != nil {
return err
}
dd := &codedeploy.CreateDeploymentInput{
ApplicationName: dp.ApplicationName,
DeploymentGroupName: dp.DeploymentGroupName,
DeploymentConfigName: dp.DeploymentConfigName,
Revision: &cdTypes.RevisionLocation{
RevisionType: cdTypes.RevisionLocationTypeAppSpecContent,
AppSpecContent: &cdTypes.AppSpecContent{
Content: aws.String(spec.String()),
},
},
}
if rollbackEvents != "" {
var events []cdTypes.AutoRollbackEvent
for ev := range strings.SplitSeq(rollbackEvents, ",") {
switch ev {
case "DEPLOYMENT_FAILURE":
events = append(events, cdTypes.AutoRollbackEventDeploymentFailure)
case "DEPLOYMENT_STOP_ON_ALARM":
events = append(events, cdTypes.AutoRollbackEventDeploymentStopOnAlarm)
case "DEPLOYMENT_STOP_ON_REQUEST":
events = append(events, cdTypes.AutoRollbackEventDeploymentStopOnRequest)
default:
return fmt.Errorf("invalid rollback event: %s", ev)
}
}
dd.AutoRollbackConfiguration = &cdTypes.AutoRollbackConfiguration{
Enabled: true,
Events: events,
}
}
d.LogDebug("creating a deployment to CodeDeploy %v", dd)
res, err := d.codedeploy.CreateDeployment(ctx, dd)
if err != nil {
return fmt.Errorf("failed to create deployment: %w", err)
}
id := *res.DeploymentId
u := fmt.Sprintf(
CodeDeployConsoleURLFmt,
d.config.Region,
id,
d.config.Region,
)
d.LogInfo("deployment created on CodeDeploy", "deployment_id", id, "url", u)
if isatty.IsTerminal(os.Stdout.Fd()) {
if err := exec.Command("open", u).Start(); err != nil {
d.LogInfo("couldn't open URL", "url", u)
}
}
return nil
}
type deployFunc func(ctx context.Context, in *ecs.UpdateServiceInput, taskDefinitionArn string, count *int32, sv *Service, opt DeployOption) error
func (d *App) DeployFunc(sv *Service) (deployFunc, error) {
defaultFunc := d.DeployByECS
if sv == nil || sv.DeploymentController == nil {
return defaultFunc, nil
}
if dc := sv.DeploymentController; dc != nil {
switch dc.Type {
case types.DeploymentControllerTypeCodeDeploy:
return d.DeployByCodeDeploy, nil
case types.DeploymentControllerTypeEcs:
return d.DeployByECS, nil
default:
return nil, fmt.Errorf("unsupported deployment controller type: %s", dc.Type)
}
}
return defaultFunc, nil
}
func (d *App) UpdateServiceTags(ctx context.Context, sv *Service, added, updated, deleted []types.Tag, opt DeployOption) error {
if len(added) == 0 && len(updated) == 0 && len(deleted) == 0 {
d.LogDebug("no service tags to update")
return nil
}
var tags []types.Tag
tags = append(tags, added...)
tags = append(tags, updated...)
var untagKeys []string
for _, t := range deleted {
untagKeys = append(untagKeys, *t.Key)
}
if len(tags) > 0 {
for _, t := range tags {
d.LogInfo("updating service tag", withDryRun(opt.DryRun, "tag_key", aws.ToString(t.Key), "tag_value", aws.ToString(t.Value))...)
}
}
if len(untagKeys) > 0 {
d.LogInfo("deleting service tags", withDryRun(opt.DryRun, "tag_keys", strings.Join(untagKeys, ","))...)
}
if opt.DryRun {
return nil
}
if len(tags) > 0 {
if _, err := d.ecs.TagResource(ctx, &ecs.TagResourceInput{
ResourceArn: sv.ServiceArn,
Tags: tags,
}); err != nil {
return fmt.Errorf("failed to tag service: %w", err)
}
}
if len(untagKeys) > 0 {
if _, err := d.ecs.UntagResource(ctx, &ecs.UntagResourceInput{
ResourceArn: sv.ServiceArn,
TagKeys: untagKeys,
}); err != nil {
return fmt.Errorf("failed to untag service: %w", err)
}
}
return nil
}
func (d *App) taskDefinitionArnForDeploy(ctx context.Context, sv *Service, opt DeployOption) (string, error) {
if opt.Revision > 0 {
if opt.LatestTaskDefinition {
return "", ErrConflictOptions("revision and latest-task-definition are exclusive")
}
family := strings.Split(arnToName(aws.ToString(sv.TaskDefinition)), ":")[0]
return fmt.Sprintf("%s:%d", family, opt.Revision), nil
}
if opt.LatestTaskDefinition {
family := strings.Split(arnToName(aws.ToString(sv.TaskDefinition)), ":")[0]
tdArn, err := d.findLatestTaskDefinitionArn(ctx, family)
if err != nil {
return "", err
}
return tdArn, nil
}
if opt.SkipTaskDefinition {
return sv.getTaskDefinitionArn()
}
td, err := d.LoadTaskDefinition(d.config.TaskDefinitionPath)
if err != nil {
return "", err
}
if opt.DryRun {
d.LogInfo("task definition:")
OutputJSONForAPI(os.Stdout, td)
return "", nil
}
newTd, err := d.RegisterTaskDefinition(ctx, td)
if err != nil {
return "", err
}
return *newTd.TaskDefinitionArn, nil
}