1// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
2
3package elbv2_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/elbv2"
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 add tags to a load balancer
29//
30// This example adds the specified tags to the specified load balancer.
31func ExampleELBV2_AddTags_shared00() {
32	svc := elbv2.New(session.New())
33	input := &elbv2.AddTagsInput{
34		ResourceArns: []*string{
35			aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"),
36		},
37		Tags: []*elbv2.Tag{
38			{
39				Key:   aws.String("project"),
40				Value: aws.String("lima"),
41			},
42			{
43				Key:   aws.String("department"),
44				Value: aws.String("digital-media"),
45			},
46		},
47	}
48
49	result, err := svc.AddTags(input)
50	if err != nil {
51		if aerr, ok := err.(awserr.Error); ok {
52			switch aerr.Code() {
53			case elbv2.ErrCodeDuplicateTagKeysException:
54				fmt.Println(elbv2.ErrCodeDuplicateTagKeysException, aerr.Error())
55			case elbv2.ErrCodeTooManyTagsException:
56				fmt.Println(elbv2.ErrCodeTooManyTagsException, aerr.Error())
57			case elbv2.ErrCodeLoadBalancerNotFoundException:
58				fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error())
59			case elbv2.ErrCodeTargetGroupNotFoundException:
60				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, 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 an HTTP listener
76//
77// This example creates an HTTP listener for the specified load balancer that forwards
78// requests to the specified target group.
79func ExampleELBV2_CreateListener_shared00() {
80	svc := elbv2.New(session.New())
81	input := &elbv2.CreateListenerInput{
82		DefaultActions: []*elbv2.Action{
83			{
84				TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"),
85				Type:           aws.String("forward"),
86			},
87		},
88		LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"),
89		Port:            aws.Int64(80),
90		Protocol:        aws.String("HTTP"),
91	}
92
93	result, err := svc.CreateListener(input)
94	if err != nil {
95		if aerr, ok := err.(awserr.Error); ok {
96			switch aerr.Code() {
97			case elbv2.ErrCodeDuplicateListenerException:
98				fmt.Println(elbv2.ErrCodeDuplicateListenerException, aerr.Error())
99			case elbv2.ErrCodeTooManyListenersException:
100				fmt.Println(elbv2.ErrCodeTooManyListenersException, aerr.Error())
101			case elbv2.ErrCodeTooManyCertificatesException:
102				fmt.Println(elbv2.ErrCodeTooManyCertificatesException, aerr.Error())
103			case elbv2.ErrCodeLoadBalancerNotFoundException:
104				fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error())
105			case elbv2.ErrCodeTargetGroupNotFoundException:
106				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
107			case elbv2.ErrCodeTargetGroupAssociationLimitException:
108				fmt.Println(elbv2.ErrCodeTargetGroupAssociationLimitException, aerr.Error())
109			case elbv2.ErrCodeInvalidConfigurationRequestException:
110				fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error())
111			case elbv2.ErrCodeIncompatibleProtocolsException:
112				fmt.Println(elbv2.ErrCodeIncompatibleProtocolsException, aerr.Error())
113			case elbv2.ErrCodeSSLPolicyNotFoundException:
114				fmt.Println(elbv2.ErrCodeSSLPolicyNotFoundException, aerr.Error())
115			case elbv2.ErrCodeCertificateNotFoundException:
116				fmt.Println(elbv2.ErrCodeCertificateNotFoundException, aerr.Error())
117			case elbv2.ErrCodeUnsupportedProtocolException:
118				fmt.Println(elbv2.ErrCodeUnsupportedProtocolException, aerr.Error())
119			case elbv2.ErrCodeTooManyRegistrationsForTargetIdException:
120				fmt.Println(elbv2.ErrCodeTooManyRegistrationsForTargetIdException, aerr.Error())
121			case elbv2.ErrCodeTooManyTargetsException:
122				fmt.Println(elbv2.ErrCodeTooManyTargetsException, aerr.Error())
123			case elbv2.ErrCodeTooManyActionsException:
124				fmt.Println(elbv2.ErrCodeTooManyActionsException, aerr.Error())
125			case elbv2.ErrCodeInvalidLoadBalancerActionException:
126				fmt.Println(elbv2.ErrCodeInvalidLoadBalancerActionException, aerr.Error())
127			case elbv2.ErrCodeTooManyUniqueTargetGroupsPerLoadBalancerException:
128				fmt.Println(elbv2.ErrCodeTooManyUniqueTargetGroupsPerLoadBalancerException, aerr.Error())
129			case elbv2.ErrCodeALPNPolicyNotSupportedException:
130				fmt.Println(elbv2.ErrCodeALPNPolicyNotSupportedException, aerr.Error())
131			default:
132				fmt.Println(aerr.Error())
133			}
134		} else {
135			// Print the error, cast err to awserr.Error to get the Code and
136			// Message from an error.
137			fmt.Println(err.Error())
138		}
139		return
140	}
141
142	fmt.Println(result)
143}
144
145// To create an HTTPS listener
146//
147// This example creates an HTTPS listener for the specified load balancer that forwards
148// requests to the specified target group. Note that you must specify an SSL certificate
149// for an HTTPS listener. You can create and manage certificates using AWS Certificate
150// Manager (ACM). Alternatively, you can create a certificate using SSL/TLS tools, get
151// the certificate signed by a certificate authority (CA), and upload the certificate
152// to AWS Identity and Access Management (IAM).
153func ExampleELBV2_CreateListener_shared01() {
154	svc := elbv2.New(session.New())
155	input := &elbv2.CreateListenerInput{
156		Certificates: []*elbv2.Certificate{
157			{
158				CertificateArn: aws.String("arn:aws:iam::123456789012:server-certificate/my-server-cert"),
159			},
160		},
161		DefaultActions: []*elbv2.Action{
162			{
163				TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"),
164				Type:           aws.String("forward"),
165			},
166		},
167		LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"),
168		Port:            aws.Int64(443),
169		Protocol:        aws.String("HTTPS"),
170		SslPolicy:       aws.String("ELBSecurityPolicy-2015-05"),
171	}
172
173	result, err := svc.CreateListener(input)
174	if err != nil {
175		if aerr, ok := err.(awserr.Error); ok {
176			switch aerr.Code() {
177			case elbv2.ErrCodeDuplicateListenerException:
178				fmt.Println(elbv2.ErrCodeDuplicateListenerException, aerr.Error())
179			case elbv2.ErrCodeTooManyListenersException:
180				fmt.Println(elbv2.ErrCodeTooManyListenersException, aerr.Error())
181			case elbv2.ErrCodeTooManyCertificatesException:
182				fmt.Println(elbv2.ErrCodeTooManyCertificatesException, aerr.Error())
183			case elbv2.ErrCodeLoadBalancerNotFoundException:
184				fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error())
185			case elbv2.ErrCodeTargetGroupNotFoundException:
186				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
187			case elbv2.ErrCodeTargetGroupAssociationLimitException:
188				fmt.Println(elbv2.ErrCodeTargetGroupAssociationLimitException, aerr.Error())
189			case elbv2.ErrCodeInvalidConfigurationRequestException:
190				fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error())
191			case elbv2.ErrCodeIncompatibleProtocolsException:
192				fmt.Println(elbv2.ErrCodeIncompatibleProtocolsException, aerr.Error())
193			case elbv2.ErrCodeSSLPolicyNotFoundException:
194				fmt.Println(elbv2.ErrCodeSSLPolicyNotFoundException, aerr.Error())
195			case elbv2.ErrCodeCertificateNotFoundException:
196				fmt.Println(elbv2.ErrCodeCertificateNotFoundException, aerr.Error())
197			case elbv2.ErrCodeUnsupportedProtocolException:
198				fmt.Println(elbv2.ErrCodeUnsupportedProtocolException, aerr.Error())
199			case elbv2.ErrCodeTooManyRegistrationsForTargetIdException:
200				fmt.Println(elbv2.ErrCodeTooManyRegistrationsForTargetIdException, aerr.Error())
201			case elbv2.ErrCodeTooManyTargetsException:
202				fmt.Println(elbv2.ErrCodeTooManyTargetsException, aerr.Error())
203			case elbv2.ErrCodeTooManyActionsException:
204				fmt.Println(elbv2.ErrCodeTooManyActionsException, aerr.Error())
205			case elbv2.ErrCodeInvalidLoadBalancerActionException:
206				fmt.Println(elbv2.ErrCodeInvalidLoadBalancerActionException, aerr.Error())
207			case elbv2.ErrCodeTooManyUniqueTargetGroupsPerLoadBalancerException:
208				fmt.Println(elbv2.ErrCodeTooManyUniqueTargetGroupsPerLoadBalancerException, aerr.Error())
209			case elbv2.ErrCodeALPNPolicyNotSupportedException:
210				fmt.Println(elbv2.ErrCodeALPNPolicyNotSupportedException, aerr.Error())
211			default:
212				fmt.Println(aerr.Error())
213			}
214		} else {
215			// Print the error, cast err to awserr.Error to get the Code and
216			// Message from an error.
217			fmt.Println(err.Error())
218		}
219		return
220	}
221
222	fmt.Println(result)
223}
224
225// To create an Internet-facing load balancer
226//
227// This example creates an Internet-facing load balancer and enables the Availability
228// Zones for the specified subnets.
229func ExampleELBV2_CreateLoadBalancer_shared00() {
230	svc := elbv2.New(session.New())
231	input := &elbv2.CreateLoadBalancerInput{
232		Name: aws.String("my-load-balancer"),
233		Subnets: []*string{
234			aws.String("subnet-b7d581c0"),
235			aws.String("subnet-8360a9e7"),
236		},
237	}
238
239	result, err := svc.CreateLoadBalancer(input)
240	if err != nil {
241		if aerr, ok := err.(awserr.Error); ok {
242			switch aerr.Code() {
243			case elbv2.ErrCodeDuplicateLoadBalancerNameException:
244				fmt.Println(elbv2.ErrCodeDuplicateLoadBalancerNameException, aerr.Error())
245			case elbv2.ErrCodeTooManyLoadBalancersException:
246				fmt.Println(elbv2.ErrCodeTooManyLoadBalancersException, aerr.Error())
247			case elbv2.ErrCodeInvalidConfigurationRequestException:
248				fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error())
249			case elbv2.ErrCodeSubnetNotFoundException:
250				fmt.Println(elbv2.ErrCodeSubnetNotFoundException, aerr.Error())
251			case elbv2.ErrCodeInvalidSubnetException:
252				fmt.Println(elbv2.ErrCodeInvalidSubnetException, aerr.Error())
253			case elbv2.ErrCodeInvalidSecurityGroupException:
254				fmt.Println(elbv2.ErrCodeInvalidSecurityGroupException, aerr.Error())
255			case elbv2.ErrCodeInvalidSchemeException:
256				fmt.Println(elbv2.ErrCodeInvalidSchemeException, aerr.Error())
257			case elbv2.ErrCodeTooManyTagsException:
258				fmt.Println(elbv2.ErrCodeTooManyTagsException, aerr.Error())
259			case elbv2.ErrCodeDuplicateTagKeysException:
260				fmt.Println(elbv2.ErrCodeDuplicateTagKeysException, aerr.Error())
261			case elbv2.ErrCodeResourceInUseException:
262				fmt.Println(elbv2.ErrCodeResourceInUseException, aerr.Error())
263			case elbv2.ErrCodeAllocationIdNotFoundException:
264				fmt.Println(elbv2.ErrCodeAllocationIdNotFoundException, aerr.Error())
265			case elbv2.ErrCodeAvailabilityZoneNotSupportedException:
266				fmt.Println(elbv2.ErrCodeAvailabilityZoneNotSupportedException, aerr.Error())
267			case elbv2.ErrCodeOperationNotPermittedException:
268				fmt.Println(elbv2.ErrCodeOperationNotPermittedException, aerr.Error())
269			default:
270				fmt.Println(aerr.Error())
271			}
272		} else {
273			// Print the error, cast err to awserr.Error to get the Code and
274			// Message from an error.
275			fmt.Println(err.Error())
276		}
277		return
278	}
279
280	fmt.Println(result)
281}
282
283// To create an internal load balancer
284//
285// This example creates an internal load balancer and enables the Availability Zones
286// for the specified subnets.
287func ExampleELBV2_CreateLoadBalancer_shared01() {
288	svc := elbv2.New(session.New())
289	input := &elbv2.CreateLoadBalancerInput{
290		Name:   aws.String("my-internal-load-balancer"),
291		Scheme: aws.String("internal"),
292		Subnets: []*string{
293			aws.String("subnet-b7d581c0"),
294			aws.String("subnet-8360a9e7"),
295		},
296	}
297
298	result, err := svc.CreateLoadBalancer(input)
299	if err != nil {
300		if aerr, ok := err.(awserr.Error); ok {
301			switch aerr.Code() {
302			case elbv2.ErrCodeDuplicateLoadBalancerNameException:
303				fmt.Println(elbv2.ErrCodeDuplicateLoadBalancerNameException, aerr.Error())
304			case elbv2.ErrCodeTooManyLoadBalancersException:
305				fmt.Println(elbv2.ErrCodeTooManyLoadBalancersException, aerr.Error())
306			case elbv2.ErrCodeInvalidConfigurationRequestException:
307				fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error())
308			case elbv2.ErrCodeSubnetNotFoundException:
309				fmt.Println(elbv2.ErrCodeSubnetNotFoundException, aerr.Error())
310			case elbv2.ErrCodeInvalidSubnetException:
311				fmt.Println(elbv2.ErrCodeInvalidSubnetException, aerr.Error())
312			case elbv2.ErrCodeInvalidSecurityGroupException:
313				fmt.Println(elbv2.ErrCodeInvalidSecurityGroupException, aerr.Error())
314			case elbv2.ErrCodeInvalidSchemeException:
315				fmt.Println(elbv2.ErrCodeInvalidSchemeException, aerr.Error())
316			case elbv2.ErrCodeTooManyTagsException:
317				fmt.Println(elbv2.ErrCodeTooManyTagsException, aerr.Error())
318			case elbv2.ErrCodeDuplicateTagKeysException:
319				fmt.Println(elbv2.ErrCodeDuplicateTagKeysException, aerr.Error())
320			case elbv2.ErrCodeResourceInUseException:
321				fmt.Println(elbv2.ErrCodeResourceInUseException, aerr.Error())
322			case elbv2.ErrCodeAllocationIdNotFoundException:
323				fmt.Println(elbv2.ErrCodeAllocationIdNotFoundException, aerr.Error())
324			case elbv2.ErrCodeAvailabilityZoneNotSupportedException:
325				fmt.Println(elbv2.ErrCodeAvailabilityZoneNotSupportedException, aerr.Error())
326			case elbv2.ErrCodeOperationNotPermittedException:
327				fmt.Println(elbv2.ErrCodeOperationNotPermittedException, aerr.Error())
328			default:
329				fmt.Println(aerr.Error())
330			}
331		} else {
332			// Print the error, cast err to awserr.Error to get the Code and
333			// Message from an error.
334			fmt.Println(err.Error())
335		}
336		return
337	}
338
339	fmt.Println(result)
340}
341
342// To create a rule
343//
344// This example creates a rule that forwards requests to the specified target group
345// if the URL contains the specified pattern (for example, /img/*).
346func ExampleELBV2_CreateRule_shared00() {
347	svc := elbv2.New(session.New())
348	input := &elbv2.CreateRuleInput{
349		Actions: []*elbv2.Action{
350			{
351				TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"),
352				Type:           aws.String("forward"),
353			},
354		},
355		Conditions: []*elbv2.RuleCondition{
356			{
357				Field: aws.String("path-pattern"),
358				Values: []*string{
359					aws.String("/img/*"),
360				},
361			},
362		},
363		ListenerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2"),
364		Priority:    aws.Int64(10),
365	}
366
367	result, err := svc.CreateRule(input)
368	if err != nil {
369		if aerr, ok := err.(awserr.Error); ok {
370			switch aerr.Code() {
371			case elbv2.ErrCodePriorityInUseException:
372				fmt.Println(elbv2.ErrCodePriorityInUseException, aerr.Error())
373			case elbv2.ErrCodeTooManyTargetGroupsException:
374				fmt.Println(elbv2.ErrCodeTooManyTargetGroupsException, aerr.Error())
375			case elbv2.ErrCodeTooManyRulesException:
376				fmt.Println(elbv2.ErrCodeTooManyRulesException, aerr.Error())
377			case elbv2.ErrCodeTargetGroupAssociationLimitException:
378				fmt.Println(elbv2.ErrCodeTargetGroupAssociationLimitException, aerr.Error())
379			case elbv2.ErrCodeIncompatibleProtocolsException:
380				fmt.Println(elbv2.ErrCodeIncompatibleProtocolsException, aerr.Error())
381			case elbv2.ErrCodeListenerNotFoundException:
382				fmt.Println(elbv2.ErrCodeListenerNotFoundException, aerr.Error())
383			case elbv2.ErrCodeTargetGroupNotFoundException:
384				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
385			case elbv2.ErrCodeInvalidConfigurationRequestException:
386				fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error())
387			case elbv2.ErrCodeTooManyRegistrationsForTargetIdException:
388				fmt.Println(elbv2.ErrCodeTooManyRegistrationsForTargetIdException, aerr.Error())
389			case elbv2.ErrCodeTooManyTargetsException:
390				fmt.Println(elbv2.ErrCodeTooManyTargetsException, aerr.Error())
391			case elbv2.ErrCodeUnsupportedProtocolException:
392				fmt.Println(elbv2.ErrCodeUnsupportedProtocolException, aerr.Error())
393			case elbv2.ErrCodeTooManyActionsException:
394				fmt.Println(elbv2.ErrCodeTooManyActionsException, aerr.Error())
395			case elbv2.ErrCodeInvalidLoadBalancerActionException:
396				fmt.Println(elbv2.ErrCodeInvalidLoadBalancerActionException, aerr.Error())
397			case elbv2.ErrCodeTooManyUniqueTargetGroupsPerLoadBalancerException:
398				fmt.Println(elbv2.ErrCodeTooManyUniqueTargetGroupsPerLoadBalancerException, 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 a target group
414//
415// This example creates a target group that you can use to route traffic to targets
416// using HTTP on port 80. This target group uses the default health check configuration.
417func ExampleELBV2_CreateTargetGroup_shared00() {
418	svc := elbv2.New(session.New())
419	input := &elbv2.CreateTargetGroupInput{
420		Name:     aws.String("my-targets"),
421		Port:     aws.Int64(80),
422		Protocol: aws.String("HTTP"),
423		VpcId:    aws.String("vpc-3ac0fb5f"),
424	}
425
426	result, err := svc.CreateTargetGroup(input)
427	if err != nil {
428		if aerr, ok := err.(awserr.Error); ok {
429			switch aerr.Code() {
430			case elbv2.ErrCodeDuplicateTargetGroupNameException:
431				fmt.Println(elbv2.ErrCodeDuplicateTargetGroupNameException, aerr.Error())
432			case elbv2.ErrCodeTooManyTargetGroupsException:
433				fmt.Println(elbv2.ErrCodeTooManyTargetGroupsException, aerr.Error())
434			case elbv2.ErrCodeInvalidConfigurationRequestException:
435				fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error())
436			default:
437				fmt.Println(aerr.Error())
438			}
439		} else {
440			// Print the error, cast err to awserr.Error to get the Code and
441			// Message from an error.
442			fmt.Println(err.Error())
443		}
444		return
445	}
446
447	fmt.Println(result)
448}
449
450// To delete a listener
451//
452// This example deletes the specified listener.
453func ExampleELBV2_DeleteListener_shared00() {
454	svc := elbv2.New(session.New())
455	input := &elbv2.DeleteListenerInput{
456		ListenerArn: aws.String("arn:aws:elasticloadbalancing:ua-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2"),
457	}
458
459	result, err := svc.DeleteListener(input)
460	if err != nil {
461		if aerr, ok := err.(awserr.Error); ok {
462			switch aerr.Code() {
463			case elbv2.ErrCodeListenerNotFoundException:
464				fmt.Println(elbv2.ErrCodeListenerNotFoundException, aerr.Error())
465			default:
466				fmt.Println(aerr.Error())
467			}
468		} else {
469			// Print the error, cast err to awserr.Error to get the Code and
470			// Message from an error.
471			fmt.Println(err.Error())
472		}
473		return
474	}
475
476	fmt.Println(result)
477}
478
479// To delete a load balancer
480//
481// This example deletes the specified load balancer.
482func ExampleELBV2_DeleteLoadBalancer_shared00() {
483	svc := elbv2.New(session.New())
484	input := &elbv2.DeleteLoadBalancerInput{
485		LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"),
486	}
487
488	result, err := svc.DeleteLoadBalancer(input)
489	if err != nil {
490		if aerr, ok := err.(awserr.Error); ok {
491			switch aerr.Code() {
492			case elbv2.ErrCodeLoadBalancerNotFoundException:
493				fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error())
494			case elbv2.ErrCodeOperationNotPermittedException:
495				fmt.Println(elbv2.ErrCodeOperationNotPermittedException, aerr.Error())
496			case elbv2.ErrCodeResourceInUseException:
497				fmt.Println(elbv2.ErrCodeResourceInUseException, aerr.Error())
498			default:
499				fmt.Println(aerr.Error())
500			}
501		} else {
502			// Print the error, cast err to awserr.Error to get the Code and
503			// Message from an error.
504			fmt.Println(err.Error())
505		}
506		return
507	}
508
509	fmt.Println(result)
510}
511
512// To delete a rule
513//
514// This example deletes the specified rule.
515func ExampleELBV2_DeleteRule_shared00() {
516	svc := elbv2.New(session.New())
517	input := &elbv2.DeleteRuleInput{
518		RuleArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/1291d13826f405c3"),
519	}
520
521	result, err := svc.DeleteRule(input)
522	if err != nil {
523		if aerr, ok := err.(awserr.Error); ok {
524			switch aerr.Code() {
525			case elbv2.ErrCodeRuleNotFoundException:
526				fmt.Println(elbv2.ErrCodeRuleNotFoundException, aerr.Error())
527			case elbv2.ErrCodeOperationNotPermittedException:
528				fmt.Println(elbv2.ErrCodeOperationNotPermittedException, 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 delete a target group
544//
545// This example deletes the specified target group.
546func ExampleELBV2_DeleteTargetGroup_shared00() {
547	svc := elbv2.New(session.New())
548	input := &elbv2.DeleteTargetGroupInput{
549		TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"),
550	}
551
552	result, err := svc.DeleteTargetGroup(input)
553	if err != nil {
554		if aerr, ok := err.(awserr.Error); ok {
555			switch aerr.Code() {
556			case elbv2.ErrCodeResourceInUseException:
557				fmt.Println(elbv2.ErrCodeResourceInUseException, aerr.Error())
558			default:
559				fmt.Println(aerr.Error())
560			}
561		} else {
562			// Print the error, cast err to awserr.Error to get the Code and
563			// Message from an error.
564			fmt.Println(err.Error())
565		}
566		return
567	}
568
569	fmt.Println(result)
570}
571
572// To deregister a target from a target group
573//
574// This example deregisters the specified instance from the specified target group.
575func ExampleELBV2_DeregisterTargets_shared00() {
576	svc := elbv2.New(session.New())
577	input := &elbv2.DeregisterTargetsInput{
578		TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"),
579		Targets: []*elbv2.TargetDescription{
580			{
581				Id: aws.String("i-0f76fade"),
582			},
583		},
584	}
585
586	result, err := svc.DeregisterTargets(input)
587	if err != nil {
588		if aerr, ok := err.(awserr.Error); ok {
589			switch aerr.Code() {
590			case elbv2.ErrCodeTargetGroupNotFoundException:
591				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
592			case elbv2.ErrCodeInvalidTargetException:
593				fmt.Println(elbv2.ErrCodeInvalidTargetException, aerr.Error())
594			default:
595				fmt.Println(aerr.Error())
596			}
597		} else {
598			// Print the error, cast err to awserr.Error to get the Code and
599			// Message from an error.
600			fmt.Println(err.Error())
601		}
602		return
603	}
604
605	fmt.Println(result)
606}
607
608// To describe a listener
609//
610// This example describes the specified listener.
611func ExampleELBV2_DescribeListeners_shared00() {
612	svc := elbv2.New(session.New())
613	input := &elbv2.DescribeListenersInput{
614		ListenerArns: []*string{
615			aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2"),
616		},
617	}
618
619	result, err := svc.DescribeListeners(input)
620	if err != nil {
621		if aerr, ok := err.(awserr.Error); ok {
622			switch aerr.Code() {
623			case elbv2.ErrCodeListenerNotFoundException:
624				fmt.Println(elbv2.ErrCodeListenerNotFoundException, aerr.Error())
625			case elbv2.ErrCodeLoadBalancerNotFoundException:
626				fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error())
627			case elbv2.ErrCodeUnsupportedProtocolException:
628				fmt.Println(elbv2.ErrCodeUnsupportedProtocolException, aerr.Error())
629			default:
630				fmt.Println(aerr.Error())
631			}
632		} else {
633			// Print the error, cast err to awserr.Error to get the Code and
634			// Message from an error.
635			fmt.Println(err.Error())
636		}
637		return
638	}
639
640	fmt.Println(result)
641}
642
643// To describe load balancer attributes
644//
645// This example describes the attributes of the specified load balancer.
646func ExampleELBV2_DescribeLoadBalancerAttributes_shared00() {
647	svc := elbv2.New(session.New())
648	input := &elbv2.DescribeLoadBalancerAttributesInput{
649		LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"),
650	}
651
652	result, err := svc.DescribeLoadBalancerAttributes(input)
653	if err != nil {
654		if aerr, ok := err.(awserr.Error); ok {
655			switch aerr.Code() {
656			case elbv2.ErrCodeLoadBalancerNotFoundException:
657				fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error())
658			default:
659				fmt.Println(aerr.Error())
660			}
661		} else {
662			// Print the error, cast err to awserr.Error to get the Code and
663			// Message from an error.
664			fmt.Println(err.Error())
665		}
666		return
667	}
668
669	fmt.Println(result)
670}
671
672// To describe a load balancer
673//
674// This example describes the specified load balancer.
675func ExampleELBV2_DescribeLoadBalancers_shared00() {
676	svc := elbv2.New(session.New())
677	input := &elbv2.DescribeLoadBalancersInput{
678		LoadBalancerArns: []*string{
679			aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"),
680		},
681	}
682
683	result, err := svc.DescribeLoadBalancers(input)
684	if err != nil {
685		if aerr, ok := err.(awserr.Error); ok {
686			switch aerr.Code() {
687			case elbv2.ErrCodeLoadBalancerNotFoundException:
688				fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error())
689			default:
690				fmt.Println(aerr.Error())
691			}
692		} else {
693			// Print the error, cast err to awserr.Error to get the Code and
694			// Message from an error.
695			fmt.Println(err.Error())
696		}
697		return
698	}
699
700	fmt.Println(result)
701}
702
703// To describe a rule
704//
705// This example describes the specified rule.
706func ExampleELBV2_DescribeRules_shared00() {
707	svc := elbv2.New(session.New())
708	input := &elbv2.DescribeRulesInput{
709		RuleArns: []*string{
710			aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/9683b2d02a6cabee"),
711		},
712	}
713
714	result, err := svc.DescribeRules(input)
715	if err != nil {
716		if aerr, ok := err.(awserr.Error); ok {
717			switch aerr.Code() {
718			case elbv2.ErrCodeListenerNotFoundException:
719				fmt.Println(elbv2.ErrCodeListenerNotFoundException, aerr.Error())
720			case elbv2.ErrCodeRuleNotFoundException:
721				fmt.Println(elbv2.ErrCodeRuleNotFoundException, aerr.Error())
722			case elbv2.ErrCodeUnsupportedProtocolException:
723				fmt.Println(elbv2.ErrCodeUnsupportedProtocolException, aerr.Error())
724			default:
725				fmt.Println(aerr.Error())
726			}
727		} else {
728			// Print the error, cast err to awserr.Error to get the Code and
729			// Message from an error.
730			fmt.Println(err.Error())
731		}
732		return
733	}
734
735	fmt.Println(result)
736}
737
738// To describe a policy used for SSL negotiation
739//
740// This example describes the specified policy used for SSL negotiation.
741func ExampleELBV2_DescribeSSLPolicies_shared00() {
742	svc := elbv2.New(session.New())
743	input := &elbv2.DescribeSSLPoliciesInput{
744		Names: []*string{
745			aws.String("ELBSecurityPolicy-2015-05"),
746		},
747	}
748
749	result, err := svc.DescribeSSLPolicies(input)
750	if err != nil {
751		if aerr, ok := err.(awserr.Error); ok {
752			switch aerr.Code() {
753			case elbv2.ErrCodeSSLPolicyNotFoundException:
754				fmt.Println(elbv2.ErrCodeSSLPolicyNotFoundException, aerr.Error())
755			default:
756				fmt.Println(aerr.Error())
757			}
758		} else {
759			// Print the error, cast err to awserr.Error to get the Code and
760			// Message from an error.
761			fmt.Println(err.Error())
762		}
763		return
764	}
765
766	fmt.Println(result)
767}
768
769// To describe the tags assigned to a load balancer
770//
771// This example describes the tags assigned to the specified load balancer.
772func ExampleELBV2_DescribeTags_shared00() {
773	svc := elbv2.New(session.New())
774	input := &elbv2.DescribeTagsInput{
775		ResourceArns: []*string{
776			aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"),
777		},
778	}
779
780	result, err := svc.DescribeTags(input)
781	if err != nil {
782		if aerr, ok := err.(awserr.Error); ok {
783			switch aerr.Code() {
784			case elbv2.ErrCodeLoadBalancerNotFoundException:
785				fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error())
786			case elbv2.ErrCodeTargetGroupNotFoundException:
787				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
788			case elbv2.ErrCodeListenerNotFoundException:
789				fmt.Println(elbv2.ErrCodeListenerNotFoundException, aerr.Error())
790			case elbv2.ErrCodeRuleNotFoundException:
791				fmt.Println(elbv2.ErrCodeRuleNotFoundException, aerr.Error())
792			default:
793				fmt.Println(aerr.Error())
794			}
795		} else {
796			// Print the error, cast err to awserr.Error to get the Code and
797			// Message from an error.
798			fmt.Println(err.Error())
799		}
800		return
801	}
802
803	fmt.Println(result)
804}
805
806// To describe target group attributes
807//
808// This example describes the attributes of the specified target group.
809func ExampleELBV2_DescribeTargetGroupAttributes_shared00() {
810	svc := elbv2.New(session.New())
811	input := &elbv2.DescribeTargetGroupAttributesInput{
812		TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"),
813	}
814
815	result, err := svc.DescribeTargetGroupAttributes(input)
816	if err != nil {
817		if aerr, ok := err.(awserr.Error); ok {
818			switch aerr.Code() {
819			case elbv2.ErrCodeTargetGroupNotFoundException:
820				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
821			default:
822				fmt.Println(aerr.Error())
823			}
824		} else {
825			// Print the error, cast err to awserr.Error to get the Code and
826			// Message from an error.
827			fmt.Println(err.Error())
828		}
829		return
830	}
831
832	fmt.Println(result)
833}
834
835// To describe a target group
836//
837// This example describes the specified target group.
838func ExampleELBV2_DescribeTargetGroups_shared00() {
839	svc := elbv2.New(session.New())
840	input := &elbv2.DescribeTargetGroupsInput{
841		TargetGroupArns: []*string{
842			aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"),
843		},
844	}
845
846	result, err := svc.DescribeTargetGroups(input)
847	if err != nil {
848		if aerr, ok := err.(awserr.Error); ok {
849			switch aerr.Code() {
850			case elbv2.ErrCodeLoadBalancerNotFoundException:
851				fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error())
852			case elbv2.ErrCodeTargetGroupNotFoundException:
853				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
854			default:
855				fmt.Println(aerr.Error())
856			}
857		} else {
858			// Print the error, cast err to awserr.Error to get the Code and
859			// Message from an error.
860			fmt.Println(err.Error())
861		}
862		return
863	}
864
865	fmt.Println(result)
866}
867
868// To describe the health of the targets for a target group
869//
870// This example describes the health of the targets for the specified target group.
871// One target is healthy but the other is not specified in an action, so it can't receive
872// traffic from the load balancer.
873func ExampleELBV2_DescribeTargetHealth_shared00() {
874	svc := elbv2.New(session.New())
875	input := &elbv2.DescribeTargetHealthInput{
876		TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"),
877	}
878
879	result, err := svc.DescribeTargetHealth(input)
880	if err != nil {
881		if aerr, ok := err.(awserr.Error); ok {
882			switch aerr.Code() {
883			case elbv2.ErrCodeInvalidTargetException:
884				fmt.Println(elbv2.ErrCodeInvalidTargetException, aerr.Error())
885			case elbv2.ErrCodeTargetGroupNotFoundException:
886				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
887			case elbv2.ErrCodeHealthUnavailableException:
888				fmt.Println(elbv2.ErrCodeHealthUnavailableException, aerr.Error())
889			default:
890				fmt.Println(aerr.Error())
891			}
892		} else {
893			// Print the error, cast err to awserr.Error to get the Code and
894			// Message from an error.
895			fmt.Println(err.Error())
896		}
897		return
898	}
899
900	fmt.Println(result)
901}
902
903// To describe the health of a target
904//
905// This example describes the health of the specified target. This target is healthy.
906func ExampleELBV2_DescribeTargetHealth_shared01() {
907	svc := elbv2.New(session.New())
908	input := &elbv2.DescribeTargetHealthInput{
909		TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"),
910		Targets: []*elbv2.TargetDescription{
911			{
912				Id:   aws.String("i-0f76fade"),
913				Port: aws.Int64(80),
914			},
915		},
916	}
917
918	result, err := svc.DescribeTargetHealth(input)
919	if err != nil {
920		if aerr, ok := err.(awserr.Error); ok {
921			switch aerr.Code() {
922			case elbv2.ErrCodeInvalidTargetException:
923				fmt.Println(elbv2.ErrCodeInvalidTargetException, aerr.Error())
924			case elbv2.ErrCodeTargetGroupNotFoundException:
925				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
926			case elbv2.ErrCodeHealthUnavailableException:
927				fmt.Println(elbv2.ErrCodeHealthUnavailableException, aerr.Error())
928			default:
929				fmt.Println(aerr.Error())
930			}
931		} else {
932			// Print the error, cast err to awserr.Error to get the Code and
933			// Message from an error.
934			fmt.Println(err.Error())
935		}
936		return
937	}
938
939	fmt.Println(result)
940}
941
942// To change the default action for a listener
943//
944// This example changes the default action for the specified listener.
945func ExampleELBV2_ModifyListener_shared00() {
946	svc := elbv2.New(session.New())
947	input := &elbv2.ModifyListenerInput{
948		DefaultActions: []*elbv2.Action{
949			{
950				TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-new-targets/2453ed029918f21f"),
951				Type:           aws.String("forward"),
952			},
953		},
954		ListenerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2"),
955	}
956
957	result, err := svc.ModifyListener(input)
958	if err != nil {
959		if aerr, ok := err.(awserr.Error); ok {
960			switch aerr.Code() {
961			case elbv2.ErrCodeDuplicateListenerException:
962				fmt.Println(elbv2.ErrCodeDuplicateListenerException, aerr.Error())
963			case elbv2.ErrCodeTooManyListenersException:
964				fmt.Println(elbv2.ErrCodeTooManyListenersException, aerr.Error())
965			case elbv2.ErrCodeTooManyCertificatesException:
966				fmt.Println(elbv2.ErrCodeTooManyCertificatesException, aerr.Error())
967			case elbv2.ErrCodeListenerNotFoundException:
968				fmt.Println(elbv2.ErrCodeListenerNotFoundException, aerr.Error())
969			case elbv2.ErrCodeTargetGroupNotFoundException:
970				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
971			case elbv2.ErrCodeTargetGroupAssociationLimitException:
972				fmt.Println(elbv2.ErrCodeTargetGroupAssociationLimitException, aerr.Error())
973			case elbv2.ErrCodeIncompatibleProtocolsException:
974				fmt.Println(elbv2.ErrCodeIncompatibleProtocolsException, aerr.Error())
975			case elbv2.ErrCodeSSLPolicyNotFoundException:
976				fmt.Println(elbv2.ErrCodeSSLPolicyNotFoundException, aerr.Error())
977			case elbv2.ErrCodeCertificateNotFoundException:
978				fmt.Println(elbv2.ErrCodeCertificateNotFoundException, aerr.Error())
979			case elbv2.ErrCodeInvalidConfigurationRequestException:
980				fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error())
981			case elbv2.ErrCodeUnsupportedProtocolException:
982				fmt.Println(elbv2.ErrCodeUnsupportedProtocolException, aerr.Error())
983			case elbv2.ErrCodeTooManyRegistrationsForTargetIdException:
984				fmt.Println(elbv2.ErrCodeTooManyRegistrationsForTargetIdException, aerr.Error())
985			case elbv2.ErrCodeTooManyTargetsException:
986				fmt.Println(elbv2.ErrCodeTooManyTargetsException, aerr.Error())
987			case elbv2.ErrCodeTooManyActionsException:
988				fmt.Println(elbv2.ErrCodeTooManyActionsException, aerr.Error())
989			case elbv2.ErrCodeInvalidLoadBalancerActionException:
990				fmt.Println(elbv2.ErrCodeInvalidLoadBalancerActionException, aerr.Error())
991			case elbv2.ErrCodeTooManyUniqueTargetGroupsPerLoadBalancerException:
992				fmt.Println(elbv2.ErrCodeTooManyUniqueTargetGroupsPerLoadBalancerException, aerr.Error())
993			case elbv2.ErrCodeALPNPolicyNotSupportedException:
994				fmt.Println(elbv2.ErrCodeALPNPolicyNotSupportedException, aerr.Error())
995			default:
996				fmt.Println(aerr.Error())
997			}
998		} else {
999			// Print the error, cast err to awserr.Error to get the Code and
1000			// Message from an error.
1001			fmt.Println(err.Error())
1002		}
1003		return
1004	}
1005
1006	fmt.Println(result)
1007}
1008
1009// To change the server certificate
1010//
1011// This example changes the server certificate for the specified HTTPS listener.
1012func ExampleELBV2_ModifyListener_shared01() {
1013	svc := elbv2.New(session.New())
1014	input := &elbv2.ModifyListenerInput{
1015		Certificates: []*elbv2.Certificate{
1016			{
1017				CertificateArn: aws.String("arn:aws:iam::123456789012:server-certificate/my-new-server-cert"),
1018			},
1019		},
1020		ListenerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/0467ef3c8400ae65"),
1021	}
1022
1023	result, err := svc.ModifyListener(input)
1024	if err != nil {
1025		if aerr, ok := err.(awserr.Error); ok {
1026			switch aerr.Code() {
1027			case elbv2.ErrCodeDuplicateListenerException:
1028				fmt.Println(elbv2.ErrCodeDuplicateListenerException, aerr.Error())
1029			case elbv2.ErrCodeTooManyListenersException:
1030				fmt.Println(elbv2.ErrCodeTooManyListenersException, aerr.Error())
1031			case elbv2.ErrCodeTooManyCertificatesException:
1032				fmt.Println(elbv2.ErrCodeTooManyCertificatesException, aerr.Error())
1033			case elbv2.ErrCodeListenerNotFoundException:
1034				fmt.Println(elbv2.ErrCodeListenerNotFoundException, aerr.Error())
1035			case elbv2.ErrCodeTargetGroupNotFoundException:
1036				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
1037			case elbv2.ErrCodeTargetGroupAssociationLimitException:
1038				fmt.Println(elbv2.ErrCodeTargetGroupAssociationLimitException, aerr.Error())
1039			case elbv2.ErrCodeIncompatibleProtocolsException:
1040				fmt.Println(elbv2.ErrCodeIncompatibleProtocolsException, aerr.Error())
1041			case elbv2.ErrCodeSSLPolicyNotFoundException:
1042				fmt.Println(elbv2.ErrCodeSSLPolicyNotFoundException, aerr.Error())
1043			case elbv2.ErrCodeCertificateNotFoundException:
1044				fmt.Println(elbv2.ErrCodeCertificateNotFoundException, aerr.Error())
1045			case elbv2.ErrCodeInvalidConfigurationRequestException:
1046				fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error())
1047			case elbv2.ErrCodeUnsupportedProtocolException:
1048				fmt.Println(elbv2.ErrCodeUnsupportedProtocolException, aerr.Error())
1049			case elbv2.ErrCodeTooManyRegistrationsForTargetIdException:
1050				fmt.Println(elbv2.ErrCodeTooManyRegistrationsForTargetIdException, aerr.Error())
1051			case elbv2.ErrCodeTooManyTargetsException:
1052				fmt.Println(elbv2.ErrCodeTooManyTargetsException, aerr.Error())
1053			case elbv2.ErrCodeTooManyActionsException:
1054				fmt.Println(elbv2.ErrCodeTooManyActionsException, aerr.Error())
1055			case elbv2.ErrCodeInvalidLoadBalancerActionException:
1056				fmt.Println(elbv2.ErrCodeInvalidLoadBalancerActionException, aerr.Error())
1057			case elbv2.ErrCodeTooManyUniqueTargetGroupsPerLoadBalancerException:
1058				fmt.Println(elbv2.ErrCodeTooManyUniqueTargetGroupsPerLoadBalancerException, aerr.Error())
1059			case elbv2.ErrCodeALPNPolicyNotSupportedException:
1060				fmt.Println(elbv2.ErrCodeALPNPolicyNotSupportedException, aerr.Error())
1061			default:
1062				fmt.Println(aerr.Error())
1063			}
1064		} else {
1065			// Print the error, cast err to awserr.Error to get the Code and
1066			// Message from an error.
1067			fmt.Println(err.Error())
1068		}
1069		return
1070	}
1071
1072	fmt.Println(result)
1073}
1074
1075// To enable deletion protection
1076//
1077// This example enables deletion protection for the specified load balancer.
1078func ExampleELBV2_ModifyLoadBalancerAttributes_shared00() {
1079	svc := elbv2.New(session.New())
1080	input := &elbv2.ModifyLoadBalancerAttributesInput{
1081		Attributes: []*elbv2.LoadBalancerAttribute{
1082			{
1083				Key:   aws.String("deletion_protection.enabled"),
1084				Value: aws.String("true"),
1085			},
1086		},
1087		LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"),
1088	}
1089
1090	result, err := svc.ModifyLoadBalancerAttributes(input)
1091	if err != nil {
1092		if aerr, ok := err.(awserr.Error); ok {
1093			switch aerr.Code() {
1094			case elbv2.ErrCodeLoadBalancerNotFoundException:
1095				fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error())
1096			case elbv2.ErrCodeInvalidConfigurationRequestException:
1097				fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error())
1098			default:
1099				fmt.Println(aerr.Error())
1100			}
1101		} else {
1102			// Print the error, cast err to awserr.Error to get the Code and
1103			// Message from an error.
1104			fmt.Println(err.Error())
1105		}
1106		return
1107	}
1108
1109	fmt.Println(result)
1110}
1111
1112// To change the idle timeout
1113//
1114// This example changes the idle timeout value for the specified load balancer.
1115func ExampleELBV2_ModifyLoadBalancerAttributes_shared01() {
1116	svc := elbv2.New(session.New())
1117	input := &elbv2.ModifyLoadBalancerAttributesInput{
1118		Attributes: []*elbv2.LoadBalancerAttribute{
1119			{
1120				Key:   aws.String("idle_timeout.timeout_seconds"),
1121				Value: aws.String("30"),
1122			},
1123		},
1124		LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"),
1125	}
1126
1127	result, err := svc.ModifyLoadBalancerAttributes(input)
1128	if err != nil {
1129		if aerr, ok := err.(awserr.Error); ok {
1130			switch aerr.Code() {
1131			case elbv2.ErrCodeLoadBalancerNotFoundException:
1132				fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error())
1133			case elbv2.ErrCodeInvalidConfigurationRequestException:
1134				fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error())
1135			default:
1136				fmt.Println(aerr.Error())
1137			}
1138		} else {
1139			// Print the error, cast err to awserr.Error to get the Code and
1140			// Message from an error.
1141			fmt.Println(err.Error())
1142		}
1143		return
1144	}
1145
1146	fmt.Println(result)
1147}
1148
1149// To enable access logs
1150//
1151// This example enables access logs for the specified load balancer. Note that the S3
1152// bucket must exist in the same region as the load balancer and must have a policy
1153// attached that grants access to the Elastic Load Balancing service.
1154func ExampleELBV2_ModifyLoadBalancerAttributes_shared02() {
1155	svc := elbv2.New(session.New())
1156	input := &elbv2.ModifyLoadBalancerAttributesInput{
1157		Attributes: []*elbv2.LoadBalancerAttribute{
1158			{
1159				Key:   aws.String("access_logs.s3.enabled"),
1160				Value: aws.String("true"),
1161			},
1162			{
1163				Key:   aws.String("access_logs.s3.bucket"),
1164				Value: aws.String("my-loadbalancer-logs"),
1165			},
1166			{
1167				Key:   aws.String("access_logs.s3.prefix"),
1168				Value: aws.String("myapp"),
1169			},
1170		},
1171		LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"),
1172	}
1173
1174	result, err := svc.ModifyLoadBalancerAttributes(input)
1175	if err != nil {
1176		if aerr, ok := err.(awserr.Error); ok {
1177			switch aerr.Code() {
1178			case elbv2.ErrCodeLoadBalancerNotFoundException:
1179				fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error())
1180			case elbv2.ErrCodeInvalidConfigurationRequestException:
1181				fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error())
1182			default:
1183				fmt.Println(aerr.Error())
1184			}
1185		} else {
1186			// Print the error, cast err to awserr.Error to get the Code and
1187			// Message from an error.
1188			fmt.Println(err.Error())
1189		}
1190		return
1191	}
1192
1193	fmt.Println(result)
1194}
1195
1196// To modify a rule
1197//
1198// This example modifies the condition for the specified rule.
1199func ExampleELBV2_ModifyRule_shared00() {
1200	svc := elbv2.New(session.New())
1201	input := &elbv2.ModifyRuleInput{
1202		Conditions: []*elbv2.RuleCondition{
1203			{
1204				Field: aws.String("path-pattern"),
1205				Values: []*string{
1206					aws.String("/images/*"),
1207				},
1208			},
1209		},
1210		RuleArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/9683b2d02a6cabee"),
1211	}
1212
1213	result, err := svc.ModifyRule(input)
1214	if err != nil {
1215		if aerr, ok := err.(awserr.Error); ok {
1216			switch aerr.Code() {
1217			case elbv2.ErrCodeTargetGroupAssociationLimitException:
1218				fmt.Println(elbv2.ErrCodeTargetGroupAssociationLimitException, aerr.Error())
1219			case elbv2.ErrCodeIncompatibleProtocolsException:
1220				fmt.Println(elbv2.ErrCodeIncompatibleProtocolsException, aerr.Error())
1221			case elbv2.ErrCodeRuleNotFoundException:
1222				fmt.Println(elbv2.ErrCodeRuleNotFoundException, aerr.Error())
1223			case elbv2.ErrCodeOperationNotPermittedException:
1224				fmt.Println(elbv2.ErrCodeOperationNotPermittedException, aerr.Error())
1225			case elbv2.ErrCodeTooManyRegistrationsForTargetIdException:
1226				fmt.Println(elbv2.ErrCodeTooManyRegistrationsForTargetIdException, aerr.Error())
1227			case elbv2.ErrCodeTooManyTargetsException:
1228				fmt.Println(elbv2.ErrCodeTooManyTargetsException, aerr.Error())
1229			case elbv2.ErrCodeTargetGroupNotFoundException:
1230				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
1231			case elbv2.ErrCodeUnsupportedProtocolException:
1232				fmt.Println(elbv2.ErrCodeUnsupportedProtocolException, aerr.Error())
1233			case elbv2.ErrCodeTooManyActionsException:
1234				fmt.Println(elbv2.ErrCodeTooManyActionsException, aerr.Error())
1235			case elbv2.ErrCodeInvalidLoadBalancerActionException:
1236				fmt.Println(elbv2.ErrCodeInvalidLoadBalancerActionException, aerr.Error())
1237			case elbv2.ErrCodeTooManyUniqueTargetGroupsPerLoadBalancerException:
1238				fmt.Println(elbv2.ErrCodeTooManyUniqueTargetGroupsPerLoadBalancerException, aerr.Error())
1239			default:
1240				fmt.Println(aerr.Error())
1241			}
1242		} else {
1243			// Print the error, cast err to awserr.Error to get the Code and
1244			// Message from an error.
1245			fmt.Println(err.Error())
1246		}
1247		return
1248	}
1249
1250	fmt.Println(result)
1251}
1252
1253// To modify the health check configuration for a target group
1254//
1255// This example changes the configuration of the health checks used to evaluate the
1256// health of the targets for the specified target group.
1257func ExampleELBV2_ModifyTargetGroup_shared00() {
1258	svc := elbv2.New(session.New())
1259	input := &elbv2.ModifyTargetGroupInput{
1260		HealthCheckPort:     aws.String("443"),
1261		HealthCheckProtocol: aws.String("HTTPS"),
1262		TargetGroupArn:      aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-https-targets/2453ed029918f21f"),
1263	}
1264
1265	result, err := svc.ModifyTargetGroup(input)
1266	if err != nil {
1267		if aerr, ok := err.(awserr.Error); ok {
1268			switch aerr.Code() {
1269			case elbv2.ErrCodeTargetGroupNotFoundException:
1270				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
1271			case elbv2.ErrCodeInvalidConfigurationRequestException:
1272				fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error())
1273			default:
1274				fmt.Println(aerr.Error())
1275			}
1276		} else {
1277			// Print the error, cast err to awserr.Error to get the Code and
1278			// Message from an error.
1279			fmt.Println(err.Error())
1280		}
1281		return
1282	}
1283
1284	fmt.Println(result)
1285}
1286
1287// To modify the deregistration delay timeout
1288//
1289// This example sets the deregistration delay timeout to the specified value for the
1290// specified target group.
1291func ExampleELBV2_ModifyTargetGroupAttributes_shared00() {
1292	svc := elbv2.New(session.New())
1293	input := &elbv2.ModifyTargetGroupAttributesInput{
1294		Attributes: []*elbv2.TargetGroupAttribute{
1295			{
1296				Key:   aws.String("deregistration_delay.timeout_seconds"),
1297				Value: aws.String("600"),
1298			},
1299		},
1300		TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"),
1301	}
1302
1303	result, err := svc.ModifyTargetGroupAttributes(input)
1304	if err != nil {
1305		if aerr, ok := err.(awserr.Error); ok {
1306			switch aerr.Code() {
1307			case elbv2.ErrCodeTargetGroupNotFoundException:
1308				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
1309			case elbv2.ErrCodeInvalidConfigurationRequestException:
1310				fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error())
1311			default:
1312				fmt.Println(aerr.Error())
1313			}
1314		} else {
1315			// Print the error, cast err to awserr.Error to get the Code and
1316			// Message from an error.
1317			fmt.Println(err.Error())
1318		}
1319		return
1320	}
1321
1322	fmt.Println(result)
1323}
1324
1325// To register targets with a target group
1326//
1327// This example registers the specified instances with the specified target group.
1328func ExampleELBV2_RegisterTargets_shared00() {
1329	svc := elbv2.New(session.New())
1330	input := &elbv2.RegisterTargetsInput{
1331		TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"),
1332		Targets: []*elbv2.TargetDescription{
1333			{
1334				Id: aws.String("i-80c8dd94"),
1335			},
1336			{
1337				Id: aws.String("i-ceddcd4d"),
1338			},
1339		},
1340	}
1341
1342	result, err := svc.RegisterTargets(input)
1343	if err != nil {
1344		if aerr, ok := err.(awserr.Error); ok {
1345			switch aerr.Code() {
1346			case elbv2.ErrCodeTargetGroupNotFoundException:
1347				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
1348			case elbv2.ErrCodeTooManyTargetsException:
1349				fmt.Println(elbv2.ErrCodeTooManyTargetsException, aerr.Error())
1350			case elbv2.ErrCodeInvalidTargetException:
1351				fmt.Println(elbv2.ErrCodeInvalidTargetException, aerr.Error())
1352			case elbv2.ErrCodeTooManyRegistrationsForTargetIdException:
1353				fmt.Println(elbv2.ErrCodeTooManyRegistrationsForTargetIdException, aerr.Error())
1354			default:
1355				fmt.Println(aerr.Error())
1356			}
1357		} else {
1358			// Print the error, cast err to awserr.Error to get the Code and
1359			// Message from an error.
1360			fmt.Println(err.Error())
1361		}
1362		return
1363	}
1364
1365	fmt.Println(result)
1366}
1367
1368// To register targets with a target group using port overrides
1369//
1370// This example registers the specified instance with the specified target group using
1371// multiple ports. This enables you to register ECS containers on the same instance
1372// as targets in the target group.
1373func ExampleELBV2_RegisterTargets_shared01() {
1374	svc := elbv2.New(session.New())
1375	input := &elbv2.RegisterTargetsInput{
1376		TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-new-targets/3bb63f11dfb0faf9"),
1377		Targets: []*elbv2.TargetDescription{
1378			{
1379				Id:   aws.String("i-80c8dd94"),
1380				Port: aws.Int64(80),
1381			},
1382			{
1383				Id:   aws.String("i-80c8dd94"),
1384				Port: aws.Int64(766),
1385			},
1386		},
1387	}
1388
1389	result, err := svc.RegisterTargets(input)
1390	if err != nil {
1391		if aerr, ok := err.(awserr.Error); ok {
1392			switch aerr.Code() {
1393			case elbv2.ErrCodeTargetGroupNotFoundException:
1394				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
1395			case elbv2.ErrCodeTooManyTargetsException:
1396				fmt.Println(elbv2.ErrCodeTooManyTargetsException, aerr.Error())
1397			case elbv2.ErrCodeInvalidTargetException:
1398				fmt.Println(elbv2.ErrCodeInvalidTargetException, aerr.Error())
1399			case elbv2.ErrCodeTooManyRegistrationsForTargetIdException:
1400				fmt.Println(elbv2.ErrCodeTooManyRegistrationsForTargetIdException, aerr.Error())
1401			default:
1402				fmt.Println(aerr.Error())
1403			}
1404		} else {
1405			// Print the error, cast err to awserr.Error to get the Code and
1406			// Message from an error.
1407			fmt.Println(err.Error())
1408		}
1409		return
1410	}
1411
1412	fmt.Println(result)
1413}
1414
1415// To remove tags from a load balancer
1416//
1417// This example removes the specified tags from the specified load balancer.
1418func ExampleELBV2_RemoveTags_shared00() {
1419	svc := elbv2.New(session.New())
1420	input := &elbv2.RemoveTagsInput{
1421		ResourceArns: []*string{
1422			aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"),
1423		},
1424		TagKeys: []*string{
1425			aws.String("project"),
1426			aws.String("department"),
1427		},
1428	}
1429
1430	result, err := svc.RemoveTags(input)
1431	if err != nil {
1432		if aerr, ok := err.(awserr.Error); ok {
1433			switch aerr.Code() {
1434			case elbv2.ErrCodeLoadBalancerNotFoundException:
1435				fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error())
1436			case elbv2.ErrCodeTargetGroupNotFoundException:
1437				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
1438			case elbv2.ErrCodeListenerNotFoundException:
1439				fmt.Println(elbv2.ErrCodeListenerNotFoundException, aerr.Error())
1440			case elbv2.ErrCodeRuleNotFoundException:
1441				fmt.Println(elbv2.ErrCodeRuleNotFoundException, aerr.Error())
1442			case elbv2.ErrCodeTooManyTagsException:
1443				fmt.Println(elbv2.ErrCodeTooManyTagsException, aerr.Error())
1444			default:
1445				fmt.Println(aerr.Error())
1446			}
1447		} else {
1448			// Print the error, cast err to awserr.Error to get the Code and
1449			// Message from an error.
1450			fmt.Println(err.Error())
1451		}
1452		return
1453	}
1454
1455	fmt.Println(result)
1456}
1457
1458// To set the rule priority
1459//
1460// This example sets the priority of the specified rule.
1461func ExampleELBV2_SetRulePriorities_shared00() {
1462	svc := elbv2.New(session.New())
1463	input := &elbv2.SetRulePrioritiesInput{
1464		RulePriorities: []*elbv2.RulePriorityPair{
1465			{
1466				Priority: aws.Int64(5),
1467				RuleArn:  aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/1291d13826f405c3"),
1468			},
1469		},
1470	}
1471
1472	result, err := svc.SetRulePriorities(input)
1473	if err != nil {
1474		if aerr, ok := err.(awserr.Error); ok {
1475			switch aerr.Code() {
1476			case elbv2.ErrCodeRuleNotFoundException:
1477				fmt.Println(elbv2.ErrCodeRuleNotFoundException, aerr.Error())
1478			case elbv2.ErrCodePriorityInUseException:
1479				fmt.Println(elbv2.ErrCodePriorityInUseException, aerr.Error())
1480			case elbv2.ErrCodeOperationNotPermittedException:
1481				fmt.Println(elbv2.ErrCodeOperationNotPermittedException, aerr.Error())
1482			default:
1483				fmt.Println(aerr.Error())
1484			}
1485		} else {
1486			// Print the error, cast err to awserr.Error to get the Code and
1487			// Message from an error.
1488			fmt.Println(err.Error())
1489		}
1490		return
1491	}
1492
1493	fmt.Println(result)
1494}
1495
1496// To associate a security group with a load balancer
1497//
1498// This example associates the specified security group with the specified load balancer.
1499func ExampleELBV2_SetSecurityGroups_shared00() {
1500	svc := elbv2.New(session.New())
1501	input := &elbv2.SetSecurityGroupsInput{
1502		LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"),
1503		SecurityGroups: []*string{
1504			aws.String("sg-5943793c"),
1505		},
1506	}
1507
1508	result, err := svc.SetSecurityGroups(input)
1509	if err != nil {
1510		if aerr, ok := err.(awserr.Error); ok {
1511			switch aerr.Code() {
1512			case elbv2.ErrCodeLoadBalancerNotFoundException:
1513				fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error())
1514			case elbv2.ErrCodeInvalidConfigurationRequestException:
1515				fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error())
1516			case elbv2.ErrCodeInvalidSecurityGroupException:
1517				fmt.Println(elbv2.ErrCodeInvalidSecurityGroupException, aerr.Error())
1518			default:
1519				fmt.Println(aerr.Error())
1520			}
1521		} else {
1522			// Print the error, cast err to awserr.Error to get the Code and
1523			// Message from an error.
1524			fmt.Println(err.Error())
1525		}
1526		return
1527	}
1528
1529	fmt.Println(result)
1530}
1531
1532// To enable Availability Zones for a load balancer
1533//
1534// This example enables the Availability Zones for the specified subnets for the specified
1535// load balancer.
1536func ExampleELBV2_SetSubnets_shared00() {
1537	svc := elbv2.New(session.New())
1538	input := &elbv2.SetSubnetsInput{
1539		LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"),
1540		Subnets: []*string{
1541			aws.String("subnet-8360a9e7"),
1542			aws.String("subnet-b7d581c0"),
1543		},
1544	}
1545
1546	result, err := svc.SetSubnets(input)
1547	if err != nil {
1548		if aerr, ok := err.(awserr.Error); ok {
1549			switch aerr.Code() {
1550			case elbv2.ErrCodeLoadBalancerNotFoundException:
1551				fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error())
1552			case elbv2.ErrCodeInvalidConfigurationRequestException:
1553				fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error())
1554			case elbv2.ErrCodeSubnetNotFoundException:
1555				fmt.Println(elbv2.ErrCodeSubnetNotFoundException, aerr.Error())
1556			case elbv2.ErrCodeInvalidSubnetException:
1557				fmt.Println(elbv2.ErrCodeInvalidSubnetException, aerr.Error())
1558			case elbv2.ErrCodeAllocationIdNotFoundException:
1559				fmt.Println(elbv2.ErrCodeAllocationIdNotFoundException, aerr.Error())
1560			case elbv2.ErrCodeAvailabilityZoneNotSupportedException:
1561				fmt.Println(elbv2.ErrCodeAvailabilityZoneNotSupportedException, aerr.Error())
1562			default:
1563				fmt.Println(aerr.Error())
1564			}
1565		} else {
1566			// Print the error, cast err to awserr.Error to get the Code and
1567			// Message from an error.
1568			fmt.Println(err.Error())
1569		}
1570		return
1571	}
1572
1573	fmt.Println(result)
1574}
1575