/// <summary>
        /// Publishes a version of your function from the current snapshot of $LATEST.
        /// </summary>
        /// <param name="functionName">The name of an AWS Lambda function.</param>
        /// <param name="settings">The <see cref="PublishVersionSettings"/> used during the request to AWS.</param>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        public async Task <string> PublishVersion(string functionName, PublishVersionSettings settings, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (String.IsNullOrEmpty(functionName))
            {
                throw new ArgumentNullException(nameof(functionName));
            }



            // Create Request
            AmazonLambdaClient client = this.CreateClient(settings);

            PublishVersionRequest request = new PublishVersionRequest()
            {
                FunctionName = functionName,

                CodeSha256  = settings.CodeSha256,
                Description = settings.Description
            };



            // Check Response
            PublishVersionResponse response = await client.PublishVersionAsync(request, cancellationToken);

            if (response.HttpStatusCode == HttpStatusCode.OK)
            {
                _Log.Verbose("Successfully published function '{0}'", functionName);
                return(response.Version);
            }
            else
            {
                _Log.Error("Failed to published function '{0}'", functionName);
                return("");
            }
        }
Exemple #2
0
 public static async Task <string> PublishLambdaVersion(this ICakeContext context, string functionName, PublishVersionSettings settings)
 {
     return(await context.CreateManager().PublishVersion(functionName, settings));
 }