private async Task <NetworkInfo> GetAsync(string vpcId) { var network = await networkService.FindAsync(Aws, vpcId);; if (network == null) { var vpc = await ec2Client.DescribeVpcAsync(vpcId) ?? throw ResourceError.NotFound(Aws, ResourceTypes.Network, vpcId); var region = Locations.Get(Aws, ec2Client.Region.Name); var registerRequest = new RegisterNetworkRequest( addressBlocks: new[] { vpc.CidrBlock }, resource: ManagedResource.Network(region, vpc.VpcId), ownerId: 1 ); // TODO: Sync the subnets & security groups // TODO: Support ipv6 address blocks // Register the network with the platform network = await networkService.RegisterAsync(registerRequest);; } return(network); }
public async Task <NetworkInfo> RegisterAsync(RegisterNetworkRequest request) { Ensure.Object(request, nameof(request)); // Validate the request var network = new NetworkInfo( id: await db.Networks.Sequence.NextAsync(), addressBlocks: request.AddressBlocks, ownerId: request.OwnerId, resource: request.Resource ); await db.Networks.InsertAsync(network); return(network); }