public async Task DescribeVpcsAsync_when_any_exist_should_describe_vpcs()
        {
            // Arrange
            var         client         = new EnvironmentVariables().CloudComputeClient();
            IVpcService classUnderTest = new VpcService(client);

            // Act
            var response = await classUnderTest.DescribeVpcsAsync();

            // Assert
            Assert.IsTrue(response.Vpcs.Count >= 1);
        }
        public async Task CreateDefaultVpcAsync_should_create_and_return_default_vpc()
        {
            // Arrange
            var         client         = new EnvironmentVariables().CloudComputeClient();
            IVpcService classUnderTest = new VpcService(client);

            // Act
            var response = await classUnderTest.CreateDefaultVpcAsync();

            // Assert
            Assert.IsTrue(response.Vpc != null);
            Assert.IsTrue(response.Vpc.VpcId.Length > 1);
        }
        public async Task DeleteVpcAsync_when_vpcId_exists_should_delete()
        {
            // Arrange
            var         vpcId          = "vpc-04bcccec7c7d8bff3";
            var         client         = new EnvironmentVariables().CloudComputeClient();
            IVpcService classUnderTest = new VpcService(client);

            // Act
            var response = await classUnderTest.DeleteVpcAsync(vpcId);

            // Assert
            Assert.IsTrue(response.HttpStatusCode == System.Net.HttpStatusCode.OK);
        }
Beispiel #4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();

            // appsettings.json
            var awsAccessKeyId     = Configuration.GetSection("AwsAccessKeyId").Value;
            var awsSecretAccessKey = Configuration.GetSection("AwsSecretAccessKey").Value;
            var keyService         = new KeyService(awsAccessKeyId, awsSecretAccessKey);

            // Amazon clients
            // `keyService` can be used to pass `AwsAccessKeyId` and `AwsSecretAccessKey`
            var cloudComputeClient      = new AmazonEC2Client();
            var containerServiceClient  = new AmazonECSClient();
            var containerRegistryClient = new AmazonECRClient();

            services.AddSingleton <IKeyService>(keyService);
            services.AddSingleton <IAmazonEC2>(cloudComputeClient);
            services.AddSingleton <IAmazonECS>(containerServiceClient);
            services.AddSingleton <IAmazonECR>(containerRegistryClient);

            // AwsAdmin.Application Services
            var vpcService             = new VpcService(cloudComputeClient);
            var subnetService          = new SubnetService(cloudComputeClient);
            var routeTableService      = new RouteTableService(cloudComputeClient);
            var internetGatewayService = new InternetGatewayService(cloudComputeClient);
            var dhcpOptionsSetService  = new DhcpOptionsSetService(cloudComputeClient);
            var networkAclsService     = new NetworkAclsService(cloudComputeClient);
            var securityGroupService   = new SecurityGroupService(cloudComputeClient);

            services.AddSingleton <IVpcService>(vpcService);
            services.AddSingleton <ISubnetService>(subnetService);
            services.AddSingleton <IRouteTableService>(routeTableService);
            services.AddSingleton <IInternetGatewayService>(internetGatewayService);
            services.AddSingleton <IDhcpOptionsSetService>(dhcpOptionsSetService);
            services.AddSingleton <INetworkAclsService>(networkAclsService);
            services.AddSingleton <ISecurityGroupService>(securityGroupService);

            // Mappers
            services.AddSingleton <IDescribeVpcMapper, DescribeVpcMapper>();
            services.AddSingleton <IDescribeSubnetMapper, DescribeSubnetMapper>();
            services.AddSingleton <IDescribeRouteTableMapper, DescribeRouteTableMapper>();
            services.AddSingleton <IDhcpOptionsSetsMapper, DhcpOptionsSetsMapper>();
            services.AddSingleton <IInternetGatewayMapper, InternetGatewayMapper>();
            services.AddSingleton <INetworkAclsMapper, NetworkAclsMapper>();
            services.AddSingleton <ISecurityGroupMapper, SecurityGroupMapper>();
        }