/// <summary> /// Updates the AWS Lambda functions code. /// </summary> /// <param name="functionName">The name of an AWS Lambda function.</param> /// <param name="settings">The <see cref="UpdateFunctionCodeSettings"/> 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> UpdateFunctionCode(string functionName, UpdateFunctionCodeSettings settings, CancellationToken cancellationToken = default(CancellationToken)) { if (String.IsNullOrEmpty(functionName)) { throw new ArgumentNullException(nameof(functionName)); } // Create Request AmazonLambdaClient client = this.CreateClient(settings); UpdateFunctionCodeRequest request = new UpdateFunctionCodeRequest() { FunctionName = functionName, Publish = settings.Publish, DryRun = settings.DryRun, S3Bucket = settings.S3Bucket, S3Key = settings.S3Key, S3ObjectVersion = settings.S3Version, ZipFile = settings.ZipFile }; if (settings.ZipPath != null) { request.ZipFile = this.GetFileStream(settings.ZipPath, settings); } // Check Response UpdateFunctionCodeResponse response = await client.UpdateFunctionCodeAsync(request, cancellationToken); if (response.HttpStatusCode == HttpStatusCode.OK) { _Log.Verbose("Successfully updated function '{0}'", functionName); return(response.Version); } else { _Log.Error("Failed to update function '{0}'", functionName); return(""); } }
public static async Task <string> UpdateLambdaFunctionCode(this ICakeContext context, string functionName, UpdateFunctionCodeSettings settings) { return(await context.CreateManager().UpdateFunctionCode(functionName, settings)); }