Skip to end of metadata
Go to start of metadata

Following is a sample template file to create a WRTC instance in cluster mode. Save this content in a text file for example, wrtc_appliance_template.txt. If required customize this content or use your own template file to create an instance. 

Since WRTC Version 01.03.00R002 release, Sonus provides a new WRTC-Appliance template for WRTC-Appliance mode of installation in AWS.

Update section "AWSRegionArch2AMI"   based on the  AMI region and AMI-ID in which you are deploying.

{
  "AWSTemplateFormatVersion" : "2010-09-09",

  "Description" : "Automate creating two WRTC HA nodes in a new VPC that will share a virtual IP address for appliance mode.After successfully launching this CloudFormation stack, you will need to manually create an EIP and attach it to HA Node #1's VIP for external connectivity using the VIP.",

  "Parameters" : {

    "VpcCidr" : {
      "Description" : "CIDR address for the VPC to be created.",
      "Type" : "String",
      "Default" : "10.10.0.0/16"
    },
    "PublicSubnetRange" : {
      "Description" : "Address range for a public subnet to be created in the VPC.",
      "Type" : "String",
      "Default" : "10.10.0.0/24"
    },
    "HANodeInstanceType" : {
      "Description" : "Instance type for HA nodes.",
      "Type" : "String",
      "Default" : "t2.large"
    },
    "HANode1IP" : {
      "Description" : "IP address for the first HA node.",
      "Type" : "String",
      "Default" : "10.10.0.11"
    },
    "HANode2IP" : {
      "Description" : "IP address for the second HA node.",
      "Type" : "String",
      "Default" : "10.10.0.12"
    },
    "VIP" : {
      "Description" : "Private virtual IP address to be swapped between the HA nodes.",
      "Type" : "String",
      "Default" : "10.10.0.10"
    }
  },

  "Mappings" : {
    "AWSInstanceType2Arch" : {
      "t1.small"    : { "Arch" : "64" },
      "t2.large"    : { "Arch" : "64" },
      "m1.medium"   : { "Arch" : "64" },
      "m4.large"    : { "Arch" : "64" },
      "m4.2xlarge"  : { "Arch" : "64" },
      "m2.xlarge"   : { "Arch" : "64" },
      "m2.2xlarge"  : { "Arch" : "64" },
      "m2.4xlarge"  : { "Arch" : "64" },
      "c1.medium"   : { "Arch" : "64" },
      "c1.xlarge"   : { "Arch" : "64" },
      "cc1.4xlarge" : { "Arch" : "64Cluster" },
      "cc2.8xlarge" : { "Arch" : "64Cluster" },
      "cg1.4xlarge" : { "Arch" : "64GPU" }
    },

    "AWSRegionArch2AMI" : {
      "us-east-1"      : { "32" : "ami-7f831005", "64" : "ami-7f831005", "64Cluster" : "ami-7f831005",      "64GPU" : "ami-7f831005" },
      "sa-east-1"      : { "32" : "ami-acc185bb", "64" : "ami-90434787", "64Cluster" : "NOT_YET_SUPPORTED", "64GPU" : "NOT_YET_SUPPORTED" }
    }

  },

  "Resources" : {

    "VIPRole": {
       "Type": "AWS::IAM::Role",
       "Properties": {
          "AssumeRolePolicyDocument": {
             "Statement": [ {
                "Effect": "Allow",
                "Principal": {
                   "Service": [ "ec2.amazonaws.com" ]
                },
                "Action": [ "sts:AssumeRole" ]
             } ]
          },
          "Path": "/",
          "Policies": [ {
             "PolicyName": "VIP_Takeover",
             "PolicyDocument": {
                "Statement": [ {
                   "Effect": "Allow",
                   "Action": [
                        "ec2:AssignPrivateIpAddresses",
                        "ec2:DescribeInstances"
                   ],
                   "Resource": "*"
                } ]
             }
             } ]
          }
    },

    "VIPRoleProfile": {
       "Type": "AWS::IAM::InstanceProfile",
       "Properties": {
          "Path": "/",
          "Roles": [ {
             "Ref": "VIPRole"
          } ]
       }
    },

    "VPC" : {
      "Type" : "AWS::EC2::VPC",
      "Properties" : {
        "CidrBlock" : { "Ref" : "VpcCidr" },
        "Tags" : [
          { "Key" : "Application", "Value" : { "Ref" : "AWS::StackName" } },
          { "Key" : "Network", "Value" : "Public" }
        ]
      }
    },

    "PublicSubnet" : {
      "Type" : "AWS::EC2::Subnet",
      "Properties" : {
        "VpcId" : { "Ref" : "VPC" },
        "CidrBlock" : { "Ref" : "PublicSubnetRange" },
        "Tags" : [
          { "Key" : "Application", "Value" : { "Ref" : "AWS::StackName" } },
          { "Key" : "Network", "Value" : "Public" }
        ]
      }
    },

    "InternetGateway" : {
      "Type" : "AWS::EC2::InternetGateway",
      "Properties" : {
        "Tags" : [
          { "Key" : "Application", "Value" : { "Ref" : "AWS::StackName" } },
          { "Key" : "Network", "Value" : "Public" }
        ]
      }
    },

    "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" }
        ]
      }
    },

    "PublicRoute" : {
      "Type" : "AWS::EC2::Route",
      "Properties" : {
        "RouteTableId" : { "Ref" : "PublicRouteTable" },
        "DestinationCidrBlock" : "0.0.0.0/0",
        "GatewayId" : { "Ref" : "InternetGateway" }
      }
    },

    "PublicSubnetRouteTableAssociation" : {
      "Type" : "AWS::EC2::SubnetRouteTableAssociation",
      "Properties" : {
        "SubnetId" : { "Ref" : "PublicSubnet" },
        "RouteTableId" : { "Ref" : "PublicRouteTable" }
      }
    },

    "HANode1EIP" : {
      "Type" : "AWS::EC2::EIP",
      "Properties" : {
        "Domain" : "vpc",
        "InstanceId" : { "Ref" : "HANode1" }
      }
    },

    "HANode2EIP" : {
      "Type" : "AWS::EC2::EIP",
      "Properties" : {
        "Domain" : "vpc",
        "InstanceId" : { "Ref" : "HANode2" }
      }
    },

    "HANode1" : {
      "Type" : "AWS::EC2::Instance",
      "Metadata" : {
        "Comment1" : "Create HA Node #1"
      },
      "Properties" : {
        "InstanceType" : { "Ref" : "HANodeInstanceType" } ,
        "IamInstanceProfile" : { "Ref" : "VIPRoleProfile" },
        "SubnetId" : { "Ref" : "PublicSubnet" },
        "SourceDestCheck" : "true",
        "PrivateIpAddress" : { "Ref" : "HANode1IP" },
        "ImageId"        : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" }, { "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "HANodeInstanceType" }, "Arch" ] } ] },
        "SecurityGroupIds" : [{ "Ref" : "HANodeSecurityGroup" }],
        "Tags" : [
          { "Key" : "Name", "Value" : "HA Node #1" }
        ],
        
      "UserData" : { "Fn::Base64" : { "Fn::Join" : [ "", [
                "#cloud-config\n",
                "write_files:\n",
                "-   content: |\n",
                "     {\n",
                "         \"", "Role",                   "\" : \"", "Active",          "\",\n",
                "         \"", "Region",                 "\" : \"", { "Ref" : "AWS::Region" },
                                                                                       "\",\n",
                "         \"", "EmsUsername",            "\" : \"", "restuser",        "\",\n",
                "         \"", "EmsIP",                  "\" : \"", "0.0.0.0",         "\",\n",
                "         \"", "EmsPassword",            "\" : \"", "sonus123",        "\",\n",
                "         \"", "EmsPrivateNodeParameters", "\" : {\n",
                "                  \"", "vnfc_id",         "\" : \"", "appliance",     "\",\n",
                "                  \"", "cluster_id",      "\" : \"", "appliance",     "\",\n",
                "                  \"", "data_ip_address", "\" : \"", "0.0.0.0",       "\"\n",
                "                },\n",
                "         \"", "Interface1",             "\" : \"", "eth0",            "\",\n",
                "         \"", "Interface1Usage1",       "\" : \"", "SIP",             "\",\n",
                "         \"", "Interface1Usage2",       "\" : \"", "HTTP",            "\",\n",
                "         \"", "Interface1Usage3",       "\" : \"", "WebSocket",       "\",\n",
                "         \"", "VIP0", "\" : {\n",
                "                  \"", "IFNAME",        "\" : \"", "IF0",             "\",\n",
                "                  \"", "IP",            "\" : \"", { "Ref" : "VIP" }, "\"\n",
                "              },\n",
                "         \"", "VirtualInterfaceIP",     "\" : \"", { "Ref" : "VIP" }, "\",\n",
                "         \"", "PeerWRTCAddress",        "\" : \"", { "Ref" : "HANode2IP" }, 
                                                                                       "\",\n",
                "         \"", "EmsRegistrationId",      "\" : \"", "WRTC",            "\",\n",
                "         \"", "RestUserName",           "\" : \"", "restuser",        "\",\n",
                "         \"", "RestPassword",           "\" : \"", "sonus",           "\"\n",
                "     }\n",
                "    path: /opt/sonus/userData.json\n"
          ]] }}
      }
    },

    "HANode2" : {
      "Type" : "AWS::EC2::Instance",
      "Metadata" : {
        "Comment1" : "Create HA Node #2"
      },
      "Properties" : {
        "InstanceType" : { "Ref" : "HANodeInstanceType" } ,
        "IamInstanceProfile" : { "Ref" : "VIPRoleProfile" },
        "SubnetId" : { "Ref" : "PublicSubnet" },
        "PrivateIpAddress" : { "Ref" : "HANode2IP" },
        "SourceDestCheck" : "true",
        "ImageId"        : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" }, { "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "HANodeInstanceType" }, "Arch" ] } ] },
        "SecurityGroupIds" : [{ "Ref" : "HANodeSecurityGroup" }],
        "Tags" : [
          { "Key" : "Name", "Value" : "HA Node #2" }
        ],

            "UserData" : { "Fn::Base64" : { "Fn::Join" : [ "", [
                "#cloud-config\n",
                "write_files:\n",
                "-   content: |\n",
                "     {\n",
                "         \"", "Role",                   "\" : \"", "Standby",         "\",\n",
                "         \"", "Region",                 "\" : \"", { "Ref" : "AWS::Region" },
                                                                                       "\",\n",
                "         \"", "EmsUsername",            "\" : \"", "restuser",        "\",\n",
                "         \"", "EmsIP",                  "\" : \"", "0.0.0.0",         "\",\n",
                "         \"", "EmsPassword",            "\" : \"", "sonus123",        "\",\n",
                "         \"", "EmsPrivateNodeParameters", "\" : {\n",
                "                  \"", "vnfc_id",         "\" : \"", "appliance",     "\",\n",
                "                  \"", "cluster_id",      "\" : \"", "appliance",     "\",\n",
                "                  \"", "data_ip_address", "\" : \"", "0.0.0.0",       "\"\n",
                "                },\n",
                "         \"", "Interface1",             "\" : \"", "eth0",            "\",\n",
                "         \"", "Interface1Usage1",       "\" : \"", "SIP",             "\",\n",
                "         \"", "Interface1Usage2",       "\" : \"", "HTTP",            "\",\n",
                "         \"", "Interface1Usage3",       "\" : \"", "WebSocket",       "\",\n",
                "         \"", "VIP0", "\" : {\n",
                "                  \"", "IFNAME",        "\" : \"", "IF0",             "\",\n",
                "                  \"", "IP",            "\" : \"", { "Ref" : "VIP" }, "\"\n",
                "              },\n",
                "         \"", "VirtualInterfaceIP",     "\" : \"", { "Ref" : "VIP" }, "\",\n",
                "         \"", "PeerWRTCAddress",        "\" : \"", { "Ref" : "HANode1IP" }, 
                                                                                       "\",\n",
                "         \"", "EmsRegistrationId",      "\" : \"", "WRTC",            "\",\n",
                "         \"", "RestUserName",           "\" : \"", "restuser",        "\",\n",
                "         \"", "RestPassword",           "\" : \"", "sonus",           "\"\n",
                "     }\n",
                "    path: /opt/sonus/userData.json\n"
          ]] }}
      }
    },

    "HANodeSecurityGroup" : {
      "Type" : "AWS::EC2::SecurityGroup",
      "Properties" : {
        "GroupDescription" : "Rules for allowing access to HA Nodes",
        "VpcId" : { "Ref" : "VPC" },
        "SecurityGroupIngress" : [
           { "IpProtocol" : "tcp", "FromPort" : "80",  "ToPort" : "9090",  "CidrIp" : "0.0.0.0/0" } ,
           { "IpProtocol" : "tcp", "FromPort" : "22",  "ToPort" : "2024",  "CidrIp" : "0.0.0.0/0" } ],
        "SecurityGroupEgress" : [
           { "IpProtocol" : "-1", "FromPort" : "443", "ToPort" : "9080", "CidrIp" : "0.0.0.0/0" } ]
      }
    },

    "HANodesAllowICMP" : {
      "Type" : "AWS::EC2::SecurityGroupIngress",
      "Properties" : {
        "GroupId" : { "Ref" : "HANodeSecurityGroup" },
        "IpProtocol" : "icmp",
        "FromPort" : "-1",
        "ToPort" : "-1",
        "SourceSecurityGroupId" : { "Ref" : "HANodeSecurityGroup" }
      }
    }
  },

  "Outputs" : {
    "HANode1URL" : {
      "Description" : "URL for accessing the WRTC web application.",
      "Value" :  { "Fn::Join" : [ "", [ "https://", { "Ref" : "HANode1EIP" },":8081" ]] }
    },
    "HANode2URL" : {
      "Description" : "URL for accessing the WRTC web application.",
      "Value" :  { "Fn::Join" : [ "", [ "https://", { "Ref" : "HANode2EIP"},":8081" ]] }
    }
  }
}