github.com/aavshr/aws-sdk-go@v1.41.3/service/elbv2/examples_test.go (about)

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