Repository: pepperize/cdk-route53-health-check (language: python)

Issue:
Cannot deploy a `EndpointHeathCheck` with `searchString`
If I define an `EndpointHeathCheck` with `searchString` like this

    const healthCheckApi = new EndpointHealthCheck(this, 'health-check-api', {
      domainName: props.api.domain,
      resourcePath: '/health',
      searchString: 'UP',
    });

I get the follwing error when running `cdk deploy`:
`Invalid request provided: AWS::Route53::HealthCheck`

I think the reason for this is, that you have to specify the `protocol` as `Protocol.HTTPS` although `Protocol.HTTPS` is the default according to the documentation.


Discussion / hints:
I will try to provide a pull request for this if that is ok for you.

Fix patch:
diff --git a/src/endpoint-health-check.ts b/src/endpoint-health-check.ts
index bf93247..1391ebb 100644
--- a/src/endpoint-health-check.ts
+++ b/src/endpoint-health-check.ts
@@ -105,7 +105,8 @@ export class EndpointHealthCheck extends HealthCheckBase {
   constructor(scope: Construct, id: string, props: EndpointHealthCheckProps) {
     super(scope, id);
 
-    const type = this.healthCheckType(props.protocol, props.searchString);
+    const protocol = props.protocol || Protocol.HTTPS;
+    const type = this.healthCheckType(protocol, props.searchString);
     const port = this.defaultPort(props.port, type);
     const enableSni = this.enableSniForHttps(type, props.enableSni);
 


Test patch:
diff --git a/test/endpoint-health-check.test.ts b/test/endpoint-health-check.test.ts
index 984b039..83508d6 100644
--- a/test/endpoint-health-check.test.ts
+++ b/test/endpoint-health-check.test.ts
@@ -121,4 +121,28 @@ describe("EndpointHealthCheck", () => {
 
     expect(capture.asObject()).not.toHaveProperty("InsufficientDataHealthStatus");
   });
+
+  it("Should be of type HTTPS_STR_MATCH if a searchString is specified", () => {
+    // Given
+    const stack = new Stack();
+    new EndpointHealthCheck(stack, "HealthCheck", {
+      domainName: "pepperize.com",
+      searchString: "UP",
+    });
+
+    // When
+    const template = Template.fromStack(stack);
+    const annotations = Annotations.fromStack(stack);
+
+    // Then
+    template.hasResourceProperties("AWS::Route53::HealthCheck", {
+      HealthCheckConfig: {
+        FullyQualifiedDomainName: "pepperize.com",
+        Port: 443,
+        Type: "HTTPS_STR_MATCH",
+        EnableSNI: true,
+      },
+    });
+    annotations.hasNoError("/Default/HealthCheck", "*");
+  });
 });