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