github.com/aavshr/aws-sdk-go@v1.41.3/service/ecs/examples_test.go (about) 1 // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 3 package ecs_test 4 5 import ( 6 "fmt" 7 "strings" 8 "time" 9 10 "github.com/aavshr/aws-sdk-go/aws" 11 "github.com/aavshr/aws-sdk-go/aws/awserr" 12 "github.com/aavshr/aws-sdk-go/aws/session" 13 "github.com/aavshr/aws-sdk-go/service/ecs" 14 ) 15 16 var _ time.Duration 17 var _ strings.Reader 18 var _ aws.Config 19 20 func parseTime(layout, value string) *time.Time { 21 t, err := time.Parse(layout, value) 22 if err != nil { 23 panic(err) 24 } 25 return &t 26 } 27 28 // To create a new cluster 29 // 30 // This example creates a cluster in your default region. 31 func ExampleECS_CreateCluster_shared00() { 32 svc := ecs.New(session.New()) 33 input := &ecs.CreateClusterInput{ 34 ClusterName: aws.String("my_cluster"), 35 } 36 37 result, err := svc.CreateCluster(input) 38 if err != nil { 39 if aerr, ok := err.(awserr.Error); ok { 40 switch aerr.Code() { 41 case ecs.ErrCodeServerException: 42 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 43 case ecs.ErrCodeClientException: 44 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 45 case ecs.ErrCodeInvalidParameterException: 46 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 47 default: 48 fmt.Println(aerr.Error()) 49 } 50 } else { 51 // Print the error, cast err to awserr.Error to get the Code and 52 // Message from an error. 53 fmt.Println(err.Error()) 54 } 55 return 56 } 57 58 fmt.Println(result) 59 } 60 61 // To create a new service 62 // 63 // This example creates a service in your default region called ``ecs-simple-service``. 64 // The service uses the ``hello_world`` task definition and it maintains 10 copies of 65 // that task. 66 func ExampleECS_CreateService_shared00() { 67 svc := ecs.New(session.New()) 68 input := &ecs.CreateServiceInput{ 69 DesiredCount: aws.Int64(10), 70 ServiceName: aws.String("ecs-simple-service"), 71 TaskDefinition: aws.String("hello_world"), 72 } 73 74 result, err := svc.CreateService(input) 75 if err != nil { 76 if aerr, ok := err.(awserr.Error); ok { 77 switch aerr.Code() { 78 case ecs.ErrCodeServerException: 79 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 80 case ecs.ErrCodeClientException: 81 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 82 case ecs.ErrCodeInvalidParameterException: 83 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 84 case ecs.ErrCodeClusterNotFoundException: 85 fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) 86 case ecs.ErrCodeUnsupportedFeatureException: 87 fmt.Println(ecs.ErrCodeUnsupportedFeatureException, aerr.Error()) 88 case ecs.ErrCodePlatformUnknownException: 89 fmt.Println(ecs.ErrCodePlatformUnknownException, aerr.Error()) 90 case ecs.ErrCodePlatformTaskDefinitionIncompatibilityException: 91 fmt.Println(ecs.ErrCodePlatformTaskDefinitionIncompatibilityException, aerr.Error()) 92 case ecs.ErrCodeAccessDeniedException: 93 fmt.Println(ecs.ErrCodeAccessDeniedException, aerr.Error()) 94 default: 95 fmt.Println(aerr.Error()) 96 } 97 } else { 98 // Print the error, cast err to awserr.Error to get the Code and 99 // Message from an error. 100 fmt.Println(err.Error()) 101 } 102 return 103 } 104 105 fmt.Println(result) 106 } 107 108 // To create a new service behind a load balancer 109 // 110 // This example creates a service in your default region called ``ecs-simple-service-elb``. 111 // The service uses the ``ecs-demo`` task definition and it maintains 10 copies of that 112 // task. You must reference an existing load balancer in the same region by its name. 113 func ExampleECS_CreateService_shared01() { 114 svc := ecs.New(session.New()) 115 input := &ecs.CreateServiceInput{ 116 DesiredCount: aws.Int64(10), 117 LoadBalancers: []*ecs.LoadBalancer{ 118 { 119 ContainerName: aws.String("simple-app"), 120 ContainerPort: aws.Int64(80), 121 LoadBalancerName: aws.String("EC2Contai-EcsElast-15DCDAURT3ZO2"), 122 }, 123 }, 124 Role: aws.String("ecsServiceRole"), 125 ServiceName: aws.String("ecs-simple-service-elb"), 126 TaskDefinition: aws.String("console-sample-app-static"), 127 } 128 129 result, err := svc.CreateService(input) 130 if err != nil { 131 if aerr, ok := err.(awserr.Error); ok { 132 switch aerr.Code() { 133 case ecs.ErrCodeServerException: 134 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 135 case ecs.ErrCodeClientException: 136 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 137 case ecs.ErrCodeInvalidParameterException: 138 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 139 case ecs.ErrCodeClusterNotFoundException: 140 fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) 141 case ecs.ErrCodeUnsupportedFeatureException: 142 fmt.Println(ecs.ErrCodeUnsupportedFeatureException, aerr.Error()) 143 case ecs.ErrCodePlatformUnknownException: 144 fmt.Println(ecs.ErrCodePlatformUnknownException, aerr.Error()) 145 case ecs.ErrCodePlatformTaskDefinitionIncompatibilityException: 146 fmt.Println(ecs.ErrCodePlatformTaskDefinitionIncompatibilityException, aerr.Error()) 147 case ecs.ErrCodeAccessDeniedException: 148 fmt.Println(ecs.ErrCodeAccessDeniedException, aerr.Error()) 149 default: 150 fmt.Println(aerr.Error()) 151 } 152 } else { 153 // Print the error, cast err to awserr.Error to get the Code and 154 // Message from an error. 155 fmt.Println(err.Error()) 156 } 157 return 158 } 159 160 fmt.Println(result) 161 } 162 163 // To delete your account setting 164 // 165 // This example deletes the account setting for your user for the specified resource 166 // type. 167 func ExampleECS_DeleteAccountSetting_shared00() { 168 svc := ecs.New(session.New()) 169 input := &ecs.DeleteAccountSettingInput{ 170 Name: aws.String("serviceLongArnFormat"), 171 } 172 173 result, err := svc.DeleteAccountSetting(input) 174 if err != nil { 175 if aerr, ok := err.(awserr.Error); ok { 176 switch aerr.Code() { 177 case ecs.ErrCodeServerException: 178 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 179 case ecs.ErrCodeClientException: 180 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 181 case ecs.ErrCodeInvalidParameterException: 182 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 183 default: 184 fmt.Println(aerr.Error()) 185 } 186 } else { 187 // Print the error, cast err to awserr.Error to get the Code and 188 // Message from an error. 189 fmt.Println(err.Error()) 190 } 191 return 192 } 193 194 fmt.Println(result) 195 } 196 197 // To delete the account settings for a specific IAM user or IAM role 198 // 199 // This example deletes the account setting for a specific IAM user or IAM role for 200 // the specified resource type. Only the root user can view or modify the account settings 201 // for another user. 202 func ExampleECS_DeleteAccountSetting_shared01() { 203 svc := ecs.New(session.New()) 204 input := &ecs.DeleteAccountSettingInput{ 205 Name: aws.String("containerInstanceLongArnFormat"), 206 PrincipalArn: aws.String("arn:aws:iam::<aws_account_id>:user/principalName"), 207 } 208 209 result, err := svc.DeleteAccountSetting(input) 210 if err != nil { 211 if aerr, ok := err.(awserr.Error); ok { 212 switch aerr.Code() { 213 case ecs.ErrCodeServerException: 214 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 215 case ecs.ErrCodeClientException: 216 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 217 case ecs.ErrCodeInvalidParameterException: 218 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 219 default: 220 fmt.Println(aerr.Error()) 221 } 222 } else { 223 // Print the error, cast err to awserr.Error to get the Code and 224 // Message from an error. 225 fmt.Println(err.Error()) 226 } 227 return 228 } 229 230 fmt.Println(result) 231 } 232 233 // To delete an empty cluster 234 // 235 // This example deletes an empty cluster in your default region. 236 func ExampleECS_DeleteCluster_shared00() { 237 svc := ecs.New(session.New()) 238 input := &ecs.DeleteClusterInput{ 239 Cluster: aws.String("my_cluster"), 240 } 241 242 result, err := svc.DeleteCluster(input) 243 if err != nil { 244 if aerr, ok := err.(awserr.Error); ok { 245 switch aerr.Code() { 246 case ecs.ErrCodeServerException: 247 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 248 case ecs.ErrCodeClientException: 249 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 250 case ecs.ErrCodeInvalidParameterException: 251 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 252 case ecs.ErrCodeClusterNotFoundException: 253 fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) 254 case ecs.ErrCodeClusterContainsContainerInstancesException: 255 fmt.Println(ecs.ErrCodeClusterContainsContainerInstancesException, aerr.Error()) 256 case ecs.ErrCodeClusterContainsServicesException: 257 fmt.Println(ecs.ErrCodeClusterContainsServicesException, aerr.Error()) 258 case ecs.ErrCodeClusterContainsTasksException: 259 fmt.Println(ecs.ErrCodeClusterContainsTasksException, aerr.Error()) 260 case ecs.ErrCodeUpdateInProgressException: 261 fmt.Println(ecs.ErrCodeUpdateInProgressException, aerr.Error()) 262 default: 263 fmt.Println(aerr.Error()) 264 } 265 } else { 266 // Print the error, cast err to awserr.Error to get the Code and 267 // Message from an error. 268 fmt.Println(err.Error()) 269 } 270 return 271 } 272 273 fmt.Println(result) 274 } 275 276 // To delete a service 277 // 278 // This example deletes the my-http-service service. The service must have a desired 279 // count and running count of 0 before you can delete it. 280 func ExampleECS_DeleteService_shared00() { 281 svc := ecs.New(session.New()) 282 input := &ecs.DeleteServiceInput{ 283 Service: aws.String("my-http-service"), 284 } 285 286 result, err := svc.DeleteService(input) 287 if err != nil { 288 if aerr, ok := err.(awserr.Error); ok { 289 switch aerr.Code() { 290 case ecs.ErrCodeServerException: 291 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 292 case ecs.ErrCodeClientException: 293 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 294 case ecs.ErrCodeInvalidParameterException: 295 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 296 case ecs.ErrCodeClusterNotFoundException: 297 fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) 298 case ecs.ErrCodeServiceNotFoundException: 299 fmt.Println(ecs.ErrCodeServiceNotFoundException, aerr.Error()) 300 default: 301 fmt.Println(aerr.Error()) 302 } 303 } else { 304 // Print the error, cast err to awserr.Error to get the Code and 305 // Message from an error. 306 fmt.Println(err.Error()) 307 } 308 return 309 } 310 311 fmt.Println(result) 312 } 313 314 // To deregister a container instance from a cluster 315 // 316 // This example deregisters a container instance from the specified cluster in your 317 // default region. If there are still tasks running on the container instance, you must 318 // either stop those tasks before deregistering, or use the force option. 319 func ExampleECS_DeregisterContainerInstance_shared00() { 320 svc := ecs.New(session.New()) 321 input := &ecs.DeregisterContainerInstanceInput{ 322 Cluster: aws.String("default"), 323 ContainerInstance: aws.String("container_instance_UUID"), 324 Force: aws.Bool(true), 325 } 326 327 result, err := svc.DeregisterContainerInstance(input) 328 if err != nil { 329 if aerr, ok := err.(awserr.Error); ok { 330 switch aerr.Code() { 331 case ecs.ErrCodeServerException: 332 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 333 case ecs.ErrCodeClientException: 334 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 335 case ecs.ErrCodeInvalidParameterException: 336 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 337 case ecs.ErrCodeClusterNotFoundException: 338 fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) 339 default: 340 fmt.Println(aerr.Error()) 341 } 342 } else { 343 // Print the error, cast err to awserr.Error to get the Code and 344 // Message from an error. 345 fmt.Println(err.Error()) 346 } 347 return 348 } 349 350 fmt.Println(result) 351 } 352 353 // To describe a cluster 354 // 355 // This example provides a description of the specified cluster in your default region. 356 func ExampleECS_DescribeClusters_shared00() { 357 svc := ecs.New(session.New()) 358 input := &ecs.DescribeClustersInput{ 359 Clusters: []*string{ 360 aws.String("default"), 361 }, 362 } 363 364 result, err := svc.DescribeClusters(input) 365 if err != nil { 366 if aerr, ok := err.(awserr.Error); ok { 367 switch aerr.Code() { 368 case ecs.ErrCodeServerException: 369 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 370 case ecs.ErrCodeClientException: 371 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 372 case ecs.ErrCodeInvalidParameterException: 373 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 374 default: 375 fmt.Println(aerr.Error()) 376 } 377 } else { 378 // Print the error, cast err to awserr.Error to get the Code and 379 // Message from an error. 380 fmt.Println(err.Error()) 381 } 382 return 383 } 384 385 fmt.Println(result) 386 } 387 388 // To describe container instance 389 // 390 // This example provides a description of the specified container instance in your default 391 // region, using the container instance UUID as an identifier. 392 func ExampleECS_DescribeContainerInstances_shared00() { 393 svc := ecs.New(session.New()) 394 input := &ecs.DescribeContainerInstancesInput{ 395 Cluster: aws.String("default"), 396 ContainerInstances: []*string{ 397 aws.String("f2756532-8f13-4d53-87c9-aed50dc94cd7"), 398 }, 399 } 400 401 result, err := svc.DescribeContainerInstances(input) 402 if err != nil { 403 if aerr, ok := err.(awserr.Error); ok { 404 switch aerr.Code() { 405 case ecs.ErrCodeServerException: 406 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 407 case ecs.ErrCodeClientException: 408 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 409 case ecs.ErrCodeInvalidParameterException: 410 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 411 case ecs.ErrCodeClusterNotFoundException: 412 fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) 413 default: 414 fmt.Println(aerr.Error()) 415 } 416 } else { 417 // Print the error, cast err to awserr.Error to get the Code and 418 // Message from an error. 419 fmt.Println(err.Error()) 420 } 421 return 422 } 423 424 fmt.Println(result) 425 } 426 427 // To describe a service 428 // 429 // This example provides descriptive information about the service named ``ecs-simple-service``. 430 func ExampleECS_DescribeServices_shared00() { 431 svc := ecs.New(session.New()) 432 input := &ecs.DescribeServicesInput{ 433 Services: []*string{ 434 aws.String("ecs-simple-service"), 435 }, 436 } 437 438 result, err := svc.DescribeServices(input) 439 if err != nil { 440 if aerr, ok := err.(awserr.Error); ok { 441 switch aerr.Code() { 442 case ecs.ErrCodeServerException: 443 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 444 case ecs.ErrCodeClientException: 445 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 446 case ecs.ErrCodeInvalidParameterException: 447 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 448 case ecs.ErrCodeClusterNotFoundException: 449 fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) 450 default: 451 fmt.Println(aerr.Error()) 452 } 453 } else { 454 // Print the error, cast err to awserr.Error to get the Code and 455 // Message from an error. 456 fmt.Println(err.Error()) 457 } 458 return 459 } 460 461 fmt.Println(result) 462 } 463 464 // To describe a task definition 465 // 466 // This example provides a description of the specified task definition. 467 func ExampleECS_DescribeTaskDefinition_shared00() { 468 svc := ecs.New(session.New()) 469 input := &ecs.DescribeTaskDefinitionInput{ 470 TaskDefinition: aws.String("hello_world:8"), 471 } 472 473 result, err := svc.DescribeTaskDefinition(input) 474 if err != nil { 475 if aerr, ok := err.(awserr.Error); ok { 476 switch aerr.Code() { 477 case ecs.ErrCodeServerException: 478 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 479 case ecs.ErrCodeClientException: 480 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 481 case ecs.ErrCodeInvalidParameterException: 482 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 483 default: 484 fmt.Println(aerr.Error()) 485 } 486 } else { 487 // Print the error, cast err to awserr.Error to get the Code and 488 // Message from an error. 489 fmt.Println(err.Error()) 490 } 491 return 492 } 493 494 fmt.Println(result) 495 } 496 497 // To describe a task 498 // 499 // This example provides a description of the specified task, using the task UUID as 500 // an identifier. 501 func ExampleECS_DescribeTasks_shared00() { 502 svc := ecs.New(session.New()) 503 input := &ecs.DescribeTasksInput{ 504 Tasks: []*string{ 505 aws.String("c5cba4eb-5dad-405e-96db-71ef8eefe6a8"), 506 }, 507 } 508 509 result, err := svc.DescribeTasks(input) 510 if err != nil { 511 if aerr, ok := err.(awserr.Error); ok { 512 switch aerr.Code() { 513 case ecs.ErrCodeServerException: 514 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 515 case ecs.ErrCodeClientException: 516 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 517 case ecs.ErrCodeInvalidParameterException: 518 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 519 case ecs.ErrCodeClusterNotFoundException: 520 fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) 521 default: 522 fmt.Println(aerr.Error()) 523 } 524 } else { 525 // Print the error, cast err to awserr.Error to get the Code and 526 // Message from an error. 527 fmt.Println(err.Error()) 528 } 529 return 530 } 531 532 fmt.Println(result) 533 } 534 535 // To view your effective account settings 536 // 537 // This example displays the effective account settings for your account. 538 func ExampleECS_ListAccountSettings_shared00() { 539 svc := ecs.New(session.New()) 540 input := &ecs.ListAccountSettingsInput{ 541 EffectiveSettings: aws.Bool(true), 542 } 543 544 result, err := svc.ListAccountSettings(input) 545 if err != nil { 546 if aerr, ok := err.(awserr.Error); ok { 547 switch aerr.Code() { 548 case ecs.ErrCodeServerException: 549 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 550 case ecs.ErrCodeClientException: 551 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 552 case ecs.ErrCodeInvalidParameterException: 553 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 554 default: 555 fmt.Println(aerr.Error()) 556 } 557 } else { 558 // Print the error, cast err to awserr.Error to get the Code and 559 // Message from an error. 560 fmt.Println(err.Error()) 561 } 562 return 563 } 564 565 fmt.Println(result) 566 } 567 568 // To view the effective account settings for a specific IAM user or IAM role 569 // 570 // This example displays the effective account settings for the specified user or role. 571 func ExampleECS_ListAccountSettings_shared01() { 572 svc := ecs.New(session.New()) 573 input := &ecs.ListAccountSettingsInput{ 574 EffectiveSettings: aws.Bool(true), 575 PrincipalArn: aws.String("arn:aws:iam::<aws_account_id>:user/principalName"), 576 } 577 578 result, err := svc.ListAccountSettings(input) 579 if err != nil { 580 if aerr, ok := err.(awserr.Error); ok { 581 switch aerr.Code() { 582 case ecs.ErrCodeServerException: 583 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 584 case ecs.ErrCodeClientException: 585 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 586 case ecs.ErrCodeInvalidParameterException: 587 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 588 default: 589 fmt.Println(aerr.Error()) 590 } 591 } else { 592 // Print the error, cast err to awserr.Error to get the Code and 593 // Message from an error. 594 fmt.Println(err.Error()) 595 } 596 return 597 } 598 599 fmt.Println(result) 600 } 601 602 // To list your available clusters 603 // 604 // This example lists all of your available clusters in your default region. 605 func ExampleECS_ListClusters_shared00() { 606 svc := ecs.New(session.New()) 607 input := &ecs.ListClustersInput{} 608 609 result, err := svc.ListClusters(input) 610 if err != nil { 611 if aerr, ok := err.(awserr.Error); ok { 612 switch aerr.Code() { 613 case ecs.ErrCodeServerException: 614 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 615 case ecs.ErrCodeClientException: 616 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 617 case ecs.ErrCodeInvalidParameterException: 618 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 619 default: 620 fmt.Println(aerr.Error()) 621 } 622 } else { 623 // Print the error, cast err to awserr.Error to get the Code and 624 // Message from an error. 625 fmt.Println(err.Error()) 626 } 627 return 628 } 629 630 fmt.Println(result) 631 } 632 633 // To list your available container instances in a cluster 634 // 635 // This example lists all of your available container instances in the specified cluster 636 // in your default region. 637 func ExampleECS_ListContainerInstances_shared00() { 638 svc := ecs.New(session.New()) 639 input := &ecs.ListContainerInstancesInput{ 640 Cluster: aws.String("default"), 641 } 642 643 result, err := svc.ListContainerInstances(input) 644 if err != nil { 645 if aerr, ok := err.(awserr.Error); ok { 646 switch aerr.Code() { 647 case ecs.ErrCodeServerException: 648 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 649 case ecs.ErrCodeClientException: 650 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 651 case ecs.ErrCodeInvalidParameterException: 652 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 653 case ecs.ErrCodeClusterNotFoundException: 654 fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) 655 default: 656 fmt.Println(aerr.Error()) 657 } 658 } else { 659 // Print the error, cast err to awserr.Error to get the Code and 660 // Message from an error. 661 fmt.Println(err.Error()) 662 } 663 return 664 } 665 666 fmt.Println(result) 667 } 668 669 // To list the services in a cluster 670 // 671 // This example lists the services running in the default cluster for an account. 672 func ExampleECS_ListServices_shared00() { 673 svc := ecs.New(session.New()) 674 input := &ecs.ListServicesInput{} 675 676 result, err := svc.ListServices(input) 677 if err != nil { 678 if aerr, ok := err.(awserr.Error); ok { 679 switch aerr.Code() { 680 case ecs.ErrCodeServerException: 681 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 682 case ecs.ErrCodeClientException: 683 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 684 case ecs.ErrCodeInvalidParameterException: 685 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 686 case ecs.ErrCodeClusterNotFoundException: 687 fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) 688 default: 689 fmt.Println(aerr.Error()) 690 } 691 } else { 692 // Print the error, cast err to awserr.Error to get the Code and 693 // Message from an error. 694 fmt.Println(err.Error()) 695 } 696 return 697 } 698 699 fmt.Println(result) 700 } 701 702 // To list the tags for a cluster. 703 // 704 // This example lists the tags for the 'dev' cluster. 705 func ExampleECS_ListTagsForResource_shared00() { 706 svc := ecs.New(session.New()) 707 input := &ecs.ListTagsForResourceInput{ 708 ResourceArn: aws.String("arn:aws:ecs:region:aws_account_id:cluster/dev"), 709 } 710 711 result, err := svc.ListTagsForResource(input) 712 if err != nil { 713 if aerr, ok := err.(awserr.Error); ok { 714 switch aerr.Code() { 715 case ecs.ErrCodeServerException: 716 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 717 case ecs.ErrCodeClientException: 718 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 719 case ecs.ErrCodeClusterNotFoundException: 720 fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) 721 case ecs.ErrCodeInvalidParameterException: 722 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 723 default: 724 fmt.Println(aerr.Error()) 725 } 726 } else { 727 // Print the error, cast err to awserr.Error to get the Code and 728 // Message from an error. 729 fmt.Println(err.Error()) 730 } 731 return 732 } 733 734 fmt.Println(result) 735 } 736 737 // To list your registered task definition families 738 // 739 // This example lists all of your registered task definition families. 740 func ExampleECS_ListTaskDefinitionFamilies_shared00() { 741 svc := ecs.New(session.New()) 742 input := &ecs.ListTaskDefinitionFamiliesInput{} 743 744 result, err := svc.ListTaskDefinitionFamilies(input) 745 if err != nil { 746 if aerr, ok := err.(awserr.Error); ok { 747 switch aerr.Code() { 748 case ecs.ErrCodeServerException: 749 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 750 case ecs.ErrCodeClientException: 751 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 752 case ecs.ErrCodeInvalidParameterException: 753 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 754 default: 755 fmt.Println(aerr.Error()) 756 } 757 } else { 758 // Print the error, cast err to awserr.Error to get the Code and 759 // Message from an error. 760 fmt.Println(err.Error()) 761 } 762 return 763 } 764 765 fmt.Println(result) 766 } 767 768 // To filter your registered task definition families 769 // 770 // This example lists the task definition revisions that start with "hpcc". 771 func ExampleECS_ListTaskDefinitionFamilies_shared01() { 772 svc := ecs.New(session.New()) 773 input := &ecs.ListTaskDefinitionFamiliesInput{ 774 FamilyPrefix: aws.String("hpcc"), 775 } 776 777 result, err := svc.ListTaskDefinitionFamilies(input) 778 if err != nil { 779 if aerr, ok := err.(awserr.Error); ok { 780 switch aerr.Code() { 781 case ecs.ErrCodeServerException: 782 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 783 case ecs.ErrCodeClientException: 784 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 785 case ecs.ErrCodeInvalidParameterException: 786 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 787 default: 788 fmt.Println(aerr.Error()) 789 } 790 } else { 791 // Print the error, cast err to awserr.Error to get the Code and 792 // Message from an error. 793 fmt.Println(err.Error()) 794 } 795 return 796 } 797 798 fmt.Println(result) 799 } 800 801 // To list your registered task definitions 802 // 803 // This example lists all of your registered task definitions. 804 func ExampleECS_ListTaskDefinitions_shared00() { 805 svc := ecs.New(session.New()) 806 input := &ecs.ListTaskDefinitionsInput{} 807 808 result, err := svc.ListTaskDefinitions(input) 809 if err != nil { 810 if aerr, ok := err.(awserr.Error); ok { 811 switch aerr.Code() { 812 case ecs.ErrCodeServerException: 813 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 814 case ecs.ErrCodeClientException: 815 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 816 case ecs.ErrCodeInvalidParameterException: 817 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 818 default: 819 fmt.Println(aerr.Error()) 820 } 821 } else { 822 // Print the error, cast err to awserr.Error to get the Code and 823 // Message from an error. 824 fmt.Println(err.Error()) 825 } 826 return 827 } 828 829 fmt.Println(result) 830 } 831 832 // To list the registered task definitions in a family 833 // 834 // This example lists the task definition revisions of a specified family. 835 func ExampleECS_ListTaskDefinitions_shared01() { 836 svc := ecs.New(session.New()) 837 input := &ecs.ListTaskDefinitionsInput{ 838 FamilyPrefix: aws.String("wordpress"), 839 } 840 841 result, err := svc.ListTaskDefinitions(input) 842 if err != nil { 843 if aerr, ok := err.(awserr.Error); ok { 844 switch aerr.Code() { 845 case ecs.ErrCodeServerException: 846 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 847 case ecs.ErrCodeClientException: 848 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 849 case ecs.ErrCodeInvalidParameterException: 850 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 851 default: 852 fmt.Println(aerr.Error()) 853 } 854 } else { 855 // Print the error, cast err to awserr.Error to get the Code and 856 // Message from an error. 857 fmt.Println(err.Error()) 858 } 859 return 860 } 861 862 fmt.Println(result) 863 } 864 865 // To list the tasks in a cluster 866 // 867 // This example lists all of the tasks in a cluster. 868 func ExampleECS_ListTasks_shared00() { 869 svc := ecs.New(session.New()) 870 input := &ecs.ListTasksInput{ 871 Cluster: aws.String("default"), 872 } 873 874 result, err := svc.ListTasks(input) 875 if err != nil { 876 if aerr, ok := err.(awserr.Error); ok { 877 switch aerr.Code() { 878 case ecs.ErrCodeServerException: 879 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 880 case ecs.ErrCodeClientException: 881 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 882 case ecs.ErrCodeInvalidParameterException: 883 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 884 case ecs.ErrCodeClusterNotFoundException: 885 fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) 886 case ecs.ErrCodeServiceNotFoundException: 887 fmt.Println(ecs.ErrCodeServiceNotFoundException, aerr.Error()) 888 default: 889 fmt.Println(aerr.Error()) 890 } 891 } else { 892 // Print the error, cast err to awserr.Error to get the Code and 893 // Message from an error. 894 fmt.Println(err.Error()) 895 } 896 return 897 } 898 899 fmt.Println(result) 900 } 901 902 // To list the tasks on a particular container instance 903 // 904 // This example lists the tasks of a specified container instance. Specifying a ``containerInstance`` 905 // value limits the results to tasks that belong to that container instance. 906 func ExampleECS_ListTasks_shared01() { 907 svc := ecs.New(session.New()) 908 input := &ecs.ListTasksInput{ 909 Cluster: aws.String("default"), 910 ContainerInstance: aws.String("f6bbb147-5370-4ace-8c73-c7181ded911f"), 911 } 912 913 result, err := svc.ListTasks(input) 914 if err != nil { 915 if aerr, ok := err.(awserr.Error); ok { 916 switch aerr.Code() { 917 case ecs.ErrCodeServerException: 918 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 919 case ecs.ErrCodeClientException: 920 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 921 case ecs.ErrCodeInvalidParameterException: 922 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 923 case ecs.ErrCodeClusterNotFoundException: 924 fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) 925 case ecs.ErrCodeServiceNotFoundException: 926 fmt.Println(ecs.ErrCodeServiceNotFoundException, aerr.Error()) 927 default: 928 fmt.Println(aerr.Error()) 929 } 930 } else { 931 // Print the error, cast err to awserr.Error to get the Code and 932 // Message from an error. 933 fmt.Println(err.Error()) 934 } 935 return 936 } 937 938 fmt.Println(result) 939 } 940 941 // To modify your account settings 942 // 943 // This example modifies your account settings to opt in to the new ARN and resource 944 // ID format for Amazon ECS services. If you’re using this command as the root user, 945 // then changes apply to the entire AWS account, unless an IAM user or role explicitly 946 // overrides these settings for themselves. 947 func ExampleECS_PutAccountSetting_shared00() { 948 svc := ecs.New(session.New()) 949 input := &ecs.PutAccountSettingInput{ 950 Name: aws.String("serviceLongArnFormat"), 951 Value: aws.String("enabled"), 952 } 953 954 result, err := svc.PutAccountSetting(input) 955 if err != nil { 956 if aerr, ok := err.(awserr.Error); ok { 957 switch aerr.Code() { 958 case ecs.ErrCodeServerException: 959 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 960 case ecs.ErrCodeClientException: 961 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 962 case ecs.ErrCodeInvalidParameterException: 963 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 964 default: 965 fmt.Println(aerr.Error()) 966 } 967 } else { 968 // Print the error, cast err to awserr.Error to get the Code and 969 // Message from an error. 970 fmt.Println(err.Error()) 971 } 972 return 973 } 974 975 fmt.Println(result) 976 } 977 978 // To modify the account settings for a specific IAM user or IAM role 979 // 980 // This example modifies the account setting for a specific IAM user or IAM role to 981 // opt in to the new ARN and resource ID format for Amazon ECS container instances. 982 // If you’re using this command as the root user, then changes apply to the entire 983 // AWS account, unless an IAM user or role explicitly overrides these settings for themselves. 984 func ExampleECS_PutAccountSetting_shared01() { 985 svc := ecs.New(session.New()) 986 input := &ecs.PutAccountSettingInput{ 987 Name: aws.String("containerInstanceLongArnFormat"), 988 PrincipalArn: aws.String("arn:aws:iam::<aws_account_id>:user/principalName"), 989 Value: aws.String("enabled"), 990 } 991 992 result, err := svc.PutAccountSetting(input) 993 if err != nil { 994 if aerr, ok := err.(awserr.Error); ok { 995 switch aerr.Code() { 996 case ecs.ErrCodeServerException: 997 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 998 case ecs.ErrCodeClientException: 999 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 1000 case ecs.ErrCodeInvalidParameterException: 1001 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 1002 default: 1003 fmt.Println(aerr.Error()) 1004 } 1005 } else { 1006 // Print the error, cast err to awserr.Error to get the Code and 1007 // Message from an error. 1008 fmt.Println(err.Error()) 1009 } 1010 return 1011 } 1012 1013 fmt.Println(result) 1014 } 1015 1016 // To modify the default account settings for all IAM users or roles on an account 1017 // 1018 // This example modifies the default account setting for the specified resource for 1019 // all IAM users or roles on an account. These changes apply to the entire AWS account, 1020 // unless an IAM user or role explicitly overrides these settings for themselves. 1021 func ExampleECS_PutAccountSettingDefault_shared00() { 1022 svc := ecs.New(session.New()) 1023 input := &ecs.PutAccountSettingDefaultInput{ 1024 Name: aws.String("serviceLongArnFormat"), 1025 Value: aws.String("enabled"), 1026 } 1027 1028 result, err := svc.PutAccountSettingDefault(input) 1029 if err != nil { 1030 if aerr, ok := err.(awserr.Error); ok { 1031 switch aerr.Code() { 1032 case ecs.ErrCodeServerException: 1033 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 1034 case ecs.ErrCodeClientException: 1035 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 1036 case ecs.ErrCodeInvalidParameterException: 1037 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 1038 default: 1039 fmt.Println(aerr.Error()) 1040 } 1041 } else { 1042 // Print the error, cast err to awserr.Error to get the Code and 1043 // Message from an error. 1044 fmt.Println(err.Error()) 1045 } 1046 return 1047 } 1048 1049 fmt.Println(result) 1050 } 1051 1052 // To register a task definition 1053 // 1054 // This example registers a task definition to the specified family. 1055 func ExampleECS_RegisterTaskDefinition_shared00() { 1056 svc := ecs.New(session.New()) 1057 input := &ecs.RegisterTaskDefinitionInput{ 1058 ContainerDefinitions: []*ecs.ContainerDefinition{ 1059 { 1060 Command: []*string{ 1061 aws.String("sleep"), 1062 aws.String("360"), 1063 }, 1064 Cpu: aws.Int64(10), 1065 Essential: aws.Bool(true), 1066 Image: aws.String("busybox"), 1067 Memory: aws.Int64(10), 1068 Name: aws.String("sleep"), 1069 }, 1070 }, 1071 Family: aws.String("sleep360"), 1072 TaskRoleArn: aws.String(""), 1073 } 1074 1075 result, err := svc.RegisterTaskDefinition(input) 1076 if err != nil { 1077 if aerr, ok := err.(awserr.Error); ok { 1078 switch aerr.Code() { 1079 case ecs.ErrCodeServerException: 1080 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 1081 case ecs.ErrCodeClientException: 1082 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 1083 case ecs.ErrCodeInvalidParameterException: 1084 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 1085 default: 1086 fmt.Println(aerr.Error()) 1087 } 1088 } else { 1089 // Print the error, cast err to awserr.Error to get the Code and 1090 // Message from an error. 1091 fmt.Println(err.Error()) 1092 } 1093 return 1094 } 1095 1096 fmt.Println(result) 1097 } 1098 1099 // To run a task on your default cluster 1100 // 1101 // This example runs the specified task definition on your default cluster. 1102 func ExampleECS_RunTask_shared00() { 1103 svc := ecs.New(session.New()) 1104 input := &ecs.RunTaskInput{ 1105 Cluster: aws.String("default"), 1106 TaskDefinition: aws.String("sleep360:1"), 1107 } 1108 1109 result, err := svc.RunTask(input) 1110 if err != nil { 1111 if aerr, ok := err.(awserr.Error); ok { 1112 switch aerr.Code() { 1113 case ecs.ErrCodeServerException: 1114 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 1115 case ecs.ErrCodeClientException: 1116 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 1117 case ecs.ErrCodeInvalidParameterException: 1118 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 1119 case ecs.ErrCodeClusterNotFoundException: 1120 fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) 1121 case ecs.ErrCodeUnsupportedFeatureException: 1122 fmt.Println(ecs.ErrCodeUnsupportedFeatureException, aerr.Error()) 1123 case ecs.ErrCodePlatformUnknownException: 1124 fmt.Println(ecs.ErrCodePlatformUnknownException, aerr.Error()) 1125 case ecs.ErrCodePlatformTaskDefinitionIncompatibilityException: 1126 fmt.Println(ecs.ErrCodePlatformTaskDefinitionIncompatibilityException, aerr.Error()) 1127 case ecs.ErrCodeAccessDeniedException: 1128 fmt.Println(ecs.ErrCodeAccessDeniedException, aerr.Error()) 1129 case ecs.ErrCodeBlockedException: 1130 fmt.Println(ecs.ErrCodeBlockedException, aerr.Error()) 1131 default: 1132 fmt.Println(aerr.Error()) 1133 } 1134 } else { 1135 // Print the error, cast err to awserr.Error to get the Code and 1136 // Message from an error. 1137 fmt.Println(err.Error()) 1138 } 1139 return 1140 } 1141 1142 fmt.Println(result) 1143 } 1144 1145 // To tag a cluster. 1146 // 1147 // This example tags the 'dev' cluster with key 'team' and value 'dev'. 1148 func ExampleECS_TagResource_shared00() { 1149 svc := ecs.New(session.New()) 1150 input := &ecs.TagResourceInput{ 1151 ResourceArn: aws.String("arn:aws:ecs:region:aws_account_id:cluster/dev"), 1152 Tags: []*ecs.Tag{ 1153 { 1154 Key: aws.String("team"), 1155 Value: aws.String("dev"), 1156 }, 1157 }, 1158 } 1159 1160 result, err := svc.TagResource(input) 1161 if err != nil { 1162 if aerr, ok := err.(awserr.Error); ok { 1163 switch aerr.Code() { 1164 case ecs.ErrCodeServerException: 1165 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 1166 case ecs.ErrCodeClientException: 1167 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 1168 case ecs.ErrCodeClusterNotFoundException: 1169 fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) 1170 case ecs.ErrCodeResourceNotFoundException: 1171 fmt.Println(ecs.ErrCodeResourceNotFoundException, aerr.Error()) 1172 case ecs.ErrCodeInvalidParameterException: 1173 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 1174 default: 1175 fmt.Println(aerr.Error()) 1176 } 1177 } else { 1178 // Print the error, cast err to awserr.Error to get the Code and 1179 // Message from an error. 1180 fmt.Println(err.Error()) 1181 } 1182 return 1183 } 1184 1185 fmt.Println(result) 1186 } 1187 1188 // To untag a cluster. 1189 // 1190 // This example deletes the 'team' tag from the 'dev' cluster. 1191 func ExampleECS_UntagResource_shared00() { 1192 svc := ecs.New(session.New()) 1193 input := &ecs.UntagResourceInput{ 1194 ResourceArn: aws.String("arn:aws:ecs:region:aws_account_id:cluster/dev"), 1195 TagKeys: []*string{ 1196 aws.String("team"), 1197 }, 1198 } 1199 1200 result, err := svc.UntagResource(input) 1201 if err != nil { 1202 if aerr, ok := err.(awserr.Error); ok { 1203 switch aerr.Code() { 1204 case ecs.ErrCodeServerException: 1205 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 1206 case ecs.ErrCodeClientException: 1207 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 1208 case ecs.ErrCodeClusterNotFoundException: 1209 fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) 1210 case ecs.ErrCodeResourceNotFoundException: 1211 fmt.Println(ecs.ErrCodeResourceNotFoundException, aerr.Error()) 1212 case ecs.ErrCodeInvalidParameterException: 1213 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 1214 default: 1215 fmt.Println(aerr.Error()) 1216 } 1217 } else { 1218 // Print the error, cast err to awserr.Error to get the Code and 1219 // Message from an error. 1220 fmt.Println(err.Error()) 1221 } 1222 return 1223 } 1224 1225 fmt.Println(result) 1226 } 1227 1228 // To change the task definition used in a service 1229 // 1230 // This example updates the my-http-service service to use the amazon-ecs-sample task 1231 // definition. 1232 func ExampleECS_UpdateService_shared00() { 1233 svc := ecs.New(session.New()) 1234 input := &ecs.UpdateServiceInput{ 1235 Service: aws.String("my-http-service"), 1236 TaskDefinition: aws.String("amazon-ecs-sample"), 1237 } 1238 1239 result, err := svc.UpdateService(input) 1240 if err != nil { 1241 if aerr, ok := err.(awserr.Error); ok { 1242 switch aerr.Code() { 1243 case ecs.ErrCodeServerException: 1244 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 1245 case ecs.ErrCodeClientException: 1246 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 1247 case ecs.ErrCodeInvalidParameterException: 1248 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 1249 case ecs.ErrCodeClusterNotFoundException: 1250 fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) 1251 case ecs.ErrCodeServiceNotFoundException: 1252 fmt.Println(ecs.ErrCodeServiceNotFoundException, aerr.Error()) 1253 case ecs.ErrCodeServiceNotActiveException: 1254 fmt.Println(ecs.ErrCodeServiceNotActiveException, aerr.Error()) 1255 case ecs.ErrCodePlatformUnknownException: 1256 fmt.Println(ecs.ErrCodePlatformUnknownException, aerr.Error()) 1257 case ecs.ErrCodePlatformTaskDefinitionIncompatibilityException: 1258 fmt.Println(ecs.ErrCodePlatformTaskDefinitionIncompatibilityException, aerr.Error()) 1259 case ecs.ErrCodeAccessDeniedException: 1260 fmt.Println(ecs.ErrCodeAccessDeniedException, aerr.Error()) 1261 default: 1262 fmt.Println(aerr.Error()) 1263 } 1264 } else { 1265 // Print the error, cast err to awserr.Error to get the Code and 1266 // Message from an error. 1267 fmt.Println(err.Error()) 1268 } 1269 return 1270 } 1271 1272 fmt.Println(result) 1273 } 1274 1275 // To change the number of tasks in a service 1276 // 1277 // This example updates the desired count of the my-http-service service to 10. 1278 func ExampleECS_UpdateService_shared01() { 1279 svc := ecs.New(session.New()) 1280 input := &ecs.UpdateServiceInput{ 1281 DesiredCount: aws.Int64(10), 1282 Service: aws.String("my-http-service"), 1283 } 1284 1285 result, err := svc.UpdateService(input) 1286 if err != nil { 1287 if aerr, ok := err.(awserr.Error); ok { 1288 switch aerr.Code() { 1289 case ecs.ErrCodeServerException: 1290 fmt.Println(ecs.ErrCodeServerException, aerr.Error()) 1291 case ecs.ErrCodeClientException: 1292 fmt.Println(ecs.ErrCodeClientException, aerr.Error()) 1293 case ecs.ErrCodeInvalidParameterException: 1294 fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) 1295 case ecs.ErrCodeClusterNotFoundException: 1296 fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) 1297 case ecs.ErrCodeServiceNotFoundException: 1298 fmt.Println(ecs.ErrCodeServiceNotFoundException, aerr.Error()) 1299 case ecs.ErrCodeServiceNotActiveException: 1300 fmt.Println(ecs.ErrCodeServiceNotActiveException, aerr.Error()) 1301 case ecs.ErrCodePlatformUnknownException: 1302 fmt.Println(ecs.ErrCodePlatformUnknownException, aerr.Error()) 1303 case ecs.ErrCodePlatformTaskDefinitionIncompatibilityException: 1304 fmt.Println(ecs.ErrCodePlatformTaskDefinitionIncompatibilityException, aerr.Error()) 1305 case ecs.ErrCodeAccessDeniedException: 1306 fmt.Println(ecs.ErrCodeAccessDeniedException, aerr.Error()) 1307 default: 1308 fmt.Println(aerr.Error()) 1309 } 1310 } else { 1311 // Print the error, cast err to awserr.Error to get the Code and 1312 // Message from an error. 1313 fmt.Println(err.Error()) 1314 } 1315 return 1316 } 1317 1318 fmt.Println(result) 1319 }