Esempio n. 1
0
        /****************************************** VPC Peering Connection ******************************************/
        public async Task <SA_PeeringConnection> GetPeeringConnection(string name)
        {
            var request  = new DescribeVpcPeeringConnectionsRequest();
            var response = await client.DescribeVpcPeeringConnectionsAsync(request);

            var connection = response.VpcPeeringConnections.
                             FindAll(o => (o.Tags.FindIndex(p => p.Key == "Name" && p.Value == name) >= 0)).
                             Find(o => o.Status.Code == VpcPeeringConnectionStateReasonCode.Active);

            if (connection != null)
            {
                var connectionModel = new SA_PeeringConnection()
                {
                    AccepterVpc            = connection.AccepterVpcInfo.VpcId,
                    RequesterVpc           = connection.RequesterVpcInfo.VpcId,
                    VpcPeeringConnectionId = connection.VpcPeeringConnectionId,
                    Status = connection.Status.Code.Value
                };
                return(connectionModel);
            }
            else
            {
                return(null);
            }
        }
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonEC2Config config = new AmazonEC2Config();

            config.RegionEndpoint = region;
            ConfigureClient(config);
            AmazonEC2Client client = new AmazonEC2Client(creds, config);

            DescribeVpcPeeringConnectionsResponse resp = new DescribeVpcPeeringConnectionsResponse();

            do
            {
                DescribeVpcPeeringConnectionsRequest req = new DescribeVpcPeeringConnectionsRequest
                {
                    NextToken = resp.NextToken
                    ,
                    MaxResults = maxItems
                };

                resp = client.DescribeVpcPeeringConnections(req);
                CheckError(resp.HttpStatusCode, "200");

                foreach (var obj in resp.VpcPeeringConnections)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
 public void DescribeVpcPeeringConnectionsAsync(DescribeVpcPeeringConnectionsRequest request, AmazonServiceCallback <DescribeVpcPeeringConnectionsRequest, DescribeVpcPeeringConnectionsResponse> callback, AsyncOptions options = null)
 {
     throw new System.NotImplementedException();
 }