GithubHelp home page GithubHelp logo

terraform-sphereex-shardingspherecloud's Introduction

Apache ShardingSphere Terraform Module

A terraform module to create an Apache ShardingSphere Proxy Cluster on AWS.

Terraform will create a cluster with the following architecture:

Prerequisites

  • Terraform CLI
  • AWS Resource
    • AK/SK for accessing AWS API
    • A internal domain name, default is shardingsphere.org
    • A list of Subnet IDs to launch the instance(s)
    • A SecurityGroup which allow ports 2888, 3888, and 2181 of the zookeeper server to pass through.
    • A ssh keypair

Usage

Step1: Edit main.tf

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "4.37.0"
    }
  }
}

provider "aws" {
  region     = "ap-southeast-1"
}

module "zk" {
  source              = "./zk"
  cluster_size        = 3
  key_name            = "test-tf"
  instance_type       = "t2.nano"
  vpc_id              = "vpc-0ef2b7440d3ade8d5"
  subnet_ids          = ["subnet-0f388a6f23063b8c9", "subnet-0bc2cd85facb5ca06", "subnet-009077567350ef1b7"]
  security_groups     = ["sg-008e74936b3f9de19"]
}

module "shardingsphere" {
  depends_on             = [module.zk]
  source                 = "./shardingsphere"
  cluster_size           = 3
  shardingsphere_version = "5.2.1"
  key_name               = "test-tf"
  image_id               = "ami-094bbd9e922dc515d"
  instance_type          = "t3.medium"
  lb_listener_port       = 3307
  vpc_id                 = "vpc-0ef2b7440d3ade8d5"
  subnet_ids             = ["subnet-0f388a6f23063b8c9", "subnet-0bc2cd85facb5ca06", "subnet-009077567350ef1b7"]
  security_groups     = ["sg-008e74936b3f9de19"]
  zk_servers             = module.zk.zk_node_domain
}

Step2: Set environments for AK/SK

export AWS_ACCESS_KEY_ID="accesskey"
export AWS_SECRET_ACCESS_KEY="secretkey"

Step3: Initial Terraform working directory

terrafrom init

Step4: Run the command terraform plan to generates a execution plan. Step5: Run the command terraform apply to crates your defined infrastructure.

By default, Terraform will create a domain proxy.[ZONE NAME] is used by other services.

If you want to delete, you can run the command terraform destroy, Terraform will destroy your defined infrastructure.

Modules

Requirements

Name Version
aws 4.37.0

Modules

Name Source Version
zk ./zk n/a
shardingsphere ./shardingsphere n/a

Outputs

Name Description
shardingsphere_domain The domain name of the ShardingSphere Proxy Cluster for use by other services
zk_node_domain The domain of zookeeper instances

ZK

Resources

Name Type
aws_instance.zk resource
aws_network_interface.zk resource
aws_route53_record.zk resource
aws_ami.base data source
aws_availability_zones.available data source
aws_route53_zone.zone data source

Inputs

Name Description Type Default Required
cluster_size The cluster size that same size as available_zones number n/a yes
hosted_zone_name The name of the hosted private zone string "shardingsphere.org" no
instance_type The EC2 instance type string n/a yes
key_name The ssh keypair for remote connection string n/a yes
security_groups List of the Security Group, it must be allow access 2181, 2888, 3888 port list(string) [] no
subnet_ids List of subnets sorted by availability zone in your VPC list(string) n/a yes
tags A map of zk instance resource, the default tag is Name=zk-${count.idx} map(any) {} no
vpc_id The id of VPC string n/a yes
zk_config The default config of zookeeper server map
{
"client_port": 2181,
"zk_heap": 1024
}
no
zk_version The zookeeper version string "3.7.1" no

Outputs

Name Description
zk_node_domain n/a
zk_node_private_ip n/a

shardingsphere

Resources

Name Type
aws_autoscaling_attachment.asg_attachment_lb resource
aws_autoscaling_group.ss resource
aws_launch_template.ss resource
aws_lb.ss resource
aws_lb_listener.ss resource
aws_lb_target_group.ss_tg resource
aws_network_interface.ss resource
aws_route53_record.ss resource
aws_availability_zones.available data source
aws_route53_zone.zone data source
aws_vpc.vpc data source

Inputs

Name Description Type Default Required
cluster_size The cluster size that same size as available_zones number n/a yes
hosted_zone_name The name of the hosted private zone string "shardingsphere.org" no
image_id The AMI id string n/a yes
instance_type The EC2 instance type string n/a yes
key_name the ssh keypair for remote connection string n/a yes
lb_listener_port lb listener port string n/a yes
security_groups List of The Security groups list(string) [] no
shardingsphere_version The shardingsphere version string n/a yes
subnet_ids List of subnets sorted by availability zone in your VPC list(string) n/a yes
vpc_id The id of your VPC string n/a yes
zk_servers The Zookeeper servers list(string) n/a yes

Outputs

Name Description
shardingsphere_domain The domain name of the ShardingSphere Proxy Cluster for use by other services

terraform-sphereex-shardingspherecloud's People

Contributors

xuanyuan300 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.