AWSTemplateFormatVersion: 2010-09-09 Description: | Simple deployment of YugabyteDB cluster in multi-AZ (default availability zone is 3 and replication factor is also 3) Parameters: DBVersion: Description: Default YugabyteDB version is 2025.2.0.0-b190 Type: String Default: "2025.2.0.0-b190" RFFactor: Description: Replication factor to create YugabyteDB cluster by default it is set to 3. Type: String Default: "3" KeyName: Description: 'Name of Key which is required for ssh to YugabyteDB node' Type: "AWS::EC2::KeyPair::KeyName" ConstraintDescription : "must be the name of an existing EC2 KeyPair." InstanceType: Description: 'Type of Instance for YugaByte DB cluster node' Type: "String" Default: "c5.xlarge" AllowedValues: ["c5.xlarge", "c5.2xlarge"] ConstraintDescription: "must be a valid EC2 instance type." LatestAmiId: Type: 'AWS::SSM::Parameter::Value' Default: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2' SshUser: Type: String Default: "ec2-user" Mappings: SubnetConfig: VPC: CIDR: "10.0.0.0/16" Public0: CIDR: "10.0.0.0/24" Public1: CIDR: "10.0.1.0/24" Public2: CIDR: "10.0.2.0/24" Resources: VPC: Type: 'AWS::EC2::VPC' Properties: EnableDnsSupport: 'true' EnableDnsHostnames: 'true' CidrBlock: !FindInMap - SubnetConfig - VPC - CIDR Tags: - Key: Application Value: !Ref 'AWS::StackName' - Key: Network Value: Public - Key: Name Value: !Ref "AWS::StackName" PublicSubnet0: Type: 'AWS::EC2::Subnet' Properties: VpcId: !Ref VPC AvailabilityZone: !Select - 0 - !GetAZs '' CidrBlock: !FindInMap - SubnetConfig - Public0 - CIDR MapPublicIpOnLaunch: 'true' Tags: - Key: Application Value: !Ref 'AWS::StackName' - Key: Network Value: Public - Key: Name Value: !Join - '' - - !Ref "AWS::StackName" - '-public-0' PublicSubnet1: Type: 'AWS::EC2::Subnet' Properties: VpcId: !Ref VPC AvailabilityZone: !Select - 1 - !GetAZs '' CidrBlock: !FindInMap - SubnetConfig - Public1 - CIDR MapPublicIpOnLaunch: 'true' Tags: - Key: Application Value: !Ref 'AWS::StackName' - Key: Network Value: Public - Key: Name Value: !Join - '' - - !Ref "AWS::StackName" - '-public-1' PublicSubnet2: Type: 'AWS::EC2::Subnet' Properties: VpcId: !Ref VPC AvailabilityZone: !Select - 2 - !GetAZs '' CidrBlock: !FindInMap - SubnetConfig - Public2 - CIDR MapPublicIpOnLaunch: 'true' Tags: - Key: Application Value: !Ref 'AWS::StackName' - Key: Network Value: Public - Key: Name Value: !Join - '' - - !Ref "AWS::StackName" - '-public-2' InternetGateway: Type: 'AWS::EC2::InternetGateway' Properties: Tags: - Key: Application Value: !Ref 'AWS::StackName' - Key: Network Value: Public - Key: Name Value: !Join - '' - - !Ref "AWS::StackName" - '-IGW' GatewayToInternet: Type: 'AWS::EC2::VPCGatewayAttachment' Properties: VpcId: !Ref VPC InternetGatewayId: !Ref InternetGateway PublicRouteTable: Type: 'AWS::EC2::RouteTable' Properties: VpcId: !Ref VPC Tags: - Key: Application Value: !Ref 'AWS::StackName' - Key: Network Value: Public - Key: Name Value: !Join - '' - - !Ref "AWS::StackName" - '-public-route-table' PublicRoute: Type: 'AWS::EC2::Route' DependsOn: GatewayToInternet Properties: RouteTableId: !Ref PublicRouteTable DestinationCidrBlock: 0.0.0.0/0 GatewayId: !Ref InternetGateway PublicSubnetRouteTableAssociation0: Type: 'AWS::EC2::SubnetRouteTableAssociation' Properties: SubnetId: !Ref PublicSubnet0 RouteTableId: !Ref PublicRouteTable PublicSubnetRouteTableAssociation1: Type: 'AWS::EC2::SubnetRouteTableAssociation' Properties: SubnetId: !Ref PublicSubnet1 RouteTableId: !Ref PublicRouteTable PublicSubnetRouteTableAssociation2: Type: 'AWS::EC2::SubnetRouteTableAssociation' Properties: SubnetId: !Ref PublicSubnet2 RouteTableId: !Ref PublicRouteTable YugaByteNodeSG: Type: AWS::EC2::SecurityGroup Properties: GroupDescription: 'YugaByte Node Security Group' GroupName: 'YugaByteNodeSG' VpcId: !Ref VPC SecurityGroupIngress: - IpProtocol: tcp FromPort: 22 ToPort: 22 CidrIp: "0.0.0.0/0" - IpProtocol: tcp FromPort: 7000 ToPort: 7000 CidrIp: "0.0.0.0/0" - IpProtocol: tcp FromPort: 7100 ToPort: 7100 CidrIp: !FindInMap - SubnetConfig - VPC - CIDR - IpProtocol: tcp FromPort: 9000 ToPort: 9000 CidrIp: "0.0.0.0/0" - IpProtocol: tcp FromPort: 9100 ToPort: 9100 CidrIp: !FindInMap - SubnetConfig - VPC - CIDR - IpProtocol: tcp FromPort: 6379 ToPort: 6379 CidrIp: !FindInMap - SubnetConfig - VPC - CIDR - IpProtocol: tcp FromPort: 5433 ToPort: 5433 CidrIp: !FindInMap - SubnetConfig - VPC - CIDR - IpProtocol: tcp FromPort: 9042 ToPort: 9042 CidrIp: !FindInMap - SubnetConfig - VPC - CIDR Tags: - Key: 'Name' Value: 'YugaByteSecurityGroup' Node0NetInt: Type: 'AWS::EC2::NetworkInterface' Properties: SubnetId: !Ref PublicSubnet0 GroupSet: - !Ref YugaByteNodeSG Node1NetInt: Type: 'AWS::EC2::NetworkInterface' Properties: SubnetId: !Ref PublicSubnet1 GroupSet: - !Ref YugaByteNodeSG Node2NetInt: Type: 'AWS::EC2::NetworkInterface' Properties: SubnetId: !Ref PublicSubnet2 GroupSet: - !Ref YugaByteNodeSG YugaByteNode0: Type: 'AWS::EC2::Instance' DependsOn: PublicRoute CreationPolicy: ResourceSignal: Count: '1' Timeout: PT5M Metadata: 'AWS::CloudFormation::Init': configSets: InstallAndRun: - Install - Configure Install: packages: yum: git: [] Configure: files: /home/ec2-user/install_software.sh: source: "https://raw.githubusercontent.com/YugaByte/utilities/master/common_scripts/install_software.sh" mode: '0755' owner: !Ref SshUser group: !Ref SshUser /home/ec2-user/create_universe.sh: source: "https://raw.githubusercontent.com/YugaByte/utilities/master/common_scripts/create_universe.sh" mode: '0755' owner: !Ref SshUser group: !Ref SshUser /home/ec2-user/start_master.sh: source: "https://raw.githubusercontent.com/YugaByte/utilities/master/scripts/start_master.sh" mode: '0755' owner: !Ref SshUser group: !Ref SshUser /home/ec2-user/start_tserver.sh: source: "https://raw.githubusercontent.com/YugaByte/utilities/master/scripts/start_tserver.sh" mode: '0755' owner: !Ref SshUser group: !Ref SshUser commands: 01_Install_YugaByte_DB: command: !Sub - bash -c "sudo -u ${SSH_USER} /home/${SSH_USER}/install_software.sh ${version}" - { version: !Ref DBVersion, SSH_USER: !Ref SshUser } 02_Create_universe: command: !Sub - bash -c "sudo -u ${SSH_USER} /home/${SSH_USER}/create_universe.sh AWS ${AWS::Region} ${RF} '${Node0NetInt.PrimaryPrivateIpAddress} ${Node1NetInt.PrimaryPrivateIpAddress} ${Node2NetInt.PrimaryPrivateIpAddress}' '${PublicSubnet0.AvailabilityZone} ${PublicSubnet1.AvailabilityZone} ${PublicSubnet2.AvailabilityZone}' ${PublicSubnet0.AvailabilityZone} ${SSH_USER}" - { RF: !Ref RFFactor, SSH_USER: !Ref SshUser } Properties: ImageId: !Ref LatestAmiId InstanceType: !Ref InstanceType KeyName: !Ref KeyName NetworkInterfaces : - NetworkInterfaceId: !Ref Node0NetInt DeviceIndex: 0 Tags: - Key: "Name" Value: !Join - '' - - !Ref "AWS::StackName" - 'Node-0' UserData: Fn::Base64: !Sub | #!/bin/bash -xe yum update -y aws-cfn-bootstrap /opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource YugaByteNode0 --configsets InstallAndRun --region ${AWS::Region} /opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource YugaByteNode0 --region ${AWS::Region} BlockDeviceMappings: - DeviceName: "/dev/xvda" Ebs: VolumeSize: 50 DeleteOnTermination: "true" VolumeType: "gp2" YugaByteNode1: Type: 'AWS::EC2::Instance' DependsOn: PublicRoute CreationPolicy: ResourceSignal: Count: '1' Timeout: PT5M Metadata: 'AWS::CloudFormation::Init': configSets: InstallAndRun: - Install - Configure Install: packages: yum: git: [] Configure: files: /home/ec2-user/install_software.sh: source: "https://raw.githubusercontent.com/YugaByte/utilities/master/common_scripts/install_software.sh" mode: '0755' owner: !Ref SshUser group: !Ref SshUser /home/ec2-user/create_universe.sh: source: "https://raw.githubusercontent.com/YugaByte/utilities/master/common_scripts/create_universe.sh" mode: '0755' owner: !Ref SshUser group: !Ref SshUser /home/ec2-user/start_master.sh: source: "https://raw.githubusercontent.com/YugaByte/utilities/master/scripts/start_master.sh" mode: '0755' owner: !Ref SshUser group: !Ref SshUser /home/ec2-user/start_tserver.sh: source: "https://raw.githubusercontent.com/YugaByte/utilities/master/scripts/start_tserver.sh" mode: '0755' owner: !Ref SshUser group: !Ref SshUser commands: 01_Install_YugaByte_DB: command: !Sub - bash -c "sudo -u ${SSH_USER} /home/${SSH_USER}/install_software.sh ${version}" - { version: !Ref DBVersion, SSH_USER: !Ref SshUser } 02_Create_universe: command: !Sub - bash -c "sudo -u ${SSH_USER} /home/${SSH_USER}/create_universe.sh AWS ${AWS::Region} ${RF} '${Node0NetInt.PrimaryPrivateIpAddress} ${Node1NetInt.PrimaryPrivateIpAddress} ${Node2NetInt.PrimaryPrivateIpAddress}' '${PublicSubnet0.AvailabilityZone} ${PublicSubnet1.AvailabilityZone} ${PublicSubnet2.AvailabilityZone}' ${PublicSubnet1.AvailabilityZone} ${SSH_USER}" - { RF: !Ref RFFactor, SSH_USER: !Ref SshUser } Properties: ImageId: !Ref LatestAmiId InstanceType: !Ref InstanceType KeyName: !Ref KeyName NetworkInterfaces : - NetworkInterfaceId: !Ref Node1NetInt DeviceIndex: 0 Tags: - Key: "Name" Value: !Join - '' - - !Ref "AWS::StackName" - 'Node-1' UserData: Fn::Base64: !Sub | #!/bin/bash -xe yum update -y aws-cfn-bootstrap /opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource YugaByteNode1 --configsets InstallAndRun --region ${AWS::Region} /opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource YugaByteNode1 --region ${AWS::Region} BlockDeviceMappings: - DeviceName: "/dev/xvda" Ebs: VolumeSize: 50 DeleteOnTermination: "true" VolumeType: "gp2" YugaByteNode2: Type: 'AWS::EC2::Instance' DependsOn: [PublicRoute, YugaByteNode0, YugaByteNode1] CreationPolicy: ResourceSignal: Count: '1' Timeout: PT5M Metadata: 'AWS::CloudFormation::Init': configSets: InstallAndRun: - Install - Configure Install: packages: yum: git: [] Configure: files: /home/ec2-user/install_software.sh: source: "https://raw.githubusercontent.com/YugaByte/utilities/master/common_scripts/install_software.sh" mode: '0755' owner: !Ref SshUser group: !Ref SshUser /home/ec2-user/create_universe.sh: source: "https://raw.githubusercontent.com/YugaByte/utilities/master/common_scripts/create_universe.sh" mode: '0755' owner: !Ref SshUser group: !Ref SshUser /home/ec2-user/start_master.sh: source: "https://raw.githubusercontent.com/YugaByte/utilities/master/scripts/start_master.sh" mode: '0755' owner: !Ref SshUser group: !Ref SshUser /home/ec2-user/start_tserver.sh: source: "https://raw.githubusercontent.com/YugaByte/utilities/master/scripts/start_tserver.sh" mode: '0755' owner: !Ref SshUser group: !Ref SshUser commands: 01_Install_YugaByte_DB: command: !Sub - bash -c "sudo -u ${SSH_USER} /home/${SSH_USER}/install_software.sh ${version}" - { version: !Ref DBVersion, SSH_USER: !Ref SshUser } 02_Create_universe: command: !Sub - bash -c "sudo -u ${SSH_USER} /home/${SSH_USER}/create_universe.sh AWS ${AWS::Region} ${RF} '${Node0NetInt.PrimaryPrivateIpAddress} ${Node1NetInt.PrimaryPrivateIpAddress} ${Node2NetInt.PrimaryPrivateIpAddress}' '${PublicSubnet0.AvailabilityZone} ${PublicSubnet1.AvailabilityZone} ${PublicSubnet2.AvailabilityZone}' ${PublicSubnet2.AvailabilityZone} ${SSH_USER}" - { RF: !Ref RFFactor, SSH_USER: !Ref SshUser } Properties: ImageId: !Ref LatestAmiId InstanceType: !Ref InstanceType KeyName: !Ref KeyName NetworkInterfaces : - NetworkInterfaceId: !Ref Node2NetInt DeviceIndex: 0 Tags: - Key: "Name" Value: !Join - '' - - !Ref "AWS::StackName" - 'Node-2' UserData: Fn::Base64: !Sub | #!/bin/bash -xe yum update -y aws-cfn-bootstrap /opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource YugaByteNode2 --configsets InstallAndRun --region ${AWS::Region} /opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource YugaByteNode2 --region ${AWS::Region} BlockDeviceMappings: - DeviceName: "/dev/xvda" Ebs: VolumeSize: 50 DeleteOnTermination: "true" VolumeType: "gp2" Outputs: VPC: Description: YugabyteDB VPC Value: !Ref VPC Export: Name: !Sub '${AWS::Region}-${AWS::StackName}-VPC' SecurityGroup: Description: YugabyteDB Node Security Group Value: !Ref YugaByteNodeSG UI: Description: URL to access YugabyteDB Admin Portal Value: !Join [ "", [ "http://", !GetAtt YugaByteNode0.PublicDnsName, ":7000" ] ] JDBC: Description: JDBC Connect string for YugabyteDB Value: !Join [ "", ["postgresql://yugabyte@", !GetAtt YugaByteNode0.PublicDnsName, ":5433" ] ] YSQL: Description: YSQL connect string for YugabyteDB Value: !Join [ " ", ["ysqlsh -U yugabyte -h", !GetAtt YugaByteNode0.PublicDnsName, "-p 5433" ] ] YCQL: Description: YCQL connect string for YugabyteDB Value: !Join [ " ", ["ycqlsh", !GetAtt YugaByteNode0.PublicDnsName, "9042" ] ] YEDIS: Description: YEDIS connect string for YugabyteDB Value: !Join [ " ", ["redis-cli -h", !GetAtt YugaByteNode0.PublicDnsName, "-p 6379" ] ]