本文整理匯總了Golang中github.com/aws/aws-sdk-go/service/elb.New函數的典型用法代碼示例。如果您正苦於以下問題:Golang New函數的具體用法?Golang New怎麽用?Golang New使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了New函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ExampleELB_CreateLBCookieStickinessPolicy
func ExampleELB_CreateLBCookieStickinessPolicy() {
svc := elb.New(nil)
params := &elb.CreateLBCookieStickinessPolicyInput{
LoadBalancerName: aws.String("AccessPointName"), // Required
PolicyName: aws.String("PolicyName"), // Required
CookieExpirationPeriod: aws.Long(1),
}
resp, err := svc.CreateLBCookieStickinessPolicy(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS Error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, The SDK should alwsy return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例2: ExampleELB_RegisterInstancesWithLoadBalancer
func ExampleELB_RegisterInstancesWithLoadBalancer() {
svc := elb.New(nil)
params := &elb.RegisterInstancesWithLoadBalancerInput{
Instances: []*elb.Instance{ // Required
&elb.Instance{ // Required
InstanceID: aws.String("InstanceId"),
},
// More values...
},
LoadBalancerName: aws.String("AccessPointName"), // Required
}
resp, err := svc.RegisterInstancesWithLoadBalancer(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS Error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, The SDK should alwsy return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例3: elbDNSName
func elbDNSName(c *conf) string {
//weirdness around how aws handles credentials
os.Setenv("AWS_ACCESS_KEY_ID", c.awsAccessKey)
os.Setenv("AWS_SECRET_ACCESS_KEY", c.awsSecretKey)
svc := elb.New(
session.New(
&aws.Config{
Region: aws.String(c.awsRegion),
Credentials: credentials.NewEnvCredentials(),
},
),
)
params := &elb.DescribeLoadBalancersInput{
LoadBalancerNames: []*string{
aws.String(c.elbName), // Required
},
}
resp, err := svc.DescribeLoadBalancers(params)
if err != nil {
log.Fatal(err)
}
return *resp.LoadBalancerDescriptions[0].DNSName
}
示例4: ExampleELB_ConfigureHealthCheck
func ExampleELB_ConfigureHealthCheck() {
svc := elb.New(nil)
params := &elb.ConfigureHealthCheckInput{
HealthCheck: &elb.HealthCheck{ // Required
HealthyThreshold: aws.Long(1), // Required
Interval: aws.Long(1), // Required
Target: aws.String("HealthCheckTarget"), // Required
Timeout: aws.Long(1), // Required
UnhealthyThreshold: aws.Long(1), // Required
},
LoadBalancerName: aws.String("AccessPointName"), // Required
}
resp, err := svc.ConfigureHealthCheck(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS Error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例5: ExampleELB_CreateLoadBalancerListeners
func ExampleELB_CreateLoadBalancerListeners() {
svc := elb.New(nil)
params := &elb.CreateLoadBalancerListenersInput{
Listeners: []*elb.Listener{ // Required
{ // Required
InstancePort: aws.Int64(1), // Required
LoadBalancerPort: aws.Int64(1), // Required
Protocol: aws.String("Protocol"), // Required
InstanceProtocol: aws.String("Protocol"),
SSLCertificateId: aws.String("SSLCertificateId"),
},
// More values...
},
LoadBalancerName: aws.String("AccessPointName"), // Required
}
resp, err := svc.CreateLoadBalancerListeners(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例6: ExampleELB_SetLoadBalancerPoliciesOfListener
func ExampleELB_SetLoadBalancerPoliciesOfListener() {
svc := elb.New(nil)
params := &elb.SetLoadBalancerPoliciesOfListenerInput{
LoadBalancerName: aws.String("AccessPointName"), // Required
LoadBalancerPort: aws.Long(1), // Required
PolicyNames: []*string{ // Required
aws.String("PolicyName"), // Required
// More values...
},
}
resp, err := svc.SetLoadBalancerPoliciesOfListener(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS Error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例7: ExampleELB_ConfigureHealthCheck
func ExampleELB_ConfigureHealthCheck() {
svc := elb.New(nil)
params := &elb.ConfigureHealthCheckInput{
HealthCheck: &elb.HealthCheck{ // Required
HealthyThreshold: aws.Int64(1), // Required
Interval: aws.Int64(1), // Required
Target: aws.String("HealthCheckTarget"), // Required
Timeout: aws.Int64(1), // Required
UnhealthyThreshold: aws.Int64(1), // Required
},
LoadBalancerName: aws.String("AccessPointName"), // Required
}
resp, err := svc.ConfigureHealthCheck(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例8: ExampleELB_DeleteLoadBalancerPolicy
func ExampleELB_DeleteLoadBalancerPolicy() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := elb.New(sess)
params := &elb.DeleteLoadBalancerPolicyInput{
LoadBalancerName: aws.String("AccessPointName"), // Required
PolicyName: aws.String("PolicyName"), // Required
}
resp, err := svc.DeleteLoadBalancerPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例9: ExampleELB_DescribeLoadBalancers
func ExampleELB_DescribeLoadBalancers() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := elb.New(sess)
params := &elb.DescribeLoadBalancersInput{
LoadBalancerNames: []*string{
aws.String("AccessPointName"), // Required
// More values...
},
Marker: aws.String("Marker"),
PageSize: aws.Int64(1),
}
resp, err := svc.DescribeLoadBalancers(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例10: ExampleELB_RegisterInstancesWithLoadBalancer
func ExampleELB_RegisterInstancesWithLoadBalancer() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := elb.New(sess)
params := &elb.RegisterInstancesWithLoadBalancerInput{
Instances: []*elb.Instance{ // Required
{ // Required
InstanceId: aws.String("InstanceId"),
},
// More values...
},
LoadBalancerName: aws.String("AccessPointName"), // Required
}
resp, err := svc.RegisterInstancesWithLoadBalancer(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例11: ExampleELB_SetLoadBalancerListenerSSLCertificate
func ExampleELB_SetLoadBalancerListenerSSLCertificate() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := elb.New(sess)
params := &elb.SetLoadBalancerListenerSSLCertificateInput{
LoadBalancerName: aws.String("AccessPointName"), // Required
LoadBalancerPort: aws.Int64(1), // Required
SSLCertificateId: aws.String("SSLCertificateId"), // Required
}
resp, err := svc.SetLoadBalancerListenerSSLCertificate(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例12: ExampleELB_SetLoadBalancerPoliciesOfListener
func ExampleELB_SetLoadBalancerPoliciesOfListener() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := elb.New(sess)
params := &elb.SetLoadBalancerPoliciesOfListenerInput{
LoadBalancerName: aws.String("AccessPointName"), // Required
LoadBalancerPort: aws.Int64(1), // Required
PolicyNames: []*string{ // Required
aws.String("PolicyName"), // Required
// More values...
},
}
resp, err := svc.SetLoadBalancerPoliciesOfListener(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例13: ExampleELB_SetLoadBalancerListenerSSLCertificate
func ExampleELB_SetLoadBalancerListenerSSLCertificate() {
svc := elb.New(nil)
params := &elb.SetLoadBalancerListenerSSLCertificateInput{
LoadBalancerName: aws.String("AccessPointName"), // Required
LoadBalancerPort: aws.Int64(1), // Required
SSLCertificateId: aws.String("SSLCertificateId"), // Required
}
resp, err := svc.SetLoadBalancerListenerSSLCertificate(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
示例14: ExampleELB_CreateLoadBalancerPolicy
func ExampleELB_CreateLoadBalancerPolicy() {
svc := elb.New(nil)
params := &elb.CreateLoadBalancerPolicyInput{
LoadBalancerName: aws.String("AccessPointName"), // Required
PolicyName: aws.String("PolicyName"), // Required
PolicyTypeName: aws.String("PolicyTypeName"), // Required
PolicyAttributes: []*elb.PolicyAttribute{
{ // Required
AttributeName: aws.String("AttributeName"),
AttributeValue: aws.String("AttributeValue"),
},
// More values...
},
}
resp, err := svc.CreateLoadBalancerPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例15: ExampleELB_RemoveTags
func ExampleELB_RemoveTags() {
svc := elb.New(nil)
params := &elb.RemoveTagsInput{
LoadBalancerNames: []*string{ // Required
aws.String("AccessPointName"), // Required
// More values...
},
Tags: []*elb.TagKeyOnly{ // Required
{ // Required
Key: aws.String("TagKey"),
},
// More values...
},
}
resp, err := svc.RemoveTags(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}