func ExampleELBV2_CreateRule_shared00() {
	svc := elbv2.New(session.New())
	input := &elbv2.CreateRuleInput{
		Actions: []*elbv2.Action{
			{
				TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"),
				Type:           aws.String("forward"),
			},
		},
		Conditions: []*elbv2.RuleCondition{
			{
				Field: aws.String("path-pattern"),
				Values: []*string{
					aws.String("/img/*"),
				},
			},
		},
		ListenerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2"),
		Priority:    aws.Int64(10),
	}

	result, err := svc.CreateRule(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			case elbv2.ErrCodePriorityInUseException:
				fmt.Println(elbv2.ErrCodePriorityInUseException, aerr.Error())
			case elbv2.ErrCodeTooManyTargetGroupsException:
				fmt.Println(elbv2.ErrCodeTooManyTargetGroupsException, aerr.Error())
			case elbv2.ErrCodeTooManyRulesException:
				fmt.Println(elbv2.ErrCodeTooManyRulesException, aerr.Error())
			case elbv2.ErrCodeTargetGroupAssociationLimitException:
				fmt.Println(elbv2.ErrCodeTargetGroupAssociationLimitException, aerr.Error())
			case elbv2.ErrCodeIncompatibleProtocolsException:
				fmt.Println(elbv2.ErrCodeIncompatibleProtocolsException, aerr.Error())
			case elbv2.ErrCodeListenerNotFoundException:
				fmt.Println(elbv2.ErrCodeListenerNotFoundException, aerr.Error())
			case elbv2.ErrCodeTargetGroupNotFoundException:
				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
			case elbv2.ErrCodeInvalidConfigurationRequestException:
				fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error())
			case elbv2.ErrCodeTooManyRegistrationsForTargetIdException:
				fmt.Println(elbv2.ErrCodeTooManyRegistrationsForTargetIdException, aerr.Error())
			case elbv2.ErrCodeTooManyTargetsException:
				fmt.Println(elbv2.ErrCodeTooManyTargetsException, aerr.Error())
			case elbv2.ErrCodeUnsupportedProtocolException:
				fmt.Println(elbv2.ErrCodeUnsupportedProtocolException, 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.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 a rule
//
// This example creates a rule that forwards requests to the specified target group
// if the URL contains the specified pattern (for example, /img/*).
To create a rule

This example creates a rule that forwards requests to the specified target group
if the URL contains the specified pattern (for example, /img).
// To create a rule // // This example creates a rule that forwards requests to the specified target group // if the URL contains the specified pattern ( for example / img / * ) .
func ExampleELBV2_CreateRule_shared00() {
	svc := elbv2.New(session.New())
	input := &elbv2.CreateRuleInput{
		Actions: []*elbv2.Action{
			{
				TargetGroupArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"),
				Type:           aws.String("forward"),
			},
		},
		Conditions: []*elbv2.RuleCondition{
			{
				Field: aws.String("path-pattern"),
				Values: []*string{
					aws.String("/img/*"),
				},
			},
		},
		ListenerArn: aws.String("arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2"),
		Priority:    aws.Int64(10),
	}
	result, err := svc.CreateRule(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			case elbv2.ErrCodePriorityInUseException:
				fmt.Println(elbv2.ErrCodePriorityInUseException, aerr.Error())
			case elbv2.ErrCodeTooManyTargetGroupsException:
				fmt.Println(elbv2.ErrCodeTooManyTargetGroupsException, aerr.Error())
			case elbv2.ErrCodeTooManyRulesException:
				fmt.Println(elbv2.ErrCodeTooManyRulesException, aerr.Error())
			case elbv2.ErrCodeTargetGroupAssociationLimitException:
				fmt.Println(elbv2.ErrCodeTargetGroupAssociationLimitException, aerr.Error())
			case elbv2.ErrCodeIncompatibleProtocolsException:
				fmt.Println(elbv2.ErrCodeIncompatibleProtocolsException, aerr.Error())
			case elbv2.ErrCodeListenerNotFoundException:
				fmt.Println(elbv2.ErrCodeListenerNotFoundException, aerr.Error())
			case elbv2.ErrCodeTargetGroupNotFoundException:
				fmt.Println(elbv2.ErrCodeTargetGroupNotFoundException, aerr.Error())
			case elbv2.ErrCodeInvalidConfigurationRequestException:
				fmt.Println(elbv2.ErrCodeInvalidConfigurationRequestException, aerr.Error())
			case elbv2.ErrCodeTooManyRegistrationsForTargetIdException:
				fmt.Println(elbv2.ErrCodeTooManyRegistrationsForTargetIdException, aerr.Error())
			case elbv2.ErrCodeTooManyTargetsException:
				fmt.Println(elbv2.ErrCodeTooManyTargetsException, aerr.Error())
			case elbv2.ErrCodeUnsupportedProtocolException:
				fmt.Println(elbv2.ErrCodeUnsupportedProtocolException, 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.ErrCodeTooManyTagsException:
				fmt.Println(elbv2.ErrCodeTooManyTagsException, aerr.Error())
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			fmt.Println(err.Error())
		}
		return
	}
	fmt.Println(result)
}
func ExampleELBV2_CreateRule_shared00 ( ) { svc := elbv2 . New ( session . New ( ) ) input := & elbv2 . CreateRuleInput { Actions : [ ] * elbv2 . Action { { TargetGroupArn : aws . String ( " " ) , Type : aws . String ( " " ) , } , } , Conditions : [ ] * elbv2 . RuleCondition { { Field : aws . String ( " " ) , Values : [ ] * string { aws . String ( " " ) , } , } , } , ListenerArn : aws . String ( " " ) , Priority : aws . Int64 ( 10 ) , } result , err := svc . CreateRule ( input ) if err != nil { if aerr , ok := err . ( awserr . Error ) ; ok { switch aerr . Code ( ) { case elbv2 . ErrCodePriorityInUseException : fmt . Println ( elbv2 . ErrCodePriorityInUseException , aerr . Error ( ) ) case elbv2 . ErrCodeTooManyTargetGroupsException : fmt . Println ( elbv2 . ErrCodeTooManyTargetGroupsException , aerr . Error ( ) ) case elbv2 . ErrCodeTooManyRulesException : fmt . Println ( elbv2 . ErrCodeTooManyRulesException , aerr . Error ( ) ) case elbv2 . ErrCodeTargetGroupAssociationLimitException : fmt . Println ( elbv2 . ErrCodeTargetGroupAssociationLimitException , aerr . Error ( ) ) case elbv2 . ErrCodeIncompatibleProtocolsException : fmt . Println ( elbv2 . ErrCodeIncompatibleProtocolsException , aerr . Error ( ) ) case elbv2 . ErrCodeListenerNotFoundException : fmt . Println ( elbv2 . ErrCodeListenerNotFoundException , aerr . Error ( ) ) case elbv2 . ErrCodeTargetGroupNotFoundException : fmt . Println ( elbv2 . ErrCodeTargetGroupNotFoundException , aerr . Error ( ) ) case elbv2 . ErrCodeInvalidConfigurationRequestException : fmt . Println ( elbv2 . ErrCodeInvalidConfigurationRequestException , aerr . Error ( ) ) case elbv2 . ErrCodeTooManyRegistrationsForTargetIdException : fmt . Println ( elbv2 . ErrCodeTooManyRegistrationsForTargetIdException , aerr . Error ( ) ) case elbv2 . ErrCodeTooManyTargetsException : fmt . Println ( elbv2 . ErrCodeTooManyTargetsException , aerr . Error ( ) ) case elbv2 . ErrCodeUnsupportedProtocolException : fmt . Println ( elbv2 . ErrCodeUnsupportedProtocolException , 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 . ErrCodeTooManyTagsException : fmt . Println ( elbv2 . ErrCodeTooManyTagsException , aerr . Error ( ) ) default : fmt . Println ( aerr . Error ( ) ) } } else { fmt . Println ( err . Error ( ) ) } return } fmt . Println ( result ) }
To create a rule
To create a rule
// Print the error, cast err to awserr.Error to get the Code and // Message from an error.