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					ResourceRecordSet: &route53.ResourceRecordSet{
87						Name: aws.String("example.com"),
88						ResourceRecords: []*route53.ResourceRecord{
89							{
90								Value: aws.String("192.0.2.44"),
91							},
92						},
93						TTL:  aws.Int64(60),
94						Type: aws.String("A"),
95					},
96				},
97			},
98			Comment: aws.String("Web server for example.com"),
99		},
100		HostedZoneId: aws.String("Z3M3LMPEXAMPLE"),
101	}
102
103	result, err := svc.ChangeResourceRecordSets(input)
104	if err != nil {
105		if aerr, ok := err.(awserr.Error); ok {
106			switch aerr.Code() {
107			case route53.ErrCodeNoSuchHostedZone:
108				fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error())
109			case route53.ErrCodeNoSuchHealthCheck:
110				fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error())
111			case route53.ErrCodeInvalidChangeBatch:
112				fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error())
113			case route53.ErrCodeInvalidInput:
114				fmt.Println(route53.ErrCodeInvalidInput, aerr.Error())
115			case route53.ErrCodePriorRequestNotComplete:
116				fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error())
117			default:
118				fmt.Println(aerr.Error())
119			}
120		} else {
121			// Print the error, cast err to awserr.Error to get the Code and
122			// Message from an error.
123			fmt.Println(err.Error())
124		}
125		return
126	}
127
128	fmt.Println(result)
129}
130
131// To create weighted resource record sets
132//
133// The following example creates two weighted resource record sets. The resource with
134// a Weight of 100 will get 1/3rd of traffic (100/100+200), and the other resource will
135// get the rest of the traffic for example.com.
136func ExampleRoute53_ChangeResourceRecordSets_shared01() {
137	svc := route53.New(session.New())
138	input := &route53.ChangeResourceRecordSetsInput{
139		ChangeBatch: &route53.ChangeBatch{
140			Changes: []*route53.Change{
141				{
142					Action: aws.String("CREATE"),
143					ResourceRecordSet: &route53.ResourceRecordSet{
144						HealthCheckId: aws.String("abcdef11-2222-3333-4444-555555fedcba"),
145						Name:          aws.String("example.com"),
146						ResourceRecords: []*route53.ResourceRecord{
147							{
148								Value: aws.String("192.0.2.44"),
149							},
150						},
151						SetIdentifier: aws.String("Seattle data center"),
152						TTL:           aws.Int64(60),
153						Type:          aws.String("A"),
154						Weight:        aws.Int64(100),
155					},
156				},
157				{
158					Action: aws.String("CREATE"),
159					ResourceRecordSet: &route53.ResourceRecordSet{
160						HealthCheckId: aws.String("abcdef66-7777-8888-9999-000000fedcba"),
161						Name:          aws.String("example.com"),
162						ResourceRecords: []*route53.ResourceRecord{
163							{
164								Value: aws.String("192.0.2.45"),
165							},
166						},
167						SetIdentifier: aws.String("Portland data center"),
168						TTL:           aws.Int64(60),
169						Type:          aws.String("A"),
170						Weight:        aws.Int64(200),
171					},
172				},
173			},
174			Comment: aws.String("Web servers for example.com"),
175		},
176		HostedZoneId: aws.String("Z3M3LMPEXAMPLE"),
177	}
178
179	result, err := svc.ChangeResourceRecordSets(input)
180	if err != nil {
181		if aerr, ok := err.(awserr.Error); ok {
182			switch aerr.Code() {
183			case route53.ErrCodeNoSuchHostedZone:
184				fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error())
185			case route53.ErrCodeNoSuchHealthCheck:
186				fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error())
187			case route53.ErrCodeInvalidChangeBatch:
188				fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error())
189			case route53.ErrCodeInvalidInput:
190				fmt.Println(route53.ErrCodeInvalidInput, aerr.Error())
191			case route53.ErrCodePriorRequestNotComplete:
192				fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error())
193			default:
194				fmt.Println(aerr.Error())
195			}
196		} else {
197			// Print the error, cast err to awserr.Error to get the Code and
198			// Message from an error.
199			fmt.Println(err.Error())
200		}
201		return
202	}
203
204	fmt.Println(result)
205}
206
207// To create an alias resource record set
208//
209// The following example creates an alias resource record set that routes traffic to
210// a CloudFront distribution.
211func ExampleRoute53_ChangeResourceRecordSets_shared02() {
212	svc := route53.New(session.New())
213	input := &route53.ChangeResourceRecordSetsInput{
214		ChangeBatch: &route53.ChangeBatch{
215			Changes: []*route53.Change{
216				{
217					Action: aws.String("CREATE"),
218					ResourceRecordSet: &route53.ResourceRecordSet{
219						AliasTarget: &route53.AliasTarget{
220							DNSName:              aws.String("d123rk29d0stfj.cloudfront.net"),
221							EvaluateTargetHealth: aws.Bool(false),
222							HostedZoneId:         aws.String("Z2FDTNDATAQYW2"),
223						},
224						Name: aws.String("example.com"),
225						Type: aws.String("A"),
226					},
227				},
228			},
229			Comment: aws.String("CloudFront distribution for example.com"),
230		},
231		HostedZoneId: aws.String("Z3M3LMPEXAMPLE"),
232	}
233
234	result, err := svc.ChangeResourceRecordSets(input)
235	if err != nil {
236		if aerr, ok := err.(awserr.Error); ok {
237			switch aerr.Code() {
238			case route53.ErrCodeNoSuchHostedZone:
239				fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error())
240			case route53.ErrCodeNoSuchHealthCheck:
241				fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error())
242			case route53.ErrCodeInvalidChangeBatch:
243				fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error())
244			case route53.ErrCodeInvalidInput:
245				fmt.Println(route53.ErrCodeInvalidInput, aerr.Error())
246			case route53.ErrCodePriorRequestNotComplete:
247				fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error())
248			default:
249				fmt.Println(aerr.Error())
250			}
251		} else {
252			// Print the error, cast err to awserr.Error to get the Code and
253			// Message from an error.
254			fmt.Println(err.Error())
255		}
256		return
257	}
258
259	fmt.Println(result)
260}
261
262// To create weighted alias resource record sets
263//
264// The following example creates two weighted alias resource record sets that route
265// traffic to ELB load balancers. The resource with a Weight of 100 will get 1/3rd of
266// traffic (100/100+200), and the other resource will get the rest of the traffic for
267// example.com.
268func ExampleRoute53_ChangeResourceRecordSets_shared03() {
269	svc := route53.New(session.New())
270	input := &route53.ChangeResourceRecordSetsInput{
271		ChangeBatch: &route53.ChangeBatch{
272			Changes: []*route53.Change{
273				{
274					Action: aws.String("CREATE"),
275					ResourceRecordSet: &route53.ResourceRecordSet{
276						AliasTarget: &route53.AliasTarget{
277							DNSName:              aws.String("example-com-123456789.us-east-2.elb.amazonaws.com "),
278							EvaluateTargetHealth: aws.Bool(true),
279							HostedZoneId:         aws.String("Z3AADJGX6KTTL2"),
280						},
281						Name:          aws.String("example.com"),
282						SetIdentifier: aws.String("Ohio region"),
283						Type:          aws.String("A"),
284						Weight:        aws.Int64(100),
285					},
286				},
287				{
288					Action: aws.String("CREATE"),
289					ResourceRecordSet: &route53.ResourceRecordSet{
290						AliasTarget: &route53.AliasTarget{
291							DNSName:              aws.String("example-com-987654321.us-west-2.elb.amazonaws.com "),
292							EvaluateTargetHealth: aws.Bool(true),
293							HostedZoneId:         aws.String("Z1H1FL5HABSF5"),
294						},
295						Name:          aws.String("example.com"),
296						SetIdentifier: aws.String("Oregon region"),
297						Type:          aws.String("A"),
298						Weight:        aws.Int64(200),
299					},
300				},
301			},
302			Comment: aws.String("ELB load balancers for example.com"),
303		},
304		HostedZoneId: aws.String("Z3M3LMPEXAMPLE"),
305	}
306
307	result, err := svc.ChangeResourceRecordSets(input)
308	if err != nil {
309		if aerr, ok := err.(awserr.Error); ok {
310			switch aerr.Code() {
311			case route53.ErrCodeNoSuchHostedZone:
312				fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error())
313			case route53.ErrCodeNoSuchHealthCheck:
314				fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error())
315			case route53.ErrCodeInvalidChangeBatch:
316				fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error())
317			case route53.ErrCodeInvalidInput:
318				fmt.Println(route53.ErrCodeInvalidInput, aerr.Error())
319			case route53.ErrCodePriorRequestNotComplete:
320				fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error())
321			default:
322				fmt.Println(aerr.Error())
323			}
324		} else {
325			// Print the error, cast err to awserr.Error to get the Code and
326			// Message from an error.
327			fmt.Println(err.Error())
328		}
329		return
330	}
331
332	fmt.Println(result)
333}
334
335// To create latency resource record sets
336//
337// The following example creates two latency resource record sets that route traffic
338// to EC2 instances. Traffic for example.com is routed either to the Ohio region or
339// the Oregon region, depending on the latency between the user and those regions.
340func ExampleRoute53_ChangeResourceRecordSets_shared04() {
341	svc := route53.New(session.New())
342	input := &route53.ChangeResourceRecordSetsInput{
343		ChangeBatch: &route53.ChangeBatch{
344			Changes: []*route53.Change{
345				{
346					Action: aws.String("CREATE"),
347					ResourceRecordSet: &route53.ResourceRecordSet{
348						HealthCheckId: aws.String("abcdef11-2222-3333-4444-555555fedcba"),
349						Name:          aws.String("example.com"),
350						Region:        aws.String("us-east-2"),
351						ResourceRecords: []*route53.ResourceRecord{
352							{
353								Value: aws.String("192.0.2.44"),
354							},
355						},
356						SetIdentifier: aws.String("Ohio region"),
357						TTL:           aws.Int64(60),
358						Type:          aws.String("A"),
359					},
360				},
361				{
362					Action: aws.String("CREATE"),
363					ResourceRecordSet: &route53.ResourceRecordSet{
364						HealthCheckId: aws.String("abcdef66-7777-8888-9999-000000fedcba"),
365						Name:          aws.String("example.com"),
366						Region:        aws.String("us-west-2"),
367						ResourceRecords: []*route53.ResourceRecord{
368							{
369								Value: aws.String("192.0.2.45"),
370							},
371						},
372						SetIdentifier: aws.String("Oregon region"),
373						TTL:           aws.Int64(60),
374						Type:          aws.String("A"),
375					},
376				},
377			},
378			Comment: aws.String("EC2 instances for example.com"),
379		},
380		HostedZoneId: aws.String("Z3M3LMPEXAMPLE"),
381	}
382
383	result, err := svc.ChangeResourceRecordSets(input)
384	if err != nil {
385		if aerr, ok := err.(awserr.Error); ok {
386			switch aerr.Code() {
387			case route53.ErrCodeNoSuchHostedZone:
388				fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error())
389			case route53.ErrCodeNoSuchHealthCheck:
390				fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error())
391			case route53.ErrCodeInvalidChangeBatch:
392				fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error())
393			case route53.ErrCodeInvalidInput:
394				fmt.Println(route53.ErrCodeInvalidInput, aerr.Error())
395			case route53.ErrCodePriorRequestNotComplete:
396				fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error())
397			default:
398				fmt.Println(aerr.Error())
399			}
400		} else {
401			// Print the error, cast err to awserr.Error to get the Code and
402			// Message from an error.
403			fmt.Println(err.Error())
404		}
405		return
406	}
407
408	fmt.Println(result)
409}
410
411// To create latency alias resource record sets
412//
413// The following example creates two latency alias resource record sets that route traffic
414// for example.com to ELB load balancers. Requests are routed either to the Ohio region
415// or the Oregon region, depending on the latency between the user and those regions.
416func ExampleRoute53_ChangeResourceRecordSets_shared05() {
417	svc := route53.New(session.New())
418	input := &route53.ChangeResourceRecordSetsInput{
419		ChangeBatch: &route53.ChangeBatch{
420			Changes: []*route53.Change{
421				{
422					Action: aws.String("CREATE"),
423					ResourceRecordSet: &route53.ResourceRecordSet{
424						AliasTarget: &route53.AliasTarget{
425							DNSName:              aws.String("example-com-123456789.us-east-2.elb.amazonaws.com "),
426							EvaluateTargetHealth: aws.Bool(true),
427							HostedZoneId:         aws.String("Z3AADJGX6KTTL2"),
428						},
429						Name:          aws.String("example.com"),
430						Region:        aws.String("us-east-2"),
431						SetIdentifier: aws.String("Ohio region"),
432						Type:          aws.String("A"),
433					},
434				},
435				{
436					Action: aws.String("CREATE"),
437					ResourceRecordSet: &route53.ResourceRecordSet{
438						AliasTarget: &route53.AliasTarget{
439							DNSName:              aws.String("example-com-987654321.us-west-2.elb.amazonaws.com "),
440							EvaluateTargetHealth: aws.Bool(true),
441							HostedZoneId:         aws.String("Z1H1FL5HABSF5"),
442						},
443						Name:          aws.String("example.com"),
444						Region:        aws.String("us-west-2"),
445						SetIdentifier: aws.String("Oregon region"),
446						Type:          aws.String("A"),
447					},
448				},
449			},
450			Comment: aws.String("ELB load balancers for example.com"),
451		},
452		HostedZoneId: aws.String("Z3M3LMPEXAMPLE"),
453	}
454
455	result, err := svc.ChangeResourceRecordSets(input)
456	if err != nil {
457		if aerr, ok := err.(awserr.Error); ok {
458			switch aerr.Code() {
459			case route53.ErrCodeNoSuchHostedZone:
460				fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error())
461			case route53.ErrCodeNoSuchHealthCheck:
462				fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error())
463			case route53.ErrCodeInvalidChangeBatch:
464				fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error())
465			case route53.ErrCodeInvalidInput:
466				fmt.Println(route53.ErrCodeInvalidInput, aerr.Error())
467			case route53.ErrCodePriorRequestNotComplete:
468				fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error())
469			default:
470				fmt.Println(aerr.Error())
471			}
472		} else {
473			// Print the error, cast err to awserr.Error to get the Code and
474			// Message from an error.
475			fmt.Println(err.Error())
476		}
477		return
478	}
479
480	fmt.Println(result)
481}
482
483// To create failover resource record sets
484//
485// The following example creates primary and secondary failover resource record sets
486// that route traffic to EC2 instances. Traffic is generally routed to the primary resource,
487// in the Ohio region. If that resource is unavailable, traffic is routed to the secondary
488// resource, in the Oregon region.
489func ExampleRoute53_ChangeResourceRecordSets_shared06() {
490	svc := route53.New(session.New())
491	input := &route53.ChangeResourceRecordSetsInput{
492		ChangeBatch: &route53.ChangeBatch{
493			Changes: []*route53.Change{
494				{
495					Action: aws.String("CREATE"),
496					ResourceRecordSet: &route53.ResourceRecordSet{
497						Failover:      aws.String("PRIMARY"),
498						HealthCheckId: aws.String("abcdef11-2222-3333-4444-555555fedcba"),
499						Name:          aws.String("example.com"),
500						ResourceRecords: []*route53.ResourceRecord{
501							{
502								Value: aws.String("192.0.2.44"),
503							},
504						},
505						SetIdentifier: aws.String("Ohio region"),
506						TTL:           aws.Int64(60),
507						Type:          aws.String("A"),
508					},
509				},
510				{
511					Action: aws.String("CREATE"),
512					ResourceRecordSet: &route53.ResourceRecordSet{
513						Failover:      aws.String("SECONDARY"),
514						HealthCheckId: aws.String("abcdef66-7777-8888-9999-000000fedcba"),
515						Name:          aws.String("example.com"),
516						ResourceRecords: []*route53.ResourceRecord{
517							{
518								Value: aws.String("192.0.2.45"),
519							},
520						},
521						SetIdentifier: aws.String("Oregon region"),
522						TTL:           aws.Int64(60),
523						Type:          aws.String("A"),
524					},
525				},
526			},
527			Comment: aws.String("Failover configuration for example.com"),
528		},
529		HostedZoneId: aws.String("Z3M3LMPEXAMPLE"),
530	}
531
532	result, err := svc.ChangeResourceRecordSets(input)
533	if err != nil {
534		if aerr, ok := err.(awserr.Error); ok {
535			switch aerr.Code() {
536			case route53.ErrCodeNoSuchHostedZone:
537				fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error())
538			case route53.ErrCodeNoSuchHealthCheck:
539				fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error())
540			case route53.ErrCodeInvalidChangeBatch:
541				fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error())
542			case route53.ErrCodeInvalidInput:
543				fmt.Println(route53.ErrCodeInvalidInput, aerr.Error())
544			case route53.ErrCodePriorRequestNotComplete:
545				fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error())
546			default:
547				fmt.Println(aerr.Error())
548			}
549		} else {
550			// Print the error, cast err to awserr.Error to get the Code and
551			// Message from an error.
552			fmt.Println(err.Error())
553		}
554		return
555	}
556
557	fmt.Println(result)
558}
559
560// To create failover alias resource record sets
561//
562// The following example creates primary and secondary failover alias resource record
563// sets that route traffic to ELB load balancers. Traffic is generally routed to the
564// primary resource, in the Ohio region. If that resource is unavailable, traffic is
565// routed to the secondary resource, in the Oregon region.
566func ExampleRoute53_ChangeResourceRecordSets_shared07() {
567	svc := route53.New(session.New())
568	input := &route53.ChangeResourceRecordSetsInput{
569		ChangeBatch: &route53.ChangeBatch{
570			Changes: []*route53.Change{
571				{
572					Action: aws.String("CREATE"),
573					ResourceRecordSet: &route53.ResourceRecordSet{
574						AliasTarget: &route53.AliasTarget{
575							DNSName:              aws.String("example-com-123456789.us-east-2.elb.amazonaws.com "),
576							EvaluateTargetHealth: aws.Bool(true),
577							HostedZoneId:         aws.String("Z3AADJGX6KTTL2"),
578						},
579						Failover:      aws.String("PRIMARY"),
580						Name:          aws.String("example.com"),
581						SetIdentifier: aws.String("Ohio region"),
582						Type:          aws.String("A"),
583					},
584				},
585				{
586					Action: aws.String("CREATE"),
587					ResourceRecordSet: &route53.ResourceRecordSet{
588						AliasTarget: &route53.AliasTarget{
589							DNSName:              aws.String("example-com-987654321.us-west-2.elb.amazonaws.com "),
590							EvaluateTargetHealth: aws.Bool(true),
591							HostedZoneId:         aws.String("Z1H1FL5HABSF5"),
592						},
593						Failover:      aws.String("SECONDARY"),
594						Name:          aws.String("example.com"),
595						SetIdentifier: aws.String("Oregon region"),
596						Type:          aws.String("A"),
597					},
598				},
599			},
600			Comment: aws.String("Failover alias configuration for example.com"),
601		},
602		HostedZoneId: aws.String("Z3M3LMPEXAMPLE"),
603	}
604
605	result, err := svc.ChangeResourceRecordSets(input)
606	if err != nil {
607		if aerr, ok := err.(awserr.Error); ok {
608			switch aerr.Code() {
609			case route53.ErrCodeNoSuchHostedZone:
610				fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error())
611			case route53.ErrCodeNoSuchHealthCheck:
612				fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error())
613			case route53.ErrCodeInvalidChangeBatch:
614				fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error())
615			case route53.ErrCodeInvalidInput:
616				fmt.Println(route53.ErrCodeInvalidInput, aerr.Error())
617			case route53.ErrCodePriorRequestNotComplete:
618				fmt.Println(route53.ErrCodePriorRequestNotComplete, 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 create geolocation resource record sets
634//
635// The following example creates four geolocation resource record sets that use IPv4
636// addresses to route traffic to resources such as web servers running on EC2 instances.
637// Traffic is routed to one of four IP addresses, for North America (NA), for South
638// America (SA), for Europe (EU), and for all other locations (*).
639func ExampleRoute53_ChangeResourceRecordSets_shared08() {
640	svc := route53.New(session.New())
641	input := &route53.ChangeResourceRecordSetsInput{
642		ChangeBatch: &route53.ChangeBatch{
643			Changes: []*route53.Change{
644				{
645					Action: aws.String("CREATE"),
646					ResourceRecordSet: &route53.ResourceRecordSet{
647						GeoLocation: &route53.GeoLocation{
648							ContinentCode: aws.String("NA"),
649						},
650						Name: aws.String("example.com"),
651						ResourceRecords: []*route53.ResourceRecord{
652							{
653								Value: aws.String("192.0.2.44"),
654							},
655						},
656						SetIdentifier: aws.String("North America"),
657						TTL:           aws.Int64(60),
658						Type:          aws.String("A"),
659					},
660				},
661				{
662					Action: aws.String("CREATE"),
663					ResourceRecordSet: &route53.ResourceRecordSet{
664						GeoLocation: &route53.GeoLocation{
665							ContinentCode: aws.String("SA"),
666						},
667						Name: aws.String("example.com"),
668						ResourceRecords: []*route53.ResourceRecord{
669							{
670								Value: aws.String("192.0.2.45"),
671							},
672						},
673						SetIdentifier: aws.String("South America"),
674						TTL:           aws.Int64(60),
675						Type:          aws.String("A"),
676					},
677				},
678				{
679					Action: aws.String("CREATE"),
680					ResourceRecordSet: &route53.ResourceRecordSet{
681						GeoLocation: &route53.GeoLocation{
682							ContinentCode: aws.String("EU"),
683						},
684						Name: aws.String("example.com"),
685						ResourceRecords: []*route53.ResourceRecord{
686							{
687								Value: aws.String("192.0.2.46"),
688							},
689						},
690						SetIdentifier: aws.String("Europe"),
691						TTL:           aws.Int64(60),
692						Type:          aws.String("A"),
693					},
694				},
695				{
696					Action: aws.String("CREATE"),
697					ResourceRecordSet: &route53.ResourceRecordSet{
698						GeoLocation: &route53.GeoLocation{
699							CountryCode: aws.String("*"),
700						},
701						Name: aws.String("example.com"),
702						ResourceRecords: []*route53.ResourceRecord{
703							{
704								Value: aws.String("192.0.2.47"),
705							},
706						},
707						SetIdentifier: aws.String("Other locations"),
708						TTL:           aws.Int64(60),
709						Type:          aws.String("A"),
710					},
711				},
712			},
713			Comment: aws.String("Geolocation configuration for example.com"),
714		},
715		HostedZoneId: aws.String("Z3M3LMPEXAMPLE"),
716	}
717
718	result, err := svc.ChangeResourceRecordSets(input)
719	if err != nil {
720		if aerr, ok := err.(awserr.Error); ok {
721			switch aerr.Code() {
722			case route53.ErrCodeNoSuchHostedZone:
723				fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error())
724			case route53.ErrCodeNoSuchHealthCheck:
725				fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error())
726			case route53.ErrCodeInvalidChangeBatch:
727				fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error())
728			case route53.ErrCodeInvalidInput:
729				fmt.Println(route53.ErrCodeInvalidInput, aerr.Error())
730			case route53.ErrCodePriorRequestNotComplete:
731				fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error())
732			default:
733				fmt.Println(aerr.Error())
734			}
735		} else {
736			// Print the error, cast err to awserr.Error to get the Code and
737			// Message from an error.
738			fmt.Println(err.Error())
739		}
740		return
741	}
742
743	fmt.Println(result)
744}
745
746// To create geolocation alias resource record sets
747//
748// The following example creates four geolocation alias resource record sets that route
749// traffic to ELB load balancers. Traffic is routed to one of four IP addresses, for
750// North America (NA), for South America (SA), for Europe (EU), and for all other locations
751// (*).
752func ExampleRoute53_ChangeResourceRecordSets_shared09() {
753	svc := route53.New(session.New())
754	input := &route53.ChangeResourceRecordSetsInput{
755		ChangeBatch: &route53.ChangeBatch{
756			Changes: []*route53.Change{
757				{
758					Action: aws.String("CREATE"),
759					ResourceRecordSet: &route53.ResourceRecordSet{
760						AliasTarget: &route53.AliasTarget{
761							DNSName:              aws.String("example-com-123456789.us-east-2.elb.amazonaws.com "),
762							EvaluateTargetHealth: aws.Bool(true),
763							HostedZoneId:         aws.String("Z3AADJGX6KTTL2"),
764						},
765						GeoLocation: &route53.GeoLocation{
766							ContinentCode: aws.String("NA"),
767						},
768						Name:          aws.String("example.com"),
769						SetIdentifier: aws.String("North America"),
770						Type:          aws.String("A"),
771					},
772				},
773				{
774					Action: aws.String("CREATE"),
775					ResourceRecordSet: &route53.ResourceRecordSet{
776						AliasTarget: &route53.AliasTarget{
777							DNSName:              aws.String("example-com-234567890.sa-east-1.elb.amazonaws.com "),
778							EvaluateTargetHealth: aws.Bool(true),
779							HostedZoneId:         aws.String("Z2P70J7HTTTPLU"),
780						},
781						GeoLocation: &route53.GeoLocation{
782							ContinentCode: aws.String("SA"),
783						},
784						Name:          aws.String("example.com"),
785						SetIdentifier: aws.String("South America"),
786						Type:          aws.String("A"),
787					},
788				},
789				{
790					Action: aws.String("CREATE"),
791					ResourceRecordSet: &route53.ResourceRecordSet{
792						AliasTarget: &route53.AliasTarget{
793							DNSName:              aws.String("example-com-234567890.eu-central-1.elb.amazonaws.com "),
794							EvaluateTargetHealth: aws.Bool(true),
795							HostedZoneId:         aws.String("Z215JYRZR1TBD5"),
796						},
797						GeoLocation: &route53.GeoLocation{
798							ContinentCode: aws.String("EU"),
799						},
800						Name:          aws.String("example.com"),
801						SetIdentifier: aws.String("Europe"),
802						Type:          aws.String("A"),
803					},
804				},
805				{
806					Action: aws.String("CREATE"),
807					ResourceRecordSet: &route53.ResourceRecordSet{
808						AliasTarget: &route53.AliasTarget{
809							DNSName:              aws.String("example-com-234567890.ap-southeast-1.elb.amazonaws.com "),
810							EvaluateTargetHealth: aws.Bool(true),
811							HostedZoneId:         aws.String("Z1LMS91P8CMLE5"),
812						},
813						GeoLocation: &route53.GeoLocation{
814							CountryCode: aws.String("*"),
815						},
816						Name:          aws.String("example.com"),
817						SetIdentifier: aws.String("Other locations"),
818						Type:          aws.String("A"),
819					},
820				},
821			},
822			Comment: aws.String("Geolocation alias configuration for example.com"),
823		},
824		HostedZoneId: aws.String("Z3M3LMPEXAMPLE"),
825	}
826
827	result, err := svc.ChangeResourceRecordSets(input)
828	if err != nil {
829		if aerr, ok := err.(awserr.Error); ok {
830			switch aerr.Code() {
831			case route53.ErrCodeNoSuchHostedZone:
832				fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error())
833			case route53.ErrCodeNoSuchHealthCheck:
834				fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error())
835			case route53.ErrCodeInvalidChangeBatch:
836				fmt.Println(route53.ErrCodeInvalidChangeBatch, aerr.Error())
837			case route53.ErrCodeInvalidInput:
838				fmt.Println(route53.ErrCodeInvalidInput, aerr.Error())
839			case route53.ErrCodePriorRequestNotComplete:
840				fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error())
841			default:
842				fmt.Println(aerr.Error())
843			}
844		} else {
845			// Print the error, cast err to awserr.Error to get the Code and
846			// Message from an error.
847			fmt.Println(err.Error())
848		}
849		return
850	}
851
852	fmt.Println(result)
853}
854
855// To add or remove tags from a hosted zone or health check
856//
857// The following example adds two tags and removes one tag from the hosted zone with
858// ID Z3M3LMPEXAMPLE.
859func ExampleRoute53_ChangeTagsForResource_shared00() {
860	svc := route53.New(session.New())
861	input := &route53.ChangeTagsForResourceInput{
862		AddTags: []*route53.Tag{
863			{
864				Key:   aws.String("apex"),
865				Value: aws.String("3874"),
866			},
867			{
868				Key:   aws.String("acme"),
869				Value: aws.String("4938"),
870			},
871		},
872		RemoveTagKeys: []*string{
873			aws.String("Nadir"),
874		},
875		ResourceId:   aws.String("Z3M3LMPEXAMPLE"),
876		ResourceType: aws.String("hostedzone"),
877	}
878
879	result, err := svc.ChangeTagsForResource(input)
880	if err != nil {
881		if aerr, ok := err.(awserr.Error); ok {
882			switch aerr.Code() {
883			case route53.ErrCodeInvalidInput:
884				fmt.Println(route53.ErrCodeInvalidInput, aerr.Error())
885			case route53.ErrCodeNoSuchHealthCheck:
886				fmt.Println(route53.ErrCodeNoSuchHealthCheck, aerr.Error())
887			case route53.ErrCodeNoSuchHostedZone:
888				fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error())
889			case route53.ErrCodePriorRequestNotComplete:
890				fmt.Println(route53.ErrCodePriorRequestNotComplete, aerr.Error())
891			case route53.ErrCodeThrottlingException:
892				fmt.Println(route53.ErrCodeThrottlingException, aerr.Error())
893			default:
894				fmt.Println(aerr.Error())
895			}
896		} else {
897			// Print the error, cast err to awserr.Error to get the Code and
898			// Message from an error.
899			fmt.Println(err.Error())
900		}
901		return
902	}
903
904	fmt.Println(result)
905}
906
907// To get information about a hosted zone
908//
909// The following example gets information about the Z3M3LMPEXAMPLE hosted zone.
910func ExampleRoute53_GetHostedZone_shared00() {
911	svc := route53.New(session.New())
912	input := &route53.GetHostedZoneInput{
913		Id: aws.String("Z3M3LMPEXAMPLE"),
914	}
915
916	result, err := svc.GetHostedZone(input)
917	if err != nil {
918		if aerr, ok := err.(awserr.Error); ok {
919			switch aerr.Code() {
920			case route53.ErrCodeNoSuchHostedZone:
921				fmt.Println(route53.ErrCodeNoSuchHostedZone, aerr.Error())
922			case route53.ErrCodeInvalidInput:
923				fmt.Println(route53.ErrCodeInvalidInput, aerr.Error())
924			default:
925				fmt.Println(aerr.Error())
926			}
927		} else {
928			// Print the error, cast err to awserr.Error to get the Code and
929			// Message from an error.
930			fmt.Println(err.Error())
931		}
932		return
933	}
934
935	fmt.Println(result)
936}
937