---
title: "Calvin Butler (@ckcalbut) | Hashnode"
description: "Calvin Butler (@ckcalbut) writes on Hashnode. Read their latest articles and follow their work."
url: "https://hashnode.com/@ckcalbut"
---

@ckcalbut

# Calvin Butler

@ckcalbut · Joined September 2023

## Comments

[Stefan Olaru Ahh that makes sense. Thank you much!](https://hashnode.com/posts/how-to-run-highly-available-typesense-cluster-in-aws/63a1a89aa59cad9bdbba1fe5/comment/655c1cb62a6c065f3be50ed1#reply-655e4ace356b1a848aa3d7f6)

Reply · Article · Nov 22, 2023 · [How to run a highly-available Typesense search in AWS](https://hashnode.com/posts/how-to-run-highly-available-typesense-cluster-in-aws/63a1a89aa59cad9bdbba1fe5)

[Ohhh... I suppose the startup would be tricky without the SNS Topic. The order of creation of things might become a tricky obstacle: The lambda has to be created to be triggered and yet the lambda needs to know some things about the autoscaling group.](https://hashnode.com/posts/how-to-run-highly-available-typesense-cluster-in-aws/63a1a89aa59cad9bdbba1fe5/comment/655c1cb62a6c065f3be50ed1#reply-655c1e86c8bfa45f6b14339f)

Reply · Article · Nov 21, 2023 · [How to run a highly-available Typesense search in AWS](https://hashnode.com/posts/how-to-run-highly-available-typesense-cluster-in-aws/63a1a89aa59cad9bdbba1fe5)

[Hi Stefan, May I ask why you decided to use a SNS Topic with a Lambda subscribed to it? Con: It seems like an extra step because you could just invoked the lambda at the end of the UserData script instead of writing to the SNS Topic at the end of the UserData script, which causes the lambda to be invoked. Pro: It does seem cleaner to separate the concerns of the lambda running successfully and the UserData script installing Typesense successfully. Was this your thinking or am I missing something?](https://hashnode.com/posts/how-to-run-highly-available-typesense-cluster-in-aws/63a1a89aa59cad9bdbba1fe5/comment/655c1cb62a6c065f3be50ed1)

Comment · Article · Nov 21, 2023 · [How to run a highly-available Typesense search in AWS](https://hashnode.com/posts/how-to-run-highly-available-typesense-cluster-in-aws/63a1a89aa59cad9bdbba1fe5)

[The names of the vpc stack's exported values are dependent on the name of the stack. I named my vpc stack, "typesense-vpc", in order for the exported values to have the names that the cluster stack expects.](https://hashnode.com/posts/how-to-run-highly-available-typesense-cluster-in-aws/63a1a89aa59cad9bdbba1fe5/comment/652056316ab81bbe71b0ae6a#reply-653aa1afe641417b5eeec3f5)

Reply · Article · Oct 26, 2023 · [How to run a highly-available Typesense search in AWS](https://hashnode.com/posts/how-to-run-highly-available-typesense-cluster-in-aws/63a1a89aa59cad9bdbba1fe5)

[Stefan Olaru Took a me a while (converted to cdk and changed/added some things), but here is what I did to generate the bootstrap api key and startup the typesense instance: Have AWS Secretsmanager generate the bootstrap api key without it ever touching my laptop: typesense\_bootstrap\_api\_key = secretsmanager.Secret(self, "TypesenseBootstrapAPIKeySecret", secret\_name="TypesenseBootstrapAPIKey", generate\_secret\_string=secretsmanager.SecretStringGenerator( exclude\_uppercase=True, exclude\_punctuation=True, password\_length=64, ), ) Get the Bootstrap API Key from SecretsManager upon execution of the UserData: sudo yum install jq # get the api key for bootstrapping typesense secretsmanager\_resp=$(aws secretsmanager get-secret-value \\ --secret-id {typesense\_bootstrap\_api\_key.secret\_name}) ApiKey=$(echo $secretsmanager\_resp | jq -r .SecretString) The Typesense EC2 Instance IAM Role needs additional permissions to get this secret from SecretsManager. I created a SecretsManagerReadOnlyPolicy and attached it to the role: secrets\_manager\_read\_only\_policy = iam.ManagedPolicy(self, "SecretsManagerReadOnlyPolicy", managed\_policy\_name="SecretsManagerReadOnly", statements=\[iam.PolicyStatement( effect=iam.Effect.ALLOW, actions=\[ "secretsmanager:GetResourcePolicy", "secretsmanager:GetSecretValue", "secretsmanager:DescribeSecret", "secretsmanager:ListSecretVersionIds" \], resources=\["\*"\] )\] ) I do end up using a lambda function to generate api keys. It gets the bootstrap or admin key (depending on what keyname you pass in the payload) from secretsmanager, reaches out to typesense to generate a new key with whatever name and permissions were passed in the payload, and then stores that new key in secretsmanager. Hopefully this can be run to generate the basic keys I'd want (admin, readwrite, readonly, idk what else) upon CDK deploy, but I don't have a great way to ensure it runs after the typesense server actually starts up for the first time without doing something very hacky. By the way, my UserData script needed this addition to get the EC2\_INSTANCE\_ID: # get instance-id TOKEN=$(curl -X PUT -H "X-aws-ec2-metadata-token-ttl-seconds: 600" "http://instance-data/latest/api/token") EC2\_INSTANCE\_ID=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -s http://instance-data/latest/meta-data/instance-id) This is all built into a greater cdk project I have going, but I will pull this out and put it in a public repo when I have time.](https://hashnode.com/posts/how-to-run-typesense-search-in-aws/639aa5021105b04b6078f283/comment/65124661555a1a5049a9df3a#reply-6519ae766b3bc781290706cf)

Reply · Article · Oct 1, 2023 · [How to run Typesense search in AWS](https://hashnode.com/posts/how-to-run-typesense-search-in-aws/639aa5021105b04b6078f283)

[Stefan Olaru Certainly!](https://hashnode.com/posts/how-to-run-typesense-search-in-aws/639aa5021105b04b6078f283/comment/65124661555a1a5049a9df3a#reply-65145ad65d5d746448ea4380)

Reply · Article · Sep 27, 2023 · [How to run Typesense search in AWS](https://hashnode.com/posts/how-to-run-typesense-search-in-aws/639aa5021105b04b6078f283)

[Stefan Olaru May I also ask why you generate the admin api key using a lambda function instead of using secrets manager?](https://hashnode.com/posts/how-to-run-typesense-search-in-aws/639aa5021105b04b6078f283/comment/65124661555a1a5049a9df3a#reply-65145051f80d7d6478976595)

Reply · Article · Sep 27, 2023 · [How to run Typesense search in AWS](https://hashnode.com/posts/how-to-run-typesense-search-in-aws/639aa5021105b04b6078f283)

[Stefan Olaru Oh, I didn't think of that. It wasn't clear to me from the AWS autoscaling docs what happens with the attached EBS (when set to not delete) upon autoscaling. That's very tricky. Thank you for the quick response.](https://hashnode.com/posts/how-to-run-typesense-search-in-aws/639aa5021105b04b6078f283/comment/65124661555a1a5049a9df3a#reply-6512d79f2bb1a65453316d2b)

Reply · Article · Sep 26, 2023 · [How to run Typesense search in AWS](https://hashnode.com/posts/how-to-run-typesense-search-in-aws/639aa5021105b04b6078f283)

[I appreciate your post. Thank you. I have one concern:It seems like half of the UserData bash script should be part of the CFN code instead. Specifically these steps should all be in CFN so that CloudFormation can track the resources, no?: # get instance-id # associate the Elastic IP address to the instance # attach volume # wait for volume to be properly attached # format the volume if doesn't have file system # create mount root folder # mount the volume to folder](https://hashnode.com/posts/how-to-run-typesense-search-in-aws/639aa5021105b04b6078f283/comment/65124661555a1a5049a9df3a)

Comment · Article · Sep 26, 2023 · [How to run Typesense search in AWS](https://hashnode.com/posts/how-to-run-typesense-search-in-aws/639aa5021105b04b6078f283)
