func ExampleELBV2_CreateListener_shared01() {
	svc := elbv2.New(session.New())
	input := &elbv2.CreateListenerInput{
		Certificates: []*elbv2.Certificate{
			{
				CertificateArn: aws.String("arn:aws:iam::123456789012:server-certificate/my-server-cert"),
			},
		},
		DefaultActions: []*elbv2.Action{
			{
				TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"),
				Type:           aws.String("forward"),
			},
		},
		LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"),
		Port:            aws.Int64(443),
		Protocol:        aws.String("HTTPS"),
		SslPolicy:       aws.String("ELBSecurityPolicy-2015-05"),
	}

	result, err := svc.CreateListener(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			case elbv2.ErrCodeDuplicateListenerException:
				fmt.Println(elbv2.ErrCodeDuplicateListenerException, aerr.Error())
			case elbv2.ErrCodeTooManyListenersException:
				fmt.Println(elbv2.ErrCodeTooManyListenersException, aerr.Error())
			case elbv2.ErrCodeTooManyCertificatesException:
				fmt.Println(elbv2.ErrCodeTooManyCertificatesException, aerr.Error())
			case elbv2.ErrCodeLoadBalancerNotFoundException:
				fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error())
			case elbv2.ErrCodeTargetGroupNotFoundException:
				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
			case elbv2.ErrCodeTargetGroupAssociationLimitException:
				fmt.Println(elbv2.ErrCodeTargetGroupAssociationLimitException, aerr.Error())
			case elbv2.ErrCodeInvalidConfigurationRequestException:
				fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error())
			case elbv2.ErrCodeIncompatibleProtocolsException:
				fmt.Println(elbv2.ErrCodeIncompatibleProtocolsException, aerr.Error())
			case elbv2.ErrCodeSSLPolicyNotFoundException:
				fmt.Println(elbv2.ErrCodeSSLPolicyNotFoundException, aerr.Error())
			case elbv2.ErrCodeCertificateNotFoundException:
				fmt.Println(elbv2.ErrCodeCertificateNotFoundException, aerr.Error())
			case elbv2.ErrCodeUnsupportedProtocolException:
				fmt.Println(elbv2.ErrCodeUnsupportedProtocolException, aerr.Error())
			case elbv2.ErrCodeTooManyRegistrationsForTargetIdException:
				fmt.Println(elbv2.ErrCodeTooManyRegistrationsForTargetIdException, aerr.Error())
			case elbv2.ErrCodeTooManyTargetsException:
				fmt.Println(elbv2.ErrCodeTooManyTargetsException, aerr.Error())
			case elbv2.ErrCodeTooManyActionsException:
				fmt.Println(elbv2.ErrCodeTooManyActionsException, aerr.Error())
			case elbv2.ErrCodeInvalidLoadBalancerActionException:
				fmt.Println(elbv2.ErrCodeInvalidLoadBalancerActionException, aerr.Error())
			case elbv2.ErrCodeTooManyUniqueTargetGroupsPerLoadBalancerException:
				fmt.Println(elbv2.ErrCodeTooManyUniqueTargetGroupsPerLoadBalancerException, aerr.Error())
			case elbv2.ErrCodeALPNPolicyNotSupportedException:
				fmt.Println(elbv2.ErrCodeALPNPolicyNotSupportedException, aerr.Error())
			case elbv2.ErrCodeTooManyTagsException:
				fmt.Println(elbv2.ErrCodeTooManyTagsException, aerr.Error())
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			// Print the error, cast err to awserr.Error to get the Code and
			// Message from an error.
			fmt.Println(err.Error())
		}
		return
	}

	fmt.Println(result)
}
// To create an HTTPS listener
//
// This example creates an HTTPS listener for the specified load balancer that forwards
// requests to the specified target group. Note that you must specify an SSL certificate
// for an HTTPS listener. You can create and manage certificates using AWS Certificate
// Manager (ACM). Alternatively, you can create a certificate using SSL/TLS tools, get
// the certificate signed by a certificate authority (CA), and upload the certificate
// to AWS Identity and Access Management (IAM).
To create an HTTPS listener

This example creates an HTTPS listener for the specified load balancer that forwards
requests to the specified target group. Note that you must specify an SSL certificate
for an HTTPS listener. You can create and manage certificates using AWS Certificate
Manager (ACM). Alternatively, you can create a certificate using SSL/TLS tools, get
the certificate signed by a certificate authority (CA), and upload the certificate
to AWS Identity and Access Management (IAM).
// To create an HTTPS listener // // This example creates an HTTPS listener for the specified load balancer that forwards // requests to the specified target group . Note that you must specify an SSL certificate // for an HTTPS listener . You can create and manage certificates using AWS Certificate // Manager ( ACM ) . Alternatively you can create a certificate using SSL / TLS tools get // the certificate signed by a certificate authority ( CA ) and upload the certificate // to AWS Identity and Access Management ( IAM ) .
func ExampleELBV2_CreateListener_shared01() {
	svc := elbv2.New(session.New())
	input := &elbv2.CreateListenerInput{
		Certificates: []*elbv2.Certificate{
			{
				CertificateArn: aws.String("arn:aws:iam::123456789012:server-certificate/my-server-cert"),
			},
		},
		DefaultActions: []*elbv2.Action{
			{
				TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"),
				Type:           aws.String("forward"),
			},
		},
		LoadBalancerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"),
		Port:            aws.Int64(443),
		Protocol:        aws.String("HTTPS"),
		SslPolicy:       aws.String("ELBSecurityPolicy-2015-05"),
	}
	result, err := svc.CreateListener(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			case elbv2.ErrCodeDuplicateListenerException:
				fmt.Println(elbv2.ErrCodeDuplicateListenerException, aerr.Error())
			case elbv2.ErrCodeTooManyListenersException:
				fmt.Println(elbv2.ErrCodeTooManyListenersException, aerr.Error())
			case elbv2.ErrCodeTooManyCertificatesException:
				fmt.Println(elbv2.ErrCodeTooManyCertificatesException, aerr.Error())
			case elbv2.ErrCodeLoadBalancerNotFoundException:
				fmt.Println(elbv2.ErrCodeLoadBalancerNotFoundException, aerr.Error())
			case elbv2.ErrCodeTargetGroupNotFoundException:
				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
			case elbv2.ErrCodeTargetGroupAssociationLimitException:
				fmt.Println(elbv2.ErrCodeTargetGroupAssociationLimitException, aerr.Error())
			case elbv2.ErrCodeInvalidConfigurationRequestException:
				fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error())
			case elbv2.ErrCodeIncompatibleProtocolsException:
				fmt.Println(elbv2.ErrCodeIncompatibleProtocolsException, aerr.Error())
			case elbv2.ErrCodeSSLPolicyNotFoundException:
				fmt.Println(elbv2.ErrCodeSSLPolicyNotFoundException, aerr.Error())
			case elbv2.ErrCodeCertificateNotFoundException:
				fmt.Println(elbv2.ErrCodeCertificateNotFoundException, aerr.Error())
			case elbv2.ErrCodeUnsupportedProtocolException:
				fmt.Println(elbv2.ErrCodeUnsupportedProtocolException, aerr.Error())
			case elbv2.ErrCodeTooManyRegistrationsForTargetIdException:
				fmt.Println(elbv2.ErrCodeTooManyRegistrationsForTargetIdException, aerr.Error())
			case elbv2.ErrCodeTooManyTargetsException:
				fmt.Println(elbv2.ErrCodeTooManyTargetsException, aerr.Error())
			case elbv2.ErrCodeTooManyActionsException:
				fmt.Println(elbv2.ErrCodeTooManyActionsException, aerr.Error())
			case elbv2.ErrCodeInvalidLoadBalancerActionException:
				fmt.Println(elbv2.ErrCodeInvalidLoadBalancerActionException, aerr.Error())
			case elbv2.ErrCodeTooManyUniqueTargetGroupsPerLoadBalancerException:
				fmt.Println(elbv2.ErrCodeTooManyUniqueTargetGroupsPerLoadBalancerException, aerr.Error())
			case elbv2.ErrCodeALPNPolicyNotSupportedException:
				fmt.Println(elbv2.ErrCodeALPNPolicyNotSupportedException, aerr.Error())
			case elbv2.ErrCodeTooManyTagsException:
				fmt.Println(elbv2.ErrCodeTooManyTagsException, aerr.Error())
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			fmt.Println(err.Error())
		}
		return
	}
	fmt.Println(result)
}
func ExampleELBV2_CreateListener_shared01 ( ) { svc := elbv2 . New ( session . New ( ) ) input := & elbv2 . CreateListenerInput { Certificates : [ ] * elbv2 . Certificate { { CertificateArn : aws . String ( " " ) , } , } , DefaultActions : [ ] * elbv2 . Action { { TargetGroupArn : aws . String ( " " ) , Type : aws . String ( " " ) , } , } , LoadBalancerArn : aws . String ( " " ) , Port : aws . Int64 ( 443 ) , Protocol : aws . String ( " " ) , SslPolicy : aws . String ( " " ) , } result , err := svc . CreateListener ( input ) if err != nil { if aerr , ok := err . ( awserr . Error ) ; ok { switch aerr . Code ( ) { case elbv2 . ErrCodeDuplicateListenerException : fmt . Println ( elbv2 . ErrCodeDuplicateListenerException , aerr . Error ( ) ) case elbv2 . ErrCodeTooManyListenersException : fmt . Println ( elbv2 . ErrCodeTooManyListenersException , aerr . Error ( ) ) case elbv2 . ErrCodeTooManyCertificatesException : fmt . Println ( elbv2 . ErrCodeTooManyCertificatesException , aerr . Error ( ) ) case elbv2 . ErrCodeLoadBalancerNotFoundException : fmt . Println ( elbv2 . ErrCodeLoadBalancerNotFoundException , aerr . Error ( ) ) case elbv2 . ErrCodeTargetGroupNotFoundException : fmt . Println ( elbv2 . ErrCodeTargetGroupNotFoundException , aerr . Error ( ) ) case elbv2 . ErrCodeTargetGroupAssociationLimitException : fmt . Println ( elbv2 . ErrCodeTargetGroupAssociationLimitException , aerr . Error ( ) ) case elbv2 . ErrCodeInvalidConfigurationRequestException : fmt . Println ( elbv2 . ErrCodeInvalidConfigurationRequestException , aerr . Error ( ) ) case elbv2 . ErrCodeIncompatibleProtocolsException : fmt . Println ( elbv2 . ErrCodeIncompatibleProtocolsException , aerr . Error ( ) ) case elbv2 . ErrCodeSSLPolicyNotFoundException : fmt . Println ( elbv2 . ErrCodeSSLPolicyNotFoundException , aerr . Error ( ) ) case elbv2 . ErrCodeCertificateNotFoundException : fmt . Println ( elbv2 . ErrCodeCertificateNotFoundException , aerr . Error ( ) ) case elbv2 . ErrCodeUnsupportedProtocolException : fmt . Println ( elbv2 . ErrCodeUnsupportedProtocolException , aerr . Error ( ) ) case elbv2 . ErrCodeTooManyRegistrationsForTargetIdException : fmt . Println ( elbv2 . ErrCodeTooManyRegistrationsForTargetIdException , aerr . Error ( ) ) case elbv2 . ErrCodeTooManyTargetsException : fmt . Println ( elbv2 . ErrCodeTooManyTargetsException , aerr . Error ( ) ) case elbv2 . ErrCodeTooManyActionsException : fmt . Println ( elbv2 . ErrCodeTooManyActionsException , aerr . Error ( ) ) case elbv2 . ErrCodeInvalidLoadBalancerActionException : fmt . Println ( elbv2 . ErrCodeInvalidLoadBalancerActionException , aerr . Error ( ) ) case elbv2 . ErrCodeTooManyUniqueTargetGroupsPerLoadBalancerException : fmt . Println ( elbv2 . ErrCodeTooManyUniqueTargetGroupsPerLoadBalancerException , aerr . Error ( ) ) case elbv2 . ErrCodeALPNPolicyNotSupportedException : fmt . Println ( elbv2 . ErrCodeALPNPolicyNotSupportedException , aerr . Error ( ) ) case elbv2 . ErrCodeTooManyTagsException : fmt . Println ( elbv2 . ErrCodeTooManyTagsException , aerr . Error ( ) ) default : fmt . Println ( aerr . Error ( ) ) } } else { fmt . Println ( err . Error ( ) ) } return } fmt . Println ( result ) }
To create an HTTPS listener
To create an HTTPS listener
// Print the error, cast err to awserr.Error to get the Code and // Message from an error.