Details instractions, on how to setup CockroachDB on AWS ( EC2 )
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
This artifact will help you to deploy Cockroachdb on AWS ( EC2 ).
- This is not production ready
- bastion host will be hosted on public subnet and cockroachdb instance will be hosted on private subnet.
- Loadbalancer to route requests to all the nodes on port 26257
- In this terraform project , cockroachdb service is not being deployed as a systemd
- Setup S3 backend for terraform state. details
- Generate ssh-keygen for Cockroachdb instances. details
- Setup Cockroachdb on AWS EC2. details
- terraform modules for this assignment. details
quick 3 min 42 sec demo video
This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.
AWS Account
An active AWS account.
aws cli ( >= 2.1.28)
aws cli need to be installed. Need help ?.
terraform (>= v0.14.7)
terraform cli need to be installed. Need help ?
Github code for this assignment
here
git clone https://github.com/sharmajee1/cockroachdb-on-aws.git
cd cockroachdb-on-aws
! Skip this step only if you already have S3 backend setup
if above steps are done, please perform below steps.
cd terraform-s3-backend
@@ setup your default variables `👉` variables.tf under terraform-s3-backend @@
# Once above steps are done, please perform below commands
terraform init
terraform plan -out=your_plan_name.tfplan
terraform apply "your_plan_name.tfplan"
@@ Copy `state_bucket_arn` URL from above execution, this will be required for `Setup cockroachDB on AWS` step. @@
#example
state_bucket_arn = "arn:aws:s3:::abhishek-temp-terraform-backend"
! Skip this step only if you already have ssh keys ready for this setup.
# From base dir `cockroachdb-on-aws` go inside scripts dir.
cd scripts
bash create-ssh-keygn.sh
Above script will create ./ssh and ssh-keys, please see below example.
scripts/ssh
├── cockroachdb-node
└── cockroachdb-node.pub
Go back to base dir cockroachdb-on-aws
From base dir perform below steps.
cd deploy-cockroachdb-om-aws-ec2
! Before performing next steps , please update your state.tf, details can be found from step `Setup S3 backend`
# Example
terraform {
backend "s3" {
bucket = "abhishek-temp-terraform-backend"
region = "us-east-1"
key = "terraform-state"
profile = "dev"
dynamodb_table = "terraform-lock"
}
}
! Before performing next steps , please update your aws profile name for `environment_to_profile_map` variable in variables.tf
# Example
variable "environment_to_profile_map" {
type = map
description = "Map aws cli profile based on the workspace"
default = {
default = "dev"
dev = "dev"
qa = "aws-qa-profile"
staging = "aws-staging-profile"
prod = "aws-prod-profile"
}
}
! Before performing next steps , please update your ssh keys for `private_key_path` and `public_key_path` variable in variables.tf
variable "private_key_path" {
default = "/Users/abhishek.sh/personal-proj/cockroachdb-on-aws/scripts/ssh/cockroachdb-node"
}
variable "public_key_path" {
default = "/Users/abhishek.sh/personal-proj/cockroachdb-on-aws/scripts/ssh/cockroachdb-node.pub"
}
Execute the final steps
# Once above steps are done, please perform below commands
terraform init
terraform plan -out=cockroachdb_setup.tfplan
terraform apply "cockroachdb_setup.tfplan"
@@ Copy the `bastion_public_ip` from above execution. @@
bastion_public_ip = "34.195.119.112"
id = [
"i-0beac6f4d8a904091",
"i-0959b35c961e34364",
]
@@ Copy the `lb_dns_name` name from above execution. @@
Login to bastion server, execute below command from your local server.
ssh -i <pem-file> ubuntu@<bastion_public_ip>
From bastion server execute below command.
cockroach node status --insecure --host=<lb_dns_name>
Once you are done with your testing, you can destroy your deployments
terraform destroy "cockroachdb_setup.tfplan"
Distributed under the MIT License. See LICENSE
for more information.
Author
abhishek sharma profile
Project Link
https://github.com/sharmajee1/cockroachdb-on-aws.git