github.com/aavshr/aws-sdk-go@v1.41.3/service/elasticbeanstalk/examples_test.go (about) 1 // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 3 package elasticbeanstalk_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/elasticbeanstalk" 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 abort a deployment 29 // 30 // The following code aborts a running application version deployment for an environment 31 // named my-env: 32 func ExampleElasticBeanstalk_AbortEnvironmentUpdate_shared00() { 33 svc := elasticbeanstalk.New(session.New()) 34 input := &elasticbeanstalk.AbortEnvironmentUpdateInput{ 35 EnvironmentName: aws.String("my-env"), 36 } 37 38 result, err := svc.AbortEnvironmentUpdate(input) 39 if err != nil { 40 if aerr, ok := err.(awserr.Error); ok { 41 switch aerr.Code() { 42 case elasticbeanstalk.ErrCodeInsufficientPrivilegesException: 43 fmt.Println(elasticbeanstalk.ErrCodeInsufficientPrivilegesException, aerr.Error()) 44 default: 45 fmt.Println(aerr.Error()) 46 } 47 } else { 48 // Print the error, cast err to awserr.Error to get the Code and 49 // Message from an error. 50 fmt.Println(err.Error()) 51 } 52 return 53 } 54 55 fmt.Println(result) 56 } 57 58 // To check the availability of a CNAME 59 // 60 // The following operation checks the availability of the subdomain my-cname: 61 func ExampleElasticBeanstalk_CheckDNSAvailability_shared00() { 62 svc := elasticbeanstalk.New(session.New()) 63 input := &elasticbeanstalk.CheckDNSAvailabilityInput{ 64 CNAMEPrefix: aws.String("my-cname"), 65 } 66 67 result, err := svc.CheckDNSAvailability(input) 68 if err != nil { 69 if aerr, ok := err.(awserr.Error); ok { 70 switch aerr.Code() { 71 default: 72 fmt.Println(aerr.Error()) 73 } 74 } else { 75 // Print the error, cast err to awserr.Error to get the Code and 76 // Message from an error. 77 fmt.Println(err.Error()) 78 } 79 return 80 } 81 82 fmt.Println(result) 83 } 84 85 // To create a new application 86 // 87 // The following operation creates a new application named my-app: 88 func ExampleElasticBeanstalk_CreateApplication_shared00() { 89 svc := elasticbeanstalk.New(session.New()) 90 input := &elasticbeanstalk.CreateApplicationInput{ 91 ApplicationName: aws.String("my-app"), 92 Description: aws.String("my application"), 93 } 94 95 result, err := svc.CreateApplication(input) 96 if err != nil { 97 if aerr, ok := err.(awserr.Error); ok { 98 switch aerr.Code() { 99 case elasticbeanstalk.ErrCodeTooManyApplicationsException: 100 fmt.Println(elasticbeanstalk.ErrCodeTooManyApplicationsException, aerr.Error()) 101 default: 102 fmt.Println(aerr.Error()) 103 } 104 } else { 105 // Print the error, cast err to awserr.Error to get the Code and 106 // Message from an error. 107 fmt.Println(err.Error()) 108 } 109 return 110 } 111 112 fmt.Println(result) 113 } 114 115 // To create a new application 116 // 117 // The following operation creates a new version (v1) of an application named my-app: 118 func ExampleElasticBeanstalk_CreateApplicationVersion_shared00() { 119 svc := elasticbeanstalk.New(session.New()) 120 input := &elasticbeanstalk.CreateApplicationVersionInput{ 121 ApplicationName: aws.String("my-app"), 122 AutoCreateApplication: aws.Bool(true), 123 Description: aws.String("my-app-v1"), 124 Process: aws.Bool(true), 125 SourceBundle: &elasticbeanstalk.S3Location{ 126 S3Bucket: aws.String("my-bucket"), 127 S3Key: aws.String("sample.war"), 128 }, 129 VersionLabel: aws.String("v1"), 130 } 131 132 result, err := svc.CreateApplicationVersion(input) 133 if err != nil { 134 if aerr, ok := err.(awserr.Error); ok { 135 switch aerr.Code() { 136 case elasticbeanstalk.ErrCodeTooManyApplicationsException: 137 fmt.Println(elasticbeanstalk.ErrCodeTooManyApplicationsException, aerr.Error()) 138 case elasticbeanstalk.ErrCodeTooManyApplicationVersionsException: 139 fmt.Println(elasticbeanstalk.ErrCodeTooManyApplicationVersionsException, aerr.Error()) 140 case elasticbeanstalk.ErrCodeInsufficientPrivilegesException: 141 fmt.Println(elasticbeanstalk.ErrCodeInsufficientPrivilegesException, aerr.Error()) 142 case elasticbeanstalk.ErrCodeS3LocationNotInServiceRegionException: 143 fmt.Println(elasticbeanstalk.ErrCodeS3LocationNotInServiceRegionException, aerr.Error()) 144 case elasticbeanstalk.ErrCodeCodeBuildNotInServiceRegionException: 145 fmt.Println(elasticbeanstalk.ErrCodeCodeBuildNotInServiceRegionException, aerr.Error()) 146 default: 147 fmt.Println(aerr.Error()) 148 } 149 } else { 150 // Print the error, cast err to awserr.Error to get the Code and 151 // Message from an error. 152 fmt.Println(err.Error()) 153 } 154 return 155 } 156 157 fmt.Println(result) 158 } 159 160 // To create a configuration template 161 // 162 // The following operation creates a configuration template named my-app-v1 from the 163 // settings applied to an environment with the id e-rpqsewtp2j: 164 func ExampleElasticBeanstalk_CreateConfigurationTemplate_shared00() { 165 svc := elasticbeanstalk.New(session.New()) 166 input := &elasticbeanstalk.CreateConfigurationTemplateInput{ 167 ApplicationName: aws.String("my-app"), 168 EnvironmentId: aws.String("e-rpqsewtp2j"), 169 TemplateName: aws.String("my-app-v1"), 170 } 171 172 result, err := svc.CreateConfigurationTemplate(input) 173 if err != nil { 174 if aerr, ok := err.(awserr.Error); ok { 175 switch aerr.Code() { 176 case elasticbeanstalk.ErrCodeInsufficientPrivilegesException: 177 fmt.Println(elasticbeanstalk.ErrCodeInsufficientPrivilegesException, aerr.Error()) 178 case elasticbeanstalk.ErrCodeTooManyBucketsException: 179 fmt.Println(elasticbeanstalk.ErrCodeTooManyBucketsException, aerr.Error()) 180 case elasticbeanstalk.ErrCodeTooManyConfigurationTemplatesException: 181 fmt.Println(elasticbeanstalk.ErrCodeTooManyConfigurationTemplatesException, aerr.Error()) 182 default: 183 fmt.Println(aerr.Error()) 184 } 185 } else { 186 // Print the error, cast err to awserr.Error to get the Code and 187 // Message from an error. 188 fmt.Println(err.Error()) 189 } 190 return 191 } 192 193 fmt.Println(result) 194 } 195 196 // To create a new environment for an application 197 // 198 // The following operation creates a new environment for version v1 of a java application 199 // named my-app: 200 func ExampleElasticBeanstalk_CreateEnvironment_shared00() { 201 svc := elasticbeanstalk.New(session.New()) 202 input := &elasticbeanstalk.CreateEnvironmentInput{ 203 ApplicationName: aws.String("my-app"), 204 CNAMEPrefix: aws.String("my-app"), 205 EnvironmentName: aws.String("my-env"), 206 SolutionStackName: aws.String("64bit Amazon Linux 2015.03 v2.0.0 running Tomcat 8 Java 8"), 207 VersionLabel: aws.String("v1"), 208 } 209 210 result, err := svc.CreateEnvironment(input) 211 if err != nil { 212 if aerr, ok := err.(awserr.Error); ok { 213 switch aerr.Code() { 214 case elasticbeanstalk.ErrCodeTooManyEnvironmentsException: 215 fmt.Println(elasticbeanstalk.ErrCodeTooManyEnvironmentsException, aerr.Error()) 216 case elasticbeanstalk.ErrCodeInsufficientPrivilegesException: 217 fmt.Println(elasticbeanstalk.ErrCodeInsufficientPrivilegesException, aerr.Error()) 218 default: 219 fmt.Println(aerr.Error()) 220 } 221 } else { 222 // Print the error, cast err to awserr.Error to get the Code and 223 // Message from an error. 224 fmt.Println(err.Error()) 225 } 226 return 227 } 228 229 fmt.Println(result) 230 } 231 232 // To create a new environment for an application 233 // 234 // The following operation creates a new environment for version v1 of a java application 235 // named my-app: 236 func ExampleElasticBeanstalk_CreateStorageLocation_shared00() { 237 svc := elasticbeanstalk.New(session.New()) 238 input := &elasticbeanstalk.CreateStorageLocationInput{} 239 240 result, err := svc.CreateStorageLocation(input) 241 if err != nil { 242 if aerr, ok := err.(awserr.Error); ok { 243 switch aerr.Code() { 244 case elasticbeanstalk.ErrCodeTooManyBucketsException: 245 fmt.Println(elasticbeanstalk.ErrCodeTooManyBucketsException, aerr.Error()) 246 case elasticbeanstalk.ErrCodeS3SubscriptionRequiredException: 247 fmt.Println(elasticbeanstalk.ErrCodeS3SubscriptionRequiredException, aerr.Error()) 248 case elasticbeanstalk.ErrCodeInsufficientPrivilegesException: 249 fmt.Println(elasticbeanstalk.ErrCodeInsufficientPrivilegesException, aerr.Error()) 250 default: 251 fmt.Println(aerr.Error()) 252 } 253 } else { 254 // Print the error, cast err to awserr.Error to get the Code and 255 // Message from an error. 256 fmt.Println(err.Error()) 257 } 258 return 259 } 260 261 fmt.Println(result) 262 } 263 264 // To delete an application 265 // 266 // The following operation deletes an application named my-app: 267 func ExampleElasticBeanstalk_DeleteApplication_shared00() { 268 svc := elasticbeanstalk.New(session.New()) 269 input := &elasticbeanstalk.DeleteApplicationInput{ 270 ApplicationName: aws.String("my-app"), 271 } 272 273 result, err := svc.DeleteApplication(input) 274 if err != nil { 275 if aerr, ok := err.(awserr.Error); ok { 276 switch aerr.Code() { 277 case elasticbeanstalk.ErrCodeOperationInProgressException: 278 fmt.Println(elasticbeanstalk.ErrCodeOperationInProgressException, aerr.Error()) 279 default: 280 fmt.Println(aerr.Error()) 281 } 282 } else { 283 // Print the error, cast err to awserr.Error to get the Code and 284 // Message from an error. 285 fmt.Println(err.Error()) 286 } 287 return 288 } 289 290 fmt.Println(result) 291 } 292 293 // To delete an application version 294 // 295 // The following operation deletes an application version named 22a0-stage-150819_182129 296 // for an application named my-app: 297 func ExampleElasticBeanstalk_DeleteApplicationVersion_shared00() { 298 svc := elasticbeanstalk.New(session.New()) 299 input := &elasticbeanstalk.DeleteApplicationVersionInput{ 300 ApplicationName: aws.String("my-app"), 301 DeleteSourceBundle: aws.Bool(true), 302 VersionLabel: aws.String("22a0-stage-150819_182129"), 303 } 304 305 result, err := svc.DeleteApplicationVersion(input) 306 if err != nil { 307 if aerr, ok := err.(awserr.Error); ok { 308 switch aerr.Code() { 309 case elasticbeanstalk.ErrCodeSourceBundleDeletionException: 310 fmt.Println(elasticbeanstalk.ErrCodeSourceBundleDeletionException, aerr.Error()) 311 case elasticbeanstalk.ErrCodeInsufficientPrivilegesException: 312 fmt.Println(elasticbeanstalk.ErrCodeInsufficientPrivilegesException, aerr.Error()) 313 case elasticbeanstalk.ErrCodeOperationInProgressException: 314 fmt.Println(elasticbeanstalk.ErrCodeOperationInProgressException, aerr.Error()) 315 case elasticbeanstalk.ErrCodeS3LocationNotInServiceRegionException: 316 fmt.Println(elasticbeanstalk.ErrCodeS3LocationNotInServiceRegionException, aerr.Error()) 317 default: 318 fmt.Println(aerr.Error()) 319 } 320 } else { 321 // Print the error, cast err to awserr.Error to get the Code and 322 // Message from an error. 323 fmt.Println(err.Error()) 324 } 325 return 326 } 327 328 fmt.Println(result) 329 } 330 331 // To delete a configuration template 332 // 333 // The following operation deletes a configuration template named my-template for an 334 // application named my-app: 335 func ExampleElasticBeanstalk_DeleteConfigurationTemplate_shared00() { 336 svc := elasticbeanstalk.New(session.New()) 337 input := &elasticbeanstalk.DeleteConfigurationTemplateInput{ 338 ApplicationName: aws.String("my-app"), 339 TemplateName: aws.String("my-template"), 340 } 341 342 result, err := svc.DeleteConfigurationTemplate(input) 343 if err != nil { 344 if aerr, ok := err.(awserr.Error); ok { 345 switch aerr.Code() { 346 case elasticbeanstalk.ErrCodeOperationInProgressException: 347 fmt.Println(elasticbeanstalk.ErrCodeOperationInProgressException, aerr.Error()) 348 default: 349 fmt.Println(aerr.Error()) 350 } 351 } else { 352 // Print the error, cast err to awserr.Error to get the Code and 353 // Message from an error. 354 fmt.Println(err.Error()) 355 } 356 return 357 } 358 359 fmt.Println(result) 360 } 361 362 // To delete a draft configuration 363 // 364 // The following operation deletes a draft configuration for an environment named my-env: 365 func ExampleElasticBeanstalk_DeleteEnvironmentConfiguration_shared00() { 366 svc := elasticbeanstalk.New(session.New()) 367 input := &elasticbeanstalk.DeleteEnvironmentConfigurationInput{ 368 ApplicationName: aws.String("my-app"), 369 EnvironmentName: aws.String("my-env"), 370 } 371 372 result, err := svc.DeleteEnvironmentConfiguration(input) 373 if err != nil { 374 if aerr, ok := err.(awserr.Error); ok { 375 switch aerr.Code() { 376 default: 377 fmt.Println(aerr.Error()) 378 } 379 } else { 380 // Print the error, cast err to awserr.Error to get the Code and 381 // Message from an error. 382 fmt.Println(err.Error()) 383 } 384 return 385 } 386 387 fmt.Println(result) 388 } 389 390 // To view information about an application version 391 // 392 // The following operation retrieves information about an application version labeled 393 // v2: 394 func ExampleElasticBeanstalk_DescribeApplicationVersions_shared00() { 395 svc := elasticbeanstalk.New(session.New()) 396 input := &elasticbeanstalk.DescribeApplicationVersionsInput{ 397 ApplicationName: aws.String("my-app"), 398 VersionLabels: []*string{ 399 aws.String("v2"), 400 }, 401 } 402 403 result, err := svc.DescribeApplicationVersions(input) 404 if err != nil { 405 if aerr, ok := err.(awserr.Error); ok { 406 switch aerr.Code() { 407 default: 408 fmt.Println(aerr.Error()) 409 } 410 } else { 411 // Print the error, cast err to awserr.Error to get the Code and 412 // Message from an error. 413 fmt.Println(err.Error()) 414 } 415 return 416 } 417 418 fmt.Println(result) 419 } 420 421 // To view a list of applications 422 // 423 // The following operation retrieves information about applications in the current region: 424 func ExampleElasticBeanstalk_DescribeApplications_shared00() { 425 svc := elasticbeanstalk.New(session.New()) 426 input := &elasticbeanstalk.DescribeApplicationsInput{} 427 428 result, err := svc.DescribeApplications(input) 429 if err != nil { 430 if aerr, ok := err.(awserr.Error); ok { 431 switch aerr.Code() { 432 default: 433 fmt.Println(aerr.Error()) 434 } 435 } else { 436 // Print the error, cast err to awserr.Error to get the Code and 437 // Message from an error. 438 fmt.Println(err.Error()) 439 } 440 return 441 } 442 443 fmt.Println(result) 444 } 445 446 // To view configuration options for an environment 447 // 448 // The following operation retrieves descriptions of all available configuration options 449 // for an environment named my-env: 450 func ExampleElasticBeanstalk_DescribeConfigurationOptions_shared00() { 451 svc := elasticbeanstalk.New(session.New()) 452 input := &elasticbeanstalk.DescribeConfigurationOptionsInput{ 453 ApplicationName: aws.String("my-app"), 454 EnvironmentName: aws.String("my-env"), 455 } 456 457 result, err := svc.DescribeConfigurationOptions(input) 458 if err != nil { 459 if aerr, ok := err.(awserr.Error); ok { 460 switch aerr.Code() { 461 case elasticbeanstalk.ErrCodeTooManyBucketsException: 462 fmt.Println(elasticbeanstalk.ErrCodeTooManyBucketsException, aerr.Error()) 463 default: 464 fmt.Println(aerr.Error()) 465 } 466 } else { 467 // Print the error, cast err to awserr.Error to get the Code and 468 // Message from an error. 469 fmt.Println(err.Error()) 470 } 471 return 472 } 473 474 fmt.Println(result) 475 } 476 477 // To view configurations settings for an environment 478 // 479 // The following operation retrieves configuration settings for an environment named 480 // my-env: 481 func ExampleElasticBeanstalk_DescribeConfigurationSettings_shared00() { 482 svc := elasticbeanstalk.New(session.New()) 483 input := &elasticbeanstalk.DescribeConfigurationSettingsInput{ 484 ApplicationName: aws.String("my-app"), 485 EnvironmentName: aws.String("my-env"), 486 } 487 488 result, err := svc.DescribeConfigurationSettings(input) 489 if err != nil { 490 if aerr, ok := err.(awserr.Error); ok { 491 switch aerr.Code() { 492 case elasticbeanstalk.ErrCodeTooManyBucketsException: 493 fmt.Println(elasticbeanstalk.ErrCodeTooManyBucketsException, aerr.Error()) 494 default: 495 fmt.Println(aerr.Error()) 496 } 497 } else { 498 // Print the error, cast err to awserr.Error to get the Code and 499 // Message from an error. 500 fmt.Println(err.Error()) 501 } 502 return 503 } 504 505 fmt.Println(result) 506 } 507 508 // To view environment health 509 // 510 // The following operation retrieves overall health information for an environment named 511 // my-env: 512 func ExampleElasticBeanstalk_DescribeEnvironmentHealth_shared00() { 513 svc := elasticbeanstalk.New(session.New()) 514 input := &elasticbeanstalk.DescribeEnvironmentHealthInput{ 515 AttributeNames: []*string{ 516 aws.String("All"), 517 }, 518 EnvironmentName: aws.String("my-env"), 519 } 520 521 result, err := svc.DescribeEnvironmentHealth(input) 522 if err != nil { 523 if aerr, ok := err.(awserr.Error); ok { 524 switch aerr.Code() { 525 case elasticbeanstalk.ErrCodeInvalidRequestException: 526 fmt.Println(elasticbeanstalk.ErrCodeInvalidRequestException, aerr.Error()) 527 case elasticbeanstalk.ErrCodeServiceException: 528 fmt.Println(elasticbeanstalk.ErrCodeServiceException, aerr.Error()) 529 default: 530 fmt.Println(aerr.Error()) 531 } 532 } else { 533 // Print the error, cast err to awserr.Error to get the Code and 534 // Message from an error. 535 fmt.Println(err.Error()) 536 } 537 return 538 } 539 540 fmt.Println(result) 541 } 542 543 // To view information about the AWS resources in your environment 544 // 545 // The following operation retrieves information about resources in an environment named 546 // my-env: 547 func ExampleElasticBeanstalk_DescribeEnvironmentResources_shared00() { 548 svc := elasticbeanstalk.New(session.New()) 549 input := &elasticbeanstalk.DescribeEnvironmentResourcesInput{ 550 EnvironmentName: aws.String("my-env"), 551 } 552 553 result, err := svc.DescribeEnvironmentResources(input) 554 if err != nil { 555 if aerr, ok := err.(awserr.Error); ok { 556 switch aerr.Code() { 557 case elasticbeanstalk.ErrCodeInsufficientPrivilegesException: 558 fmt.Println(elasticbeanstalk.ErrCodeInsufficientPrivilegesException, aerr.Error()) 559 default: 560 fmt.Println(aerr.Error()) 561 } 562 } else { 563 // Print the error, cast err to awserr.Error to get the Code and 564 // Message from an error. 565 fmt.Println(err.Error()) 566 } 567 return 568 } 569 570 fmt.Println(result) 571 } 572 573 // To view information about an environment 574 // 575 // The following operation retrieves information about an environment named my-env: 576 func ExampleElasticBeanstalk_DescribeEnvironments_shared00() { 577 svc := elasticbeanstalk.New(session.New()) 578 input := &elasticbeanstalk.DescribeEnvironmentsInput{ 579 EnvironmentNames: []*string{ 580 aws.String("my-env"), 581 }, 582 } 583 584 result, err := svc.DescribeEnvironments(input) 585 if err != nil { 586 if aerr, ok := err.(awserr.Error); ok { 587 switch aerr.Code() { 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 view events for an environment 603 // 604 // The following operation retrieves events for an environment named my-env: 605 func ExampleElasticBeanstalk_DescribeEvents_shared00() { 606 svc := elasticbeanstalk.New(session.New()) 607 input := &elasticbeanstalk.DescribeEventsInput{ 608 EnvironmentName: aws.String("my-env"), 609 } 610 611 result, err := svc.DescribeEvents(input) 612 if err != nil { 613 if aerr, ok := err.(awserr.Error); ok { 614 switch aerr.Code() { 615 default: 616 fmt.Println(aerr.Error()) 617 } 618 } else { 619 // Print the error, cast err to awserr.Error to get the Code and 620 // Message from an error. 621 fmt.Println(err.Error()) 622 } 623 return 624 } 625 626 fmt.Println(result) 627 } 628 629 // To view environment health 630 // 631 // The following operation retrieves health information for instances in an environment 632 // named my-env: 633 func ExampleElasticBeanstalk_DescribeInstancesHealth_shared00() { 634 svc := elasticbeanstalk.New(session.New()) 635 input := &elasticbeanstalk.DescribeInstancesHealthInput{ 636 AttributeNames: []*string{ 637 aws.String("All"), 638 }, 639 EnvironmentName: aws.String("my-env"), 640 } 641 642 result, err := svc.DescribeInstancesHealth(input) 643 if err != nil { 644 if aerr, ok := err.(awserr.Error); ok { 645 switch aerr.Code() { 646 case elasticbeanstalk.ErrCodeInvalidRequestException: 647 fmt.Println(elasticbeanstalk.ErrCodeInvalidRequestException, aerr.Error()) 648 case elasticbeanstalk.ErrCodeServiceException: 649 fmt.Println(elasticbeanstalk.ErrCodeServiceException, aerr.Error()) 650 default: 651 fmt.Println(aerr.Error()) 652 } 653 } else { 654 // Print the error, cast err to awserr.Error to get the Code and 655 // Message from an error. 656 fmt.Println(err.Error()) 657 } 658 return 659 } 660 661 fmt.Println(result) 662 } 663 664 // To view solution stacks 665 // 666 // The following operation lists solution stacks for all currently available platform 667 // configurations and any that you have used in the past: 668 func ExampleElasticBeanstalk_ListAvailableSolutionStacks_shared00() { 669 svc := elasticbeanstalk.New(session.New()) 670 input := &elasticbeanstalk.ListAvailableSolutionStacksInput{} 671 672 result, err := svc.ListAvailableSolutionStacks(input) 673 if err != nil { 674 if aerr, ok := err.(awserr.Error); ok { 675 switch aerr.Code() { 676 default: 677 fmt.Println(aerr.Error()) 678 } 679 } else { 680 // Print the error, cast err to awserr.Error to get the Code and 681 // Message from an error. 682 fmt.Println(err.Error()) 683 } 684 return 685 } 686 687 fmt.Println(result) 688 } 689 690 // To rebuild an environment 691 // 692 // The following operation terminates and recreates the resources in an environment 693 // named my-env: 694 func ExampleElasticBeanstalk_RebuildEnvironment_shared00() { 695 svc := elasticbeanstalk.New(session.New()) 696 input := &elasticbeanstalk.RebuildEnvironmentInput{ 697 EnvironmentName: aws.String("my-env"), 698 } 699 700 result, err := svc.RebuildEnvironment(input) 701 if err != nil { 702 if aerr, ok := err.(awserr.Error); ok { 703 switch aerr.Code() { 704 case elasticbeanstalk.ErrCodeInsufficientPrivilegesException: 705 fmt.Println(elasticbeanstalk.ErrCodeInsufficientPrivilegesException, aerr.Error()) 706 default: 707 fmt.Println(aerr.Error()) 708 } 709 } else { 710 // Print the error, cast err to awserr.Error to get the Code and 711 // Message from an error. 712 fmt.Println(err.Error()) 713 } 714 return 715 } 716 717 fmt.Println(result) 718 } 719 720 // To request tailed logs 721 // 722 // The following operation requests logs from an environment named my-env: 723 func ExampleElasticBeanstalk_RequestEnvironmentInfo_shared00() { 724 svc := elasticbeanstalk.New(session.New()) 725 input := &elasticbeanstalk.RequestEnvironmentInfoInput{ 726 EnvironmentName: aws.String("my-env"), 727 InfoType: aws.String("tail"), 728 } 729 730 result, err := svc.RequestEnvironmentInfo(input) 731 if err != nil { 732 if aerr, ok := err.(awserr.Error); ok { 733 switch aerr.Code() { 734 default: 735 fmt.Println(aerr.Error()) 736 } 737 } else { 738 // Print the error, cast err to awserr.Error to get the Code and 739 // Message from an error. 740 fmt.Println(err.Error()) 741 } 742 return 743 } 744 745 fmt.Println(result) 746 } 747 748 // To restart application servers 749 // 750 // The following operation restarts application servers on all instances in an environment 751 // named my-env: 752 func ExampleElasticBeanstalk_RestartAppServer_shared00() { 753 svc := elasticbeanstalk.New(session.New()) 754 input := &elasticbeanstalk.RestartAppServerInput{ 755 EnvironmentName: aws.String("my-env"), 756 } 757 758 result, err := svc.RestartAppServer(input) 759 if err != nil { 760 if aerr, ok := err.(awserr.Error); ok { 761 switch aerr.Code() { 762 default: 763 fmt.Println(aerr.Error()) 764 } 765 } else { 766 // Print the error, cast err to awserr.Error to get the Code and 767 // Message from an error. 768 fmt.Println(err.Error()) 769 } 770 return 771 } 772 773 fmt.Println(result) 774 } 775 776 // To retrieve tailed logs 777 // 778 // The following operation retrieves a link to logs from an environment named my-env: 779 func ExampleElasticBeanstalk_RetrieveEnvironmentInfo_shared00() { 780 svc := elasticbeanstalk.New(session.New()) 781 input := &elasticbeanstalk.RetrieveEnvironmentInfoInput{ 782 EnvironmentName: aws.String("my-env"), 783 InfoType: aws.String("tail"), 784 } 785 786 result, err := svc.RetrieveEnvironmentInfo(input) 787 if err != nil { 788 if aerr, ok := err.(awserr.Error); ok { 789 switch aerr.Code() { 790 default: 791 fmt.Println(aerr.Error()) 792 } 793 } else { 794 // Print the error, cast err to awserr.Error to get the Code and 795 // Message from an error. 796 fmt.Println(err.Error()) 797 } 798 return 799 } 800 801 fmt.Println(result) 802 } 803 804 // To swap environment CNAMES 805 // 806 // The following operation swaps the assigned subdomains of two environments: 807 func ExampleElasticBeanstalk_SwapEnvironmentCNAMEs_shared00() { 808 svc := elasticbeanstalk.New(session.New()) 809 input := &elasticbeanstalk.SwapEnvironmentCNAMEsInput{ 810 DestinationEnvironmentName: aws.String("my-env-green"), 811 SourceEnvironmentName: aws.String("my-env-blue"), 812 } 813 814 result, err := svc.SwapEnvironmentCNAMEs(input) 815 if err != nil { 816 if aerr, ok := err.(awserr.Error); ok { 817 switch aerr.Code() { 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 terminate an environment 833 // 834 // The following operation terminates an Elastic Beanstalk environment named my-env: 835 func ExampleElasticBeanstalk_TerminateEnvironment_shared00() { 836 svc := elasticbeanstalk.New(session.New()) 837 input := &elasticbeanstalk.TerminateEnvironmentInput{ 838 EnvironmentName: aws.String("my-env"), 839 } 840 841 result, err := svc.TerminateEnvironment(input) 842 if err != nil { 843 if aerr, ok := err.(awserr.Error); ok { 844 switch aerr.Code() { 845 case elasticbeanstalk.ErrCodeInsufficientPrivilegesException: 846 fmt.Println(elasticbeanstalk.ErrCodeInsufficientPrivilegesException, aerr.Error()) 847 default: 848 fmt.Println(aerr.Error()) 849 } 850 } else { 851 // Print the error, cast err to awserr.Error to get the Code and 852 // Message from an error. 853 fmt.Println(err.Error()) 854 } 855 return 856 } 857 858 fmt.Println(result) 859 } 860 861 // To change an application's description 862 // 863 // The following operation updates the description of an application named my-app: 864 func ExampleElasticBeanstalk_UpdateApplication_shared00() { 865 svc := elasticbeanstalk.New(session.New()) 866 input := &elasticbeanstalk.UpdateApplicationInput{ 867 ApplicationName: aws.String("my-app"), 868 Description: aws.String("my Elastic Beanstalk application"), 869 } 870 871 result, err := svc.UpdateApplication(input) 872 if err != nil { 873 if aerr, ok := err.(awserr.Error); ok { 874 switch aerr.Code() { 875 default: 876 fmt.Println(aerr.Error()) 877 } 878 } else { 879 // Print the error, cast err to awserr.Error to get the Code and 880 // Message from an error. 881 fmt.Println(err.Error()) 882 } 883 return 884 } 885 886 fmt.Println(result) 887 } 888 889 // To change an application version's description 890 // 891 // The following operation updates the description of an application version named 22a0-stage-150819_185942: 892 func ExampleElasticBeanstalk_UpdateApplicationVersion_shared00() { 893 svc := elasticbeanstalk.New(session.New()) 894 input := &elasticbeanstalk.UpdateApplicationVersionInput{ 895 ApplicationName: aws.String("my-app"), 896 Description: aws.String("new description"), 897 VersionLabel: aws.String("22a0-stage-150819_185942"), 898 } 899 900 result, err := svc.UpdateApplicationVersion(input) 901 if err != nil { 902 if aerr, ok := err.(awserr.Error); ok { 903 switch aerr.Code() { 904 default: 905 fmt.Println(aerr.Error()) 906 } 907 } else { 908 // Print the error, cast err to awserr.Error to get the Code and 909 // Message from an error. 910 fmt.Println(err.Error()) 911 } 912 return 913 } 914 915 fmt.Println(result) 916 } 917 918 // To update a configuration template 919 // 920 // The following operation removes the configured CloudWatch custom health metrics configuration 921 // ConfigDocument from a saved configuration template named my-template: 922 func ExampleElasticBeanstalk_UpdateConfigurationTemplate_shared00() { 923 svc := elasticbeanstalk.New(session.New()) 924 input := &elasticbeanstalk.UpdateConfigurationTemplateInput{ 925 ApplicationName: aws.String("my-app"), 926 OptionsToRemove: []*elasticbeanstalk.OptionSpecification{ 927 { 928 Namespace: aws.String("aws:elasticbeanstalk:healthreporting:system"), 929 OptionName: aws.String("ConfigDocument"), 930 }, 931 }, 932 TemplateName: aws.String("my-template"), 933 } 934 935 result, err := svc.UpdateConfigurationTemplate(input) 936 if err != nil { 937 if aerr, ok := err.(awserr.Error); ok { 938 switch aerr.Code() { 939 case elasticbeanstalk.ErrCodeInsufficientPrivilegesException: 940 fmt.Println(elasticbeanstalk.ErrCodeInsufficientPrivilegesException, aerr.Error()) 941 case elasticbeanstalk.ErrCodeTooManyBucketsException: 942 fmt.Println(elasticbeanstalk.ErrCodeTooManyBucketsException, aerr.Error()) 943 default: 944 fmt.Println(aerr.Error()) 945 } 946 } else { 947 // Print the error, cast err to awserr.Error to get the Code and 948 // Message from an error. 949 fmt.Println(err.Error()) 950 } 951 return 952 } 953 954 fmt.Println(result) 955 } 956 957 // To update an environment to a new version 958 // 959 // The following operation updates an environment named "my-env" to version "v2" of 960 // the application to which it belongs: 961 func ExampleElasticBeanstalk_UpdateEnvironment_shared00() { 962 svc := elasticbeanstalk.New(session.New()) 963 input := &elasticbeanstalk.UpdateEnvironmentInput{ 964 EnvironmentName: aws.String("my-env"), 965 VersionLabel: aws.String("v2"), 966 } 967 968 result, err := svc.UpdateEnvironment(input) 969 if err != nil { 970 if aerr, ok := err.(awserr.Error); ok { 971 switch aerr.Code() { 972 case elasticbeanstalk.ErrCodeInsufficientPrivilegesException: 973 fmt.Println(elasticbeanstalk.ErrCodeInsufficientPrivilegesException, aerr.Error()) 974 case elasticbeanstalk.ErrCodeTooManyBucketsException: 975 fmt.Println(elasticbeanstalk.ErrCodeTooManyBucketsException, aerr.Error()) 976 default: 977 fmt.Println(aerr.Error()) 978 } 979 } else { 980 // Print the error, cast err to awserr.Error to get the Code and 981 // Message from an error. 982 fmt.Println(err.Error()) 983 } 984 return 985 } 986 987 fmt.Println(result) 988 } 989 990 // To configure option settings 991 // 992 // The following operation configures several options in the aws:elb:loadbalancer namespace: 993 func ExampleElasticBeanstalk_UpdateEnvironment_shared01() { 994 svc := elasticbeanstalk.New(session.New()) 995 input := &elasticbeanstalk.UpdateEnvironmentInput{ 996 EnvironmentName: aws.String("my-env"), 997 OptionSettings: []*elasticbeanstalk.ConfigurationOptionSetting{ 998 { 999 Namespace: aws.String("aws:elb:healthcheck"), 1000 OptionName: aws.String("Interval"), 1001 Value: aws.String("15"), 1002 }, 1003 { 1004 Namespace: aws.String("aws:elb:healthcheck"), 1005 OptionName: aws.String("Timeout"), 1006 Value: aws.String("8"), 1007 }, 1008 { 1009 Namespace: aws.String("aws:elb:healthcheck"), 1010 OptionName: aws.String("HealthyThreshold"), 1011 Value: aws.String("2"), 1012 }, 1013 { 1014 Namespace: aws.String("aws:elb:healthcheck"), 1015 OptionName: aws.String("UnhealthyThreshold"), 1016 Value: aws.String("3"), 1017 }, 1018 }, 1019 } 1020 1021 result, err := svc.UpdateEnvironment(input) 1022 if err != nil { 1023 if aerr, ok := err.(awserr.Error); ok { 1024 switch aerr.Code() { 1025 case elasticbeanstalk.ErrCodeInsufficientPrivilegesException: 1026 fmt.Println(elasticbeanstalk.ErrCodeInsufficientPrivilegesException, aerr.Error()) 1027 case elasticbeanstalk.ErrCodeTooManyBucketsException: 1028 fmt.Println(elasticbeanstalk.ErrCodeTooManyBucketsException, aerr.Error()) 1029 default: 1030 fmt.Println(aerr.Error()) 1031 } 1032 } else { 1033 // Print the error, cast err to awserr.Error to get the Code and 1034 // Message from an error. 1035 fmt.Println(err.Error()) 1036 } 1037 return 1038 } 1039 1040 fmt.Println(result) 1041 } 1042 1043 // To validate configuration settings 1044 // 1045 // The following operation validates a CloudWatch custom metrics config document: 1046 func ExampleElasticBeanstalk_ValidateConfigurationSettings_shared00() { 1047 svc := elasticbeanstalk.New(session.New()) 1048 input := &elasticbeanstalk.ValidateConfigurationSettingsInput{ 1049 ApplicationName: aws.String("my-app"), 1050 EnvironmentName: aws.String("my-env"), 1051 OptionSettings: []*elasticbeanstalk.ConfigurationOptionSetting{ 1052 { 1053 Namespace: aws.String("aws:elasticbeanstalk:healthreporting:system"), 1054 OptionName: aws.String("ConfigDocument"), 1055 Value: aws.String("{\"CloudWatchMetrics\": {\"Environment\": {\"ApplicationLatencyP99.9\": null,\"InstancesSevere\": 60,\"ApplicationLatencyP90\": 60,\"ApplicationLatencyP99\": null,\"ApplicationLatencyP95\": 60,\"InstancesUnknown\": 60,\"ApplicationLatencyP85\": 60,\"InstancesInfo\": null,\"ApplicationRequests2xx\": null,\"InstancesDegraded\": null,\"InstancesWarning\": 60,\"ApplicationLatencyP50\": 60,\"ApplicationRequestsTotal\": null,\"InstancesNoData\": null,\"InstancesPending\": 60,\"ApplicationLatencyP10\": null,\"ApplicationRequests5xx\": null,\"ApplicationLatencyP75\": null,\"InstancesOk\": 60,\"ApplicationRequests3xx\": null,\"ApplicationRequests4xx\": null},\"Instance\": {\"ApplicationLatencyP99.9\": null,\"ApplicationLatencyP90\": 60,\"ApplicationLatencyP99\": null,\"ApplicationLatencyP95\": null,\"ApplicationLatencyP85\": null,\"CPUUser\": 60,\"ApplicationRequests2xx\": null,\"CPUIdle\": null,\"ApplicationLatencyP50\": null,\"ApplicationRequestsTotal\": 60,\"RootFilesystemUtil\": null,\"LoadAverage1min\": null,\"CPUIrq\": null,\"CPUNice\": 60,\"CPUIowait\": 60,\"ApplicationLatencyP10\": null,\"LoadAverage5min\": null,\"ApplicationRequests5xx\": null,\"ApplicationLatencyP75\": 60,\"CPUSystem\": 60,\"ApplicationRequests3xx\": 60,\"ApplicationRequests4xx\": null,\"InstanceHealth\": null,\"CPUSoftirq\": 60}},\"Version\": 1}"), 1056 }, 1057 }, 1058 } 1059 1060 result, err := svc.ValidateConfigurationSettings(input) 1061 if err != nil { 1062 if aerr, ok := err.(awserr.Error); ok { 1063 switch aerr.Code() { 1064 case elasticbeanstalk.ErrCodeInsufficientPrivilegesException: 1065 fmt.Println(elasticbeanstalk.ErrCodeInsufficientPrivilegesException, aerr.Error()) 1066 case elasticbeanstalk.ErrCodeTooManyBucketsException: 1067 fmt.Println(elasticbeanstalk.ErrCodeTooManyBucketsException, aerr.Error()) 1068 default: 1069 fmt.Println(aerr.Error()) 1070 } 1071 } else { 1072 // Print the error, cast err to awserr.Error to get the Code and 1073 // Message from an error. 1074 fmt.Println(err.Error()) 1075 } 1076 return 1077 } 1078 1079 fmt.Println(result) 1080 }