当前位置: 首页>>代码示例>>C#>>正文


C# EC2.AmazonEC2Config类代码示例

本文整理汇总了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;
        }
开发者ID:ernestohs,项目名称:Apprenda-AWS-Integration,代码行数:35,代码来源:EC2AMIFactory.cs

示例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);
 }
开发者ID:awithy,项目名称:aws,代码行数:11,代码来源:ClientUtils.cs

示例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;
        }
开发者ID:ronmichael,项目名称:aws-snapshot-scheduler,代码行数:15,代码来源:Ec2Helper.cs

示例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);
        }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:14,代码来源:ProxyTests.cs

示例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));
        }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:15,代码来源:ProxyTests.cs

示例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);
        }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:21,代码来源:ProxyTests.cs

示例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);
 }
开发者ID:sadiqj,项目名称:aws-sdk-xamarin,代码行数:17,代码来源:AWSClientFactory.cs

示例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>
 /// &lt;?xml version="1.0" encoding="utf-8" ?&gt;
 /// &lt;configuration&gt;
 ///     &lt;appSettings&gt;
 ///         &lt;add key="AWSAccessKey" value="********************"/&gt;
 ///         &lt;add key="AWSSecretKey" value="****************************************"/&gt;
 ///     &lt;/appSettings&gt;
 /// &lt;/configuration&gt;
 /// </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);
 }
开发者ID:rguarino4,项目名称:aws-sdk-net,代码行数:21,代码来源:AWSClientFactory.cs

示例9: CreateAmazonEc2Client

        private AmazonEC2 CreateAmazonEc2Client(Ec2Key ec2Key)
        {
            var er2Config = new AmazonEC2Config();
            AmazonEC2 ec2 = AWSClientFactory.CreateAmazonEC2Client(ec2Key.AwsAccessKey, ec2Key.AwsSecretKey, er2Config);

            return ec2;
        }
开发者ID:escherrer,项目名称:EC2Utilities,代码行数:7,代码来源:Ec2ResourceAccess.cs

示例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)
 {
 }
开发者ID:rsparkyc,项目名称:aws-sdk-net,代码行数:12,代码来源:AmazonEC2Client.cs

示例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)
 {
 }
开发者ID:reidwooten99apps,项目名称:aws-sdk-net,代码行数:10,代码来源:AmazonEC2Client.cs

示例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);
        }
开发者ID:trista-lg,项目名称:AWSHelpers,代码行数:14,代码来源:AWSEC2Helper.cs

示例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;
        }
开发者ID:roymayfield,项目名称:aws-auto-scaling-console-sample,代码行数:18,代码来源:ConsoleView.xaml.cs

示例14: EC2Helper

 public EC2Helper(AwsClientDetails clientDetails, String regionURL)
 {
     AmazonEC2Config region = new AmazonEC2Config();
     region.ServiceURL = regionURL;
     Client = AWSClientFactory.CreateAmazonEC2Client(clientDetails.AwsAccessKeyId, clientDetails.AwsSecretAccessKey, region);
 }
开发者ID:JohnMorales,项目名称:MSBuildAWSTasks,代码行数:6,代码来源:EC2Helper.cs


注:本文中的Amazon.EC2.AmazonEC2Config类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。