Skip to content

Instantly share code, notes, and snippets.

@xpepper
Last active September 17, 2016 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xpepper/7880a24b1ff4081e9c09a485495ba256 to your computer and use it in GitHub Desktop.
Save xpepper/7880a24b1ff4081e9c09a485495ba256 to your computer and use it in GitHub Desktop.
Create an health check on AWS Route53 with aws cli

The command is something like

aws route53 create-health-check --caller-reference $(date "+%Y%m%d%H%M%S") --health-check-config file:///tmp/create-health-check.json --profile cn

where /tmp/create-health-check.json --profile cn is

{
  "Type": "HTTPS_STR_MATCH",
  "ResourcePath": "/production/photographers/search",
  "FullyQualifiedDomainName": "api.fakebook.com",
  "SearchString": "items",
  "RequestInterval": 30,
  "FailureThreshold": 3
}

response should be something like

{
    "HealthCheck": {
        "HealthCheckConfig": {
            "FailureThreshold": 3,
            "SearchString": "items",
            "ResourcePath": "/production/photographers/search",
            "EnableSNI": true,
            "Inverted": false,
            "MeasureLatency": false,
            "RequestInterval": 30,
            "Type": "HTTPS_STR_MATCH",
            "Port": 443,
            "FullyQualifiedDomainName": "api.fakebook.com"
        },
        "CallerReference": "10260012001114",
        "HealthCheckVersion": 1,
        "Id": "3e99ee29-5399-4854-b213-6736737b2baa"
    },
    "Location": "https://route53.amazonaws.com/2015-01-01/healthcheck/3e99ee29-5399-4854-b213-6736737b2baa"
}
require 'aws-sdk'
route53 = Aws::Route53::Client.new(
access_key_id: '<YOUR KEY>',
secret_access_key: '<SECRET_KEY>',
region: 'eu-west-1'
)
response = route53.create_health_check(
{
caller_reference: "#{rand(100000)}",
health_check_config: {
type: "HTTPS_STR_MATCH",
resource_path: "/production/photographers/search",
fully_qualified_domain_name: "api.fakebook.com",
search_string: "items",
request_interval: 30,
failure_threshold: 3,
measure_latency: true,
enable_sni: true
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment