Table of Contents

Connecting to ScaleOut in AWS EC2

The EC2BootstrapGatewayProvider class allows the Scaleout.Client library to connect to a ScaleOut cluster in Amazon EC2 using only your AWS credentials to discover ScaleOut hosts.

Background

When a EC2BootstrapGatewayProvider instance is supplied to a GridConnection Connect or ConnectAsync call, your connection string can omit the bootstrapGateway parameter.

The EC2BootstrapGatewayProvider uses tag metadata that is present on your EC2 instances to find ScaleOut hosts. This metadata is present whenever ScaleOut hosts are launched using the standard ScaleOut CloudFormation template (or one of the ScaleOut-supplied AMIs in the AWS Marketplace).

Prerequisites

The EC2BootstrapGatewayProvider is available in the Scaleout.Client.EC2 NuGet package.

Procedure

  1. Add a reference to the Scaleout.Client.EC2 NuGet package.

  2. Supply an EC2BootstrapGatewayProvider instance to the GridConnection when connecting.

using System;
using Scaleout.Client;
using Scaleout.Client.EC2;

class Program
{
    static void Main(string[] args)
    {
        var ec2Prov = new EC2BootstrapGatewayProvider(
                            awsAccessKeyId: "AKIAIOSFODNN7EXAMPLE",
                            awsSecretKey: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
                            awsRegionName: "us-east-1",
                            scaleoutStoreName: "MyProdClusterEast",
                            gatewayType: GatewayType.Private);

        string connectionString = "useSecure=false;maxPoolsize=16";

        var conn = GridConnection.Connect(connectionString, ec2Prov);
        var cacheBuilder = new CacheBuilder<string, string>("My Cache", conn);
        var cache = cacheBuilder.Build();
        //...
    }
}
  • A constructor overload is available that takes an AmazonEC2Client instance from the AWS SDK for .NET. This can be used instead of supplying AWS credentials directly to ScaleOut APIs.
  • The EC2BootstrapGatewayProvider constructor requires a scaleoutStoreName argument. All ScaleOut clusters in AWS are assigned names upon deployment--use the name you gave your cluster for this parameter.
  • The gatewayType parameter indicates whether the Scaleout.Client library should connect using your EC2 instance's public or private IP address. Use GatewayType.Private whenever possible to avoid data egress charges.