api_op_CreateHealthCheck.go (6654B)
1 // Code generated by smithy-go-codegen DO NOT EDIT. 2 3 package route53 4 5 import ( 6 "context" 7 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 8 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 9 "github.com/aws/aws-sdk-go-v2/service/route53/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12 ) 13 14 // Creates a new health check. For information about adding health checks to 15 // resource record sets, see HealthCheckId 16 // (https://docs.aws.amazon.com/Route53/latest/APIReference/API_ResourceRecordSet.html#Route53-Type-ResourceRecordSet-HealthCheckId) 17 // in ChangeResourceRecordSets 18 // (https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html). 19 // ELB Load Balancers If you're registering EC2 instances with an Elastic Load 20 // Balancing (ELB) load balancer, do not create Amazon Route 53 health checks for 21 // the EC2 instances. When you register an EC2 instance with a load balancer, you 22 // configure settings for an ELB health check, which performs a similar function to 23 // a Route 53 health check. Private Hosted Zones You can associate health checks 24 // with failover resource record sets in a private hosted zone. Note the 25 // following: 26 // 27 // * Route 53 health checkers are outside the VPC. To check the health 28 // of an endpoint within a VPC by IP address, you must assign a public IP address 29 // to the instance in the VPC. 30 // 31 // * You can configure a health checker to check the 32 // health of an external resource that the instance relies on, such as a database 33 // server. 34 // 35 // * You can create a CloudWatch metric, associate an alarm with the 36 // metric, and then create a health check that is based on the state of the alarm. 37 // For example, you might create a CloudWatch metric that checks the status of the 38 // Amazon EC2 StatusCheckFailed metric, add an alarm to the metric, and then create 39 // a health check that is based on the state of the alarm. For information about 40 // creating CloudWatch metrics and alarms by using the CloudWatch console, see the 41 // Amazon CloudWatch User Guide 42 // (https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/WhatIsCloudWatch.html). 43 func (c *Client) CreateHealthCheck(ctx context.Context, params *CreateHealthCheckInput, optFns ...func(*Options)) (*CreateHealthCheckOutput, error) { 44 if params == nil { 45 params = &CreateHealthCheckInput{} 46 } 47 48 result, metadata, err := c.invokeOperation(ctx, "CreateHealthCheck", params, optFns, c.addOperationCreateHealthCheckMiddlewares) 49 if err != nil { 50 return nil, err 51 } 52 53 out := result.(*CreateHealthCheckOutput) 54 out.ResultMetadata = metadata 55 return out, nil 56 } 57 58 // A complex type that contains the health check request information. 59 type CreateHealthCheckInput struct { 60 61 // A unique string that identifies the request and that allows you to retry a 62 // failed CreateHealthCheck request without the risk of creating two identical 63 // health checks: 64 // 65 // * If you send a CreateHealthCheck request with the same 66 // CallerReference and settings as a previous request, and if the health check 67 // doesn't exist, Amazon Route 53 creates the health check. If the health check 68 // does exist, Route 53 returns the settings for the existing health check. 69 // 70 // * If 71 // you send a CreateHealthCheck request with the same CallerReference as a deleted 72 // health check, regardless of the settings, Route 53 returns a 73 // HealthCheckAlreadyExists error. 74 // 75 // * If you send a CreateHealthCheck request with 76 // the same CallerReference as an existing health check but with different 77 // settings, Route 53 returns a HealthCheckAlreadyExists error. 78 // 79 // * If you send a 80 // CreateHealthCheck request with a unique CallerReference but settings identical 81 // to an existing health check, Route 53 creates the health check. 82 // 83 // This member is required. 84 CallerReference *string 85 86 // A complex type that contains settings for a new health check. 87 // 88 // This member is required. 89 HealthCheckConfig *types.HealthCheckConfig 90 91 noSmithyDocumentSerde 92 } 93 94 // A complex type containing the response information for the new health check. 95 type CreateHealthCheckOutput struct { 96 97 // A complex type that contains identifying information about the health check. 98 // 99 // This member is required. 100 HealthCheck *types.HealthCheck 101 102 // The unique URL representing the new health check. 103 // 104 // This member is required. 105 Location *string 106 107 // Metadata pertaining to the operation's result. 108 ResultMetadata middleware.Metadata 109 110 noSmithyDocumentSerde 111 } 112 113 func (c *Client) addOperationCreateHealthCheckMiddlewares(stack *middleware.Stack, options Options) (err error) { 114 err = stack.Serialize.Add(&awsRestxml_serializeOpCreateHealthCheck{}, middleware.After) 115 if err != nil { 116 return err 117 } 118 err = stack.Deserialize.Add(&awsRestxml_deserializeOpCreateHealthCheck{}, middleware.After) 119 if err != nil { 120 return err 121 } 122 if err = addSetLoggerMiddleware(stack, options); err != nil { 123 return err 124 } 125 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 126 return err 127 } 128 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 129 return err 130 } 131 if err = addResolveEndpointMiddleware(stack, options); err != nil { 132 return err 133 } 134 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 135 return err 136 } 137 if err = addRetryMiddlewares(stack, options); err != nil { 138 return err 139 } 140 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 141 return err 142 } 143 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 144 return err 145 } 146 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 147 return err 148 } 149 if err = addClientUserAgent(stack); err != nil { 150 return err 151 } 152 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 153 return err 154 } 155 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 156 return err 157 } 158 if err = addOpCreateHealthCheckValidationMiddleware(stack); err != nil { 159 return err 160 } 161 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateHealthCheck(options.Region), middleware.Before); err != nil { 162 return err 163 } 164 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 165 return err 166 } 167 if err = addResponseErrorMiddleware(stack); err != nil { 168 return err 169 } 170 if err = addRequestResponseLogging(stack, options); err != nil { 171 return err 172 } 173 return nil 174 } 175 176 func newServiceMetadataMiddleware_opCreateHealthCheck(region string) *awsmiddleware.RegisterServiceMetadata { 177 return &awsmiddleware.RegisterServiceMetadata{ 178 Region: region, 179 ServiceID: ServiceID, 180 SigningName: "route53", 181 OperationName: "CreateHealthCheck", 182 } 183 }