private static async Task DeleteOldVersionsForTheFunction(string functionName, int count)
        {
            var _versionList = (await _lambdaClient.ListVersionsByFunctionAsync(new ListVersionsByFunctionRequest {
                FunctionName = functionName
            }))
                               .Versions
                               .Where(q => !(q.FunctionArn.EndsWith("LATEST")))
                               .OrderByDescending(q => q.LastModified);

            Console.WriteLine("The Function has " + _versionList.Count() + " versions");
            if (_versionList.Count() > count)
            {
                foreach (var _version in _versionList.Skip(count))
                {
                    Console.WriteLine("Deleting " + _version.FunctionArn);
                    if (!_debugMode)
                    {
                        await _lambdaClient.DeleteFunctionAsync(new DeleteFunctionRequest { FunctionName = _version.FunctionName, Qualifier = _version.Version });
                    }
                }
            }
            else
            {
                Console.WriteLine("The Version Count is lower than " + count + ". The function is skipped.");
            }
        }
Exemplo n.º 2
0
        public ListVersionsByFunctionResponse ListVersionsByFunction(string functionName, string marker = null, int max = 0)
        {
            var request = new ListVersionsByFunctionRequest();

            request.FunctionName = functionName;
            if (marker != null)
            {
                request.Marker = marker;
            }
            if (max > 0)
            {
                request.MaxItems = max;
            }
            var response = _client.ListVersionsByFunctionAsync(request);

            return(response.Result);
        }