1// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 3package route53_test 4 5import ( 6 "fmt" 7 "strings" 8 "time" 9 10 "github.com/aws/aws-sdk-go/aws" 11 "github.com/aws/aws-sdk-go/aws/awserr" 12 "github.com/aws/aws-sdk-go/aws/session" 13 "github.com/aws/aws-sdk-go/service/route53" 14) 15 16var _ time.Duration 17var _ strings.Reader 18var _ aws.Config 19 20func 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 associate a VPC with a hosted zone 29// 30// The following example associates the VPC with ID vpc-1a2b3c4d with the hosted zone 31// with ID Z3M3LMPEXAMPLE. 32func ExampleRoute53_AssociateVPCWithHostedZone_shared00() { 33 svc := route53.New(session.New()) 34 input := &route53.AssociateVPCWithHostedZoneInput{ 35 Comment: aws.String(""), 36 HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), 37 VPC: &route53.VPC{ 38 VPCId: aws.String("vpc-1a2b3c4d"), 39 VPCRegion: aws.String("us-east-2"), 40 }, 41 } 42 43 result, err := svc.AssociateVPCWithHostedZone(input) 44 if err != nil { 45 if aerr, ok := err.(awserr.Error); ok { 46 switch aerr.Code() { 47 case route53.ErrCodeNoSuchHostedZone: 48 fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) 49 case route53.ErrCodeNotAuthorizedException: 50 fmt.Println(route53.ErrCodeNotAuthorizedException, aerr.Error()) 51 case route53.ErrCodeInvalidVPCId: 52 fmt.Println(route53.ErrCodeInvalidVPCId, aerr.Error()) 53 case route53.ErrCodeInvalidInput: 54 fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) 55 case route53.ErrCodePublicZoneVPCAssociation: 56 fmt.Println(route53.ErrCodePublicZoneVPCAssociation, aerr.Error()) 57 case route53.ErrCodeConflictingDomainExists: 58 fmt.Println(route53.ErrCodeConflictingDomainExists, aerr.Error()) 59 case route53.ErrCodeLimitsExceeded: 60 fmt.Println(route53.ErrCodeLimitsExceeded, aerr.Error()) 61 default: 62 fmt.Println(aerr.Error()) 63 } 64 } else { 65 // Print the error, cast err to awserr.Error to get the Code and 66 // Message from an error. 67 fmt.Println(err.Error()) 68 } 69 return 70 } 71 72 fmt.Println(result) 73} 74 75// To create a basic resource record set 76// 77// The following example creates a resource record set that routes Internet traffic 78// to a resource with an IP address of 192.0.2.44. 79func ExampleRoute53_ChangeResourceRecordSets_shared00() { 80 svc := route53.New(session.New()) 81 input := &route53.ChangeResourceRecordSetsInput{ 82 ChangeBatch: &route53.ChangeBatch{ 83 Changes: []*route53.Change{ 84 { 85 Action: aws.String("CREATE"), 86 }, 87 }, 88 Comment: aws.String("Web server for example.com"), 89 }, 90 HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), 91 } 92 93 result, err := svc.ChangeResourceRecordSets(input) 94 if err != nil { 95 if aerr, ok := err.(awserr.Error); ok { 96 switch aerr.Code() { 97 case route53.ErrCodeNoSuchHostedZone: 98 fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) 99 case route53.ErrCodeNoSuchHealthCheck: 100 fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) 101 case route53.ErrCodeInvalidChangeBatch: 102 fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error()) 103 case route53.ErrCodeInvalidInput: 104 fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) 105 case route53.ErrCodePriorRequestNotComplete: 106 fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error()) 107 default: 108 fmt.Println(aerr.Error()) 109 } 110 } else { 111 // Print the error, cast err to awserr.Error to get the Code and 112 // Message from an error. 113 fmt.Println(err.Error()) 114 } 115 return 116 } 117 118 fmt.Println(result) 119} 120 121// To create weighted resource record sets 122// 123// The following example creates two weighted resource record sets. The resource with 124// a Weight of 100 will get 1/3rd of traffic (100/100+200), and the other resource will 125// get the rest of the traffic for example.com. 126func ExampleRoute53_ChangeResourceRecordSets_shared01() { 127 svc := route53.New(session.New()) 128 input := &route53.ChangeResourceRecordSetsInput{ 129 ChangeBatch: &route53.ChangeBatch{ 130 Changes: []*route53.Change{ 131 { 132 Action: aws.String("CREATE"), 133 }, 134 { 135 Action: aws.String("CREATE"), 136 }, 137 }, 138 Comment: aws.String("Web servers for example.com"), 139 }, 140 HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), 141 } 142 143 result, err := svc.ChangeResourceRecordSets(input) 144 if err != nil { 145 if aerr, ok := err.(awserr.Error); ok { 146 switch aerr.Code() { 147 case route53.ErrCodeNoSuchHostedZone: 148 fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) 149 case route53.ErrCodeNoSuchHealthCheck: 150 fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) 151 case route53.ErrCodeInvalidChangeBatch: 152 fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error()) 153 case route53.ErrCodeInvalidInput: 154 fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) 155 case route53.ErrCodePriorRequestNotComplete: 156 fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error()) 157 default: 158 fmt.Println(aerr.Error()) 159 } 160 } else { 161 // Print the error, cast err to awserr.Error to get the Code and 162 // Message from an error. 163 fmt.Println(err.Error()) 164 } 165 return 166 } 167 168 fmt.Println(result) 169} 170 171// To create an alias resource record set 172// 173// The following example creates an alias resource record set that routes traffic to 174// a CloudFront distribution. 175func ExampleRoute53_ChangeResourceRecordSets_shared02() { 176 svc := route53.New(session.New()) 177 input := &route53.ChangeResourceRecordSetsInput{ 178 ChangeBatch: &route53.ChangeBatch{ 179 Changes: []*route53.Change{ 180 { 181 Action: aws.String("CREATE"), 182 }, 183 }, 184 Comment: aws.String("CloudFront distribution for example.com"), 185 }, 186 HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), 187 } 188 189 result, err := svc.ChangeResourceRecordSets(input) 190 if err != nil { 191 if aerr, ok := err.(awserr.Error); ok { 192 switch aerr.Code() { 193 case route53.ErrCodeNoSuchHostedZone: 194 fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) 195 case route53.ErrCodeNoSuchHealthCheck: 196 fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) 197 case route53.ErrCodeInvalidChangeBatch: 198 fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error()) 199 case route53.ErrCodeInvalidInput: 200 fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) 201 case route53.ErrCodePriorRequestNotComplete: 202 fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error()) 203 default: 204 fmt.Println(aerr.Error()) 205 } 206 } else { 207 // Print the error, cast err to awserr.Error to get the Code and 208 // Message from an error. 209 fmt.Println(err.Error()) 210 } 211 return 212 } 213 214 fmt.Println(result) 215} 216 217// To create weighted alias resource record sets 218// 219// The following example creates two weighted alias resource record sets that route 220// traffic to ELB load balancers. The resource with a Weight of 100 will get 1/3rd of 221// traffic (100/100+200), and the other resource will get the rest of the traffic for 222// example.com. 223func ExampleRoute53_ChangeResourceRecordSets_shared03() { 224 svc := route53.New(session.New()) 225 input := &route53.ChangeResourceRecordSetsInput{ 226 ChangeBatch: &route53.ChangeBatch{ 227 Changes: []*route53.Change{ 228 { 229 Action: aws.String("CREATE"), 230 }, 231 { 232 Action: aws.String("CREATE"), 233 }, 234 }, 235 Comment: aws.String("ELB load balancers for example.com"), 236 }, 237 HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), 238 } 239 240 result, err := svc.ChangeResourceRecordSets(input) 241 if err != nil { 242 if aerr, ok := err.(awserr.Error); ok { 243 switch aerr.Code() { 244 case route53.ErrCodeNoSuchHostedZone: 245 fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) 246 case route53.ErrCodeNoSuchHealthCheck: 247 fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) 248 case route53.ErrCodeInvalidChangeBatch: 249 fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error()) 250 case route53.ErrCodeInvalidInput: 251 fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) 252 case route53.ErrCodePriorRequestNotComplete: 253 fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error()) 254 default: 255 fmt.Println(aerr.Error()) 256 } 257 } else { 258 // Print the error, cast err to awserr.Error to get the Code and 259 // Message from an error. 260 fmt.Println(err.Error()) 261 } 262 return 263 } 264 265 fmt.Println(result) 266} 267 268// To create latency resource record sets 269// 270// The following example creates two latency resource record sets that route traffic 271// to EC2 instances. Traffic for example.com is routed either to the Ohio region or 272// the Oregon region, depending on the latency between the user and those regions. 273func ExampleRoute53_ChangeResourceRecordSets_shared04() { 274 svc := route53.New(session.New()) 275 input := &route53.ChangeResourceRecordSetsInput{ 276 ChangeBatch: &route53.ChangeBatch{ 277 Changes: []*route53.Change{ 278 { 279 Action: aws.String("CREATE"), 280 }, 281 { 282 Action: aws.String("CREATE"), 283 }, 284 }, 285 Comment: aws.String("EC2 instances for example.com"), 286 }, 287 HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), 288 } 289 290 result, err := svc.ChangeResourceRecordSets(input) 291 if err != nil { 292 if aerr, ok := err.(awserr.Error); ok { 293 switch aerr.Code() { 294 case route53.ErrCodeNoSuchHostedZone: 295 fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) 296 case route53.ErrCodeNoSuchHealthCheck: 297 fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) 298 case route53.ErrCodeInvalidChangeBatch: 299 fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error()) 300 case route53.ErrCodeInvalidInput: 301 fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) 302 case route53.ErrCodePriorRequestNotComplete: 303 fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error()) 304 default: 305 fmt.Println(aerr.Error()) 306 } 307 } else { 308 // Print the error, cast err to awserr.Error to get the Code and 309 // Message from an error. 310 fmt.Println(err.Error()) 311 } 312 return 313 } 314 315 fmt.Println(result) 316} 317 318// To create latency alias resource record sets 319// 320// The following example creates two latency alias resource record sets that route traffic 321// for example.com to ELB load balancers. Requests are routed either to the Ohio region 322// or the Oregon region, depending on the latency between the user and those regions. 323func ExampleRoute53_ChangeResourceRecordSets_shared05() { 324 svc := route53.New(session.New()) 325 input := &route53.ChangeResourceRecordSetsInput{ 326 ChangeBatch: &route53.ChangeBatch{ 327 Changes: []*route53.Change{ 328 { 329 Action: aws.String("CREATE"), 330 }, 331 { 332 Action: aws.String("CREATE"), 333 }, 334 }, 335 Comment: aws.String("ELB load balancers for example.com"), 336 }, 337 HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), 338 } 339 340 result, err := svc.ChangeResourceRecordSets(input) 341 if err != nil { 342 if aerr, ok := err.(awserr.Error); ok { 343 switch aerr.Code() { 344 case route53.ErrCodeNoSuchHostedZone: 345 fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) 346 case route53.ErrCodeNoSuchHealthCheck: 347 fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) 348 case route53.ErrCodeInvalidChangeBatch: 349 fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error()) 350 case route53.ErrCodeInvalidInput: 351 fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) 352 case route53.ErrCodePriorRequestNotComplete: 353 fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error()) 354 default: 355 fmt.Println(aerr.Error()) 356 } 357 } else { 358 // Print the error, cast err to awserr.Error to get the Code and 359 // Message from an error. 360 fmt.Println(err.Error()) 361 } 362 return 363 } 364 365 fmt.Println(result) 366} 367 368// To create failover resource record sets 369// 370// The following example creates primary and secondary failover resource record sets 371// that route traffic to EC2 instances. Traffic is generally routed to the primary resource, 372// in the Ohio region. If that resource is unavailable, traffic is routed to the secondary 373// resource, in the Oregon region. 374func ExampleRoute53_ChangeResourceRecordSets_shared06() { 375 svc := route53.New(session.New()) 376 input := &route53.ChangeResourceRecordSetsInput{ 377 ChangeBatch: &route53.ChangeBatch{ 378 Changes: []*route53.Change{ 379 { 380 Action: aws.String("CREATE"), 381 }, 382 { 383 Action: aws.String("CREATE"), 384 }, 385 }, 386 Comment: aws.String("Failover configuration for example.com"), 387 }, 388 HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), 389 } 390 391 result, err := svc.ChangeResourceRecordSets(input) 392 if err != nil { 393 if aerr, ok := err.(awserr.Error); ok { 394 switch aerr.Code() { 395 case route53.ErrCodeNoSuchHostedZone: 396 fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) 397 case route53.ErrCodeNoSuchHealthCheck: 398 fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) 399 case route53.ErrCodeInvalidChangeBatch: 400 fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error()) 401 case route53.ErrCodeInvalidInput: 402 fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) 403 case route53.ErrCodePriorRequestNotComplete: 404 fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error()) 405 default: 406 fmt.Println(aerr.Error()) 407 } 408 } else { 409 // Print the error, cast err to awserr.Error to get the Code and 410 // Message from an error. 411 fmt.Println(err.Error()) 412 } 413 return 414 } 415 416 fmt.Println(result) 417} 418 419// To create failover alias resource record sets 420// 421// The following example creates primary and secondary failover alias resource record 422// sets that route traffic to ELB load balancers. Traffic is generally routed to the 423// primary resource, in the Ohio region. If that resource is unavailable, traffic is 424// routed to the secondary resource, in the Oregon region. 425func ExampleRoute53_ChangeResourceRecordSets_shared07() { 426 svc := route53.New(session.New()) 427 input := &route53.ChangeResourceRecordSetsInput{ 428 ChangeBatch: &route53.ChangeBatch{ 429 Changes: []*route53.Change{ 430 { 431 Action: aws.String("CREATE"), 432 }, 433 { 434 Action: aws.String("CREATE"), 435 }, 436 }, 437 Comment: aws.String("Failover alias configuration for example.com"), 438 }, 439 HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), 440 } 441 442 result, err := svc.ChangeResourceRecordSets(input) 443 if err != nil { 444 if aerr, ok := err.(awserr.Error); ok { 445 switch aerr.Code() { 446 case route53.ErrCodeNoSuchHostedZone: 447 fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) 448 case route53.ErrCodeNoSuchHealthCheck: 449 fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) 450 case route53.ErrCodeInvalidChangeBatch: 451 fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error()) 452 case route53.ErrCodeInvalidInput: 453 fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) 454 case route53.ErrCodePriorRequestNotComplete: 455 fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error()) 456 default: 457 fmt.Println(aerr.Error()) 458 } 459 } else { 460 // Print the error, cast err to awserr.Error to get the Code and 461 // Message from an error. 462 fmt.Println(err.Error()) 463 } 464 return 465 } 466 467 fmt.Println(result) 468} 469 470// To create geolocation resource record sets 471// 472// The following example creates four geolocation resource record sets that use IPv4 473// addresses to route traffic to resources such as web servers running on EC2 instances. 474// Traffic is routed to one of four IP addresses, for North America (NA), for South 475// America (SA), for Europe (EU), and for all other locations (*). 476func ExampleRoute53_ChangeResourceRecordSets_shared08() { 477 svc := route53.New(session.New()) 478 input := &route53.ChangeResourceRecordSetsInput{ 479 ChangeBatch: &route53.ChangeBatch{ 480 Changes: []*route53.Change{ 481 { 482 Action: aws.String("CREATE"), 483 }, 484 { 485 Action: aws.String("CREATE"), 486 }, 487 { 488 Action: aws.String("CREATE"), 489 }, 490 { 491 Action: aws.String("CREATE"), 492 }, 493 }, 494 Comment: aws.String("Geolocation configuration for example.com"), 495 }, 496 HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), 497 } 498 499 result, err := svc.ChangeResourceRecordSets(input) 500 if err != nil { 501 if aerr, ok := err.(awserr.Error); ok { 502 switch aerr.Code() { 503 case route53.ErrCodeNoSuchHostedZone: 504 fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) 505 case route53.ErrCodeNoSuchHealthCheck: 506 fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) 507 case route53.ErrCodeInvalidChangeBatch: 508 fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error()) 509 case route53.ErrCodeInvalidInput: 510 fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) 511 case route53.ErrCodePriorRequestNotComplete: 512 fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error()) 513 default: 514 fmt.Println(aerr.Error()) 515 } 516 } else { 517 // Print the error, cast err to awserr.Error to get the Code and 518 // Message from an error. 519 fmt.Println(err.Error()) 520 } 521 return 522 } 523 524 fmt.Println(result) 525} 526 527// To create geolocation alias resource record sets 528// 529// The following example creates four geolocation alias resource record sets that route 530// traffic to ELB load balancers. Traffic is routed to one of four IP addresses, for 531// North America (NA), for South America (SA), for Europe (EU), and for all other locations 532// (*). 533func ExampleRoute53_ChangeResourceRecordSets_shared09() { 534 svc := route53.New(session.New()) 535 input := &route53.ChangeResourceRecordSetsInput{ 536 ChangeBatch: &route53.ChangeBatch{ 537 Changes: []*route53.Change{ 538 { 539 Action: aws.String("CREATE"), 540 }, 541 { 542 Action: aws.String("CREATE"), 543 }, 544 { 545 Action: aws.String("CREATE"), 546 }, 547 { 548 Action: aws.String("CREATE"), 549 }, 550 }, 551 Comment: aws.String("Geolocation alias configuration for example.com"), 552 }, 553 HostedZoneId: aws.String("Z3M3LMPEXAMPLE"), 554 } 555 556 result, err := svc.ChangeResourceRecordSets(input) 557 if err != nil { 558 if aerr, ok := err.(awserr.Error); ok { 559 switch aerr.Code() { 560 case route53.ErrCodeNoSuchHostedZone: 561 fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) 562 case route53.ErrCodeNoSuchHealthCheck: 563 fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) 564 case route53.ErrCodeInvalidChangeBatch: 565 fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error()) 566 case route53.ErrCodeInvalidInput: 567 fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) 568 case route53.ErrCodePriorRequestNotComplete: 569 fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error()) 570 default: 571 fmt.Println(aerr.Error()) 572 } 573 } else { 574 // Print the error, cast err to awserr.Error to get the Code and 575 // Message from an error. 576 fmt.Println(err.Error()) 577 } 578 return 579 } 580 581 fmt.Println(result) 582} 583 584// To add or remove tags from a hosted zone or health check 585// 586// The following example adds two tags and removes one tag from the hosted zone with 587// ID Z3M3LMPEXAMPLE. 588func ExampleRoute53_ChangeTagsForResource_shared00() { 589 svc := route53.New(session.New()) 590 input := &route53.ChangeTagsForResourceInput{ 591 AddTags: []*route53.Tag{ 592 { 593 Key: aws.String("apex"), 594 Value: aws.String("3874"), 595 }, 596 { 597 Key: aws.String("acme"), 598 Value: aws.String("4938"), 599 }, 600 }, 601 RemoveTagKeys: []*string{ 602 aws.String("Nadir"), 603 }, 604 ResourceId: aws.String("Z3M3LMPEXAMPLE"), 605 ResourceType: aws.String("hostedzone"), 606 } 607 608 result, err := svc.ChangeTagsForResource(input) 609 if err != nil { 610 if aerr, ok := err.(awserr.Error); ok { 611 switch aerr.Code() { 612 case route53.ErrCodeInvalidInput: 613 fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) 614 case route53.ErrCodeNoSuchHealthCheck: 615 fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error()) 616 case route53.ErrCodeNoSuchHostedZone: 617 fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) 618 case route53.ErrCodePriorRequestNotComplete: 619 fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error()) 620 case route53.ErrCodeThrottlingException: 621 fmt.Println(route53.ErrCodeThrottlingException, aerr.Error()) 622 default: 623 fmt.Println(aerr.Error()) 624 } 625 } else { 626 // Print the error, cast err to awserr.Error to get the Code and 627 // Message from an error. 628 fmt.Println(err.Error()) 629 } 630 return 631 } 632 633 fmt.Println(result) 634} 635 636// To get information about a hosted zone 637// 638// The following example gets information about the Z3M3LMPEXAMPLE hosted zone. 639func ExampleRoute53_GetHostedZone_shared00() { 640 svc := route53.New(session.New()) 641 input := &route53.GetHostedZoneInput{ 642 Id: aws.String("Z3M3LMPEXAMPLE"), 643 } 644 645 result, err := svc.GetHostedZone(input) 646 if err != nil { 647 if aerr, ok := err.(awserr.Error); ok { 648 switch aerr.Code() { 649 case route53.ErrCodeNoSuchHostedZone: 650 fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error()) 651 case route53.ErrCodeInvalidInput: 652 fmt.Println(route53.ErrCodeInvalidInput, aerr.Error()) 653 default: 654 fmt.Println(aerr.Error()) 655 } 656 } else { 657 // Print the error, cast err to awserr.Error to get the Code and 658 // Message from an error. 659 fmt.Println(err.Error()) 660 } 661 return 662 } 663 664 fmt.Println(result) 665} 666