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