本文整理汇总了C#中Amazon.EC2.AmazonEC2Config类的典型用法代码示例。如果您正苦于以下问题:C# AmazonEC2Config类的具体用法?C# AmazonEC2Config怎么用?C# AmazonEC2Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AmazonEC2Config类属于Amazon.EC2命名空间,在下文中一共展示了AmazonEC2Config类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartServer
public static Ec2Response StartServer(DeveloperOptions developerOptions)
{
try
{
var ec2Config = new AmazonEC2Config { AuthenticationRegion = developerOptions.RegionEndpont };
var ec2Client = new AmazonEC2Client(
new BasicAWSCredentials(developerOptions.AccessKey, developerOptions.SecretAccessKey), ec2Config);
var launchRequest = new RunInstancesRequest
{
ImageId = developerOptions.AmiId,
InstanceType = developerOptions.InstanceType,
MinCount = 1,
MaxCount = 1,
KeyName = developerOptions.Ec2KeyPair,
SecurityGroupIds = new List<string> { developerOptions.SecurityGroupId }
};
var launchResponse = ec2Client.RunInstances(launchRequest);
if (launchResponse.HttpStatusCode.Equals(HttpStatusCode.OK))
{
while (true)
{
var instances = ec2Client.DescribeInstances();
}
}
}
catch (Exception)
{
throw;
}
// TODO
return null;
}
示例2: _GetClient
private static AmazonEC2Client _GetClient()
{
var awsAccessKeyId = "ACCESS_KEY";
var secretAccessKey = "SECRET_ACCESS_KEY".ToCharArray();
var awsSecretAccessKey = new SecureString();
foreach (var secretAccessKeyChar in secretAccessKey)
awsSecretAccessKey.AppendChar(secretAccessKeyChar);
awsSecretAccessKey.MakeReadOnly();
var config = new AmazonEC2Config();
return new AmazonEC2Client(awsAccessKeyId, awsSecretAccessKey, config);
}
示例3: CreateClient
/// <summary>
/// Return the EC2 client
/// </summary>
/// <returns></returns>
public static AmazonEC2Client CreateClient()
{
AmazonEC2Config config = new AmazonEC2Config();
config.ServiceURL = "https://ec2." + Program.options.Region + ".amazonaws.com";
//config.RegionEndpoint = RegionEndpoint.USEast1;
AmazonEC2Client ec2 = new Amazon.EC2.AmazonEC2Client(Program.options.AccessKey, Program.options.SecretKey, config);
//AmazonEC2 ec2 = AWSClientFactory.CreateAmazonEC2Client(Program.options.AccessKey, Program.options.SecretKey, config);
return ec2;
}
示例4: TestProxySetupHostAndPortOnly
public void TestProxySetupHostAndPortOnly()
{
var dummyConfig = new AmazonEC2Config();
dummyConfig.ProxyHost = Host;
dummyConfig.ProxyPort = Port;
WebProxy proxy = dummyConfig.GetWebProxy();
var address = proxy.Address;
Assert.AreEqual(address.Host, Host);
Assert.AreEqual(address.Port, Port);
Assert.AreEqual(0, proxy.BypassList.Length);
Assert.IsFalse(proxy.BypassProxyOnLocal);
}
示例5: TestProxySetupWithSchemedHost
public void TestProxySetupWithSchemedHost()
{
// verifies bug fix that the http:// scheme is not doubled
// up in the proxy address if the user specifies it when setting
// proxy host (the bug yielded an address like http://http/host)
var dummyConfig = new AmazonEC2Config();
var host = string.Concat("http://", Host);
dummyConfig.ProxyHost = host;
dummyConfig.ProxyPort = Port;
WebProxy proxy = dummyConfig.GetWebProxy();
Assert.IsTrue(proxy.Address.ToString().StartsWith(host, StringComparison.OrdinalIgnoreCase));
}
示例6: TestProxySetupWithBypass
public void TestProxySetupWithBypass()
{
var dummyConfig = new AmazonEC2Config();
dummyConfig.ProxyHost = Host;
dummyConfig.ProxyPort = Port;
dummyConfig.ProxyBypassList = new List<string>(BypassList);
dummyConfig.ProxyBypassOnLocal = true;
WebProxy proxy = dummyConfig.GetWebProxy();
Assert.AreEqual(BypassList.Count, proxy.BypassList.Length);
// making assumption here that order is retained on assignment
// inside WebProxy - seems to be the case
for (int i = 0; i < BypassList.Count; i++)
{
Assert.AreEqual(BypassList[i], proxy.BypassList[i]);
}
Assert.IsTrue(proxy.BypassProxyOnLocal);
}
示例7: CreateAmazonEC2Client
/// <summary>
/// Create a client for the Amazon EC2 Service with the specified configuration
/// </summary>
/// <param name="awsAccessKey">The AWS Access Key associated with the account</param>
/// <param name="awsSecretAccessKey">The AWS Secret Access Key associated with the account</param>
/// <param name="config">Configuration options for the service like HTTP Proxy, # of connections, etc
/// </param>
/// <returns>An Amazon EC2 client</returns>
/// <remarks>
/// </remarks>
public static IAmazonEC2 CreateAmazonEC2Client(
string awsAccessKey,
string awsSecretAccessKey, AmazonEC2Config config
)
{
return new AmazonEC2Client(awsAccessKey, awsSecretAccessKey, config);
}
示例8: CreateAmazonEC2Client
/// <summary>
/// Create a client for the Amazon EC2 Service with the credentials loaded from the application's
/// default configuration, and if unsuccessful from the Instance Profile service on an EC2 instance.
///
/// Example App.config with credentials set.
/// <code>
/// <?xml version="1.0" encoding="utf-8" ?>
/// <configuration>
/// <appSettings>
/// <add key="AWSAccessKey" value="********************"/>
/// <add key="AWSSecretKey" value="****************************************"/>
/// </appSettings>
/// </configuration>
/// </code>
/// </summary>
/// <param name="config">Configuration options for the service like HTTP Proxy, # of connections, etc</param>
/// <returns>An Amazon EC2 client</returns>
public static AmazonEC2 CreateAmazonEC2Client(AmazonEC2Config config)
{
return new AmazonEC2Client(config);
}
示例9: CreateAmazonEc2Client
private AmazonEC2 CreateAmazonEc2Client(Ec2Key ec2Key)
{
var er2Config = new AmazonEC2Config();
AmazonEC2 ec2 = AWSClientFactory.CreateAmazonEC2Client(ec2Key.AwsAccessKey, ec2Key.AwsSecretKey, er2Config);
return ec2;
}
示例10: AmazonEC2Client
/// <summary>
/// Constructs AmazonEC2Client with AWS Access Key ID, AWS Secret Key and an
/// AmazonEC2Client Configuration object.
/// </summary>
/// <param name="awsAccessKeyId">AWS Access Key ID</param>
/// <param name="awsSecretAccessKey">AWS Secret Access Key</param>
/// <param name="awsSessionToken">AWS Session Token</param>
/// <param name="clientConfig">The AmazonEC2Client Configuration Object</param>
public AmazonEC2Client(string awsAccessKeyId, string awsSecretAccessKey, string awsSessionToken, AmazonEC2Config clientConfig)
: base(awsAccessKeyId, awsSecretAccessKey, awsSessionToken, clientConfig, AuthenticationTypes.User | AuthenticationTypes.Session)
{
}
示例11: AmazonEC2Client
/// <summary>
/// Constructs AmazonEC2Client with AWS Credentials and an
/// AmazonEC2Client Configuration object.
/// </summary>
/// <param name="credentials">AWS Credentials</param>
/// <param name="clientConfig">The AmazonEC2Client Configuration Object</param>
public AmazonEC2Client(AWSCredentials credentials, AmazonEC2Config clientConfig)
: base(credentials, clientConfig)
{
}
示例12: Initialize
private void Initialize(RegionEndpoint regionEndpoint, string AWSAcessKey, string AWSSecretKey)
{
// Set configuration info
AmazonEC2Config config = new AmazonEC2Config ();
config.Timeout = new TimeSpan (1, 0, 0);
config.ReadWriteTimeout = new TimeSpan (1, 0, 0);
config.RegionEndpoint = regionEndpoint;
// Create EC2 client
EC2client = AWSClientFactory.CreateAmazonEC2Client (
AWSAcessKey,
AWSSecretKey,
config);
}
示例13: GetEc2Client
/// <summary>
/// Creates AWS EC2 client
/// </summary>
/// <returns>AmazonEC2Client</returns>
private AmazonEC2Client GetEc2Client()
{
if (vm.Region == null)
{
throw new InvalidRegionException("No region defined when creating EC2 client");
}
AmazonEC2Config config = new AmazonEC2Config();
config.ServiceURL = vm.Region.Ec2Url;
AmazonEC2Client client = new AmazonEC2Client(config);
return client;
}
示例14: EC2Helper
public EC2Helper(AwsClientDetails clientDetails, String regionURL)
{
AmazonEC2Config region = new AmazonEC2Config();
region.ServiceURL = regionURL;
Client = AWSClientFactory.CreateAmazonEC2Client(clientDetails.AwsAccessKeyId, clientDetails.AwsSecretAccessKey, region);
}