Example #1
0
        /// <summary>
        /// Returns the configuration information of the Lambda function. This the same information
        /// you provided as parameters when uploading the function by using <a>CreateFunction</a>.
        ///
        ///
        /// <para>
        /// This operation requires permission for the <code>lambda:GetFunctionConfiguration</code>
        /// operation.
        /// </para>
        /// </summary>
        /// <param name="functionName">The name of the Lambda function for which you want to retrieve the configuration information.  You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length. </param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        ///
        /// <returns>The response from the GetFunctionConfiguration service method, as returned by Lambda.</returns>
        /// <exception cref="Amazon.Lambda.Model.ResourceNotFoundException">
        /// The resource (for example, a Lambda function or access policy statement) specified
        /// in the request does not exist.
        /// </exception>
        /// <exception cref="Amazon.Lambda.Model.ServiceException">
        /// The AWS Lambda service encountered an internal error.
        /// </exception>
        /// <exception cref="Amazon.Lambda.Model.TooManyRequestsException">
        ///
        /// </exception>
        public Task <GetFunctionConfigurationResponse> GetFunctionConfigurationAsync(string functionName, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var request = new GetFunctionConfigurationRequest();

            request.FunctionName = functionName;
            return(GetFunctionConfigurationAsync(request, cancellationToken));
        }
Example #2
0
        internal GetFunctionConfigurationResponse GetFunctionConfiguration(GetFunctionConfigurationRequest request)
        {
            var marshaller   = new GetFunctionConfigurationRequestMarshaller();
            var unmarshaller = GetFunctionConfigurationResponseUnmarshaller.Instance;

            return(Invoke <GetFunctionConfigurationRequest, GetFunctionConfigurationResponse>(request, marshaller, unmarshaller));
        }
        /// <summary>
        /// Returns the configuration information of the Lambda function. This the same information
        /// you provided as parameters when uploading the function by using <a>CreateFunction</a>.
        ///
        ///
        /// <para>
        /// This operation requires permission for the <code>lambda:GetFunctionConfiguration</code>
        /// operation.
        /// </para>
        /// </summary>
        /// <param name="functionName">The name of the Lambda function for which you want to retrieve the configuration information.  You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length. </param>
        /// <param name="options">
        ///     A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///     procedure using the AsyncState property.
        /// </param>
        ///
        /// <returns>The response from the GetFunctionConfiguration service method, as returned by Lambda.</returns>
        /// <exception cref="Amazon.Lambda.Model.ResourceNotFoundException">
        /// The resource (for example, a Lambda function or access policy statement) specified
        /// in the request does not exist.
        /// </exception>
        /// <exception cref="Amazon.Lambda.Model.ServiceException">
        /// The AWS Lambda service encountered an internal error.
        /// </exception>
        /// <exception cref="Amazon.Lambda.Model.TooManyRequestsException">
        ///
        /// </exception>
        public void GetFunctionConfigurationAsync(string functionName, AmazonServiceCallback <GetFunctionConfigurationRequest, GetFunctionConfigurationResponse> callback, AsyncOptions options = null)
        {
            var request = new GetFunctionConfigurationRequest();

            request.FunctionName = functionName;
            GetFunctionConfigurationAsync(request, callback, options);
        }
Example #4
0
        /// <summary>
        /// Returns the configuration information of the Lambda function. This the same information
        /// you provided as parameters when uploading the function by using <a>UploadFunction</a>.
        ///
        ///
        /// <para>
        /// This operation requires permission for the <code>lambda:GetFunctionConfiguration</code>
        /// operation.
        /// </para>
        /// </summary>
        /// <param name="functionName">The name of the Lambda function for which you want to retrieve the configuration information.</param>
        ///
        /// <returns>The response from the GetFunctionConfiguration service method, as returned by Lambda.</returns>
        /// <exception cref="Amazon.Lambda.Model.ResourceNotFoundException">
        /// The function or the event source specified in the request does not exist.
        /// </exception>
        /// <exception cref="Amazon.Lambda.Model.ServiceException">
        /// The AWS Lambda service encountered an internal error.
        /// </exception>
        public GetFunctionConfigurationResponse GetFunctionConfiguration(string functionName)
        {
            var request = new GetFunctionConfigurationRequest();

            request.FunctionName = functionName;
            return(GetFunctionConfiguration(request));
        }
        protected async Task UpdateHandlerAsync(IAmazonLambda lambdaClient, string handler, Dictionary <string, string> environmentVariables = null)
        {
            var updateFunctionConfigurationRequest = new UpdateFunctionConfigurationRequest
            {
                FunctionName = FunctionName,
                Handler      = handler,
                Environment  = new Model.Environment
                {
                    IsVariablesSet = true,
                    Variables      = environmentVariables ?? new Dictionary <string, string>()
                }
            };
            await lambdaClient.UpdateFunctionConfigurationAsync(updateFunctionConfigurationRequest);

            // Wait for eventual consistency of function change.
            var getConfigurationRequest = new GetFunctionConfigurationRequest {
                FunctionName = FunctionName
            };
            GetFunctionConfigurationResponse getConfigurationResponse = null;

            do
            {
                await Task.Delay(1000);

                getConfigurationResponse = await lambdaClient.GetFunctionConfigurationAsync(getConfigurationRequest);
            } while (getConfigurationResponse.State == State.Pending);
            await Task.Delay(1000);
        }
Example #6
0
        /// <summary>
        /// Initiates the asynchronous execution of the GetFunctionConfiguration operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the GetFunctionConfiguration operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task <GetFunctionConfigurationResponse> GetFunctionConfigurationAsync(GetFunctionConfigurationRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new GetFunctionConfigurationRequestMarshaller();
            var unmarshaller = GetFunctionConfigurationResponseUnmarshaller.Instance;

            return(InvokeAsync <GetFunctionConfigurationRequest, GetFunctionConfigurationResponse>(request, marshaller,
                                                                                                   unmarshaller, cancellationToken));
        }
        public static async Task WaitTillFunctionAvailableAsync(IToolLogger logger, IAmazonLambda lambdaClient, string functionName)
        {
            const int POLL_INTERVAL       = 3000;
            const int MAX_TIMEOUT_MINUTES = 20;

            try
            {
                var request = new GetFunctionConfigurationRequest
                {
                    FunctionName = functionName
                };

                GetFunctionConfigurationResponse response = null;

                bool logInitialMessage = false;
                var  timeout           = DateTime.UtcNow.AddMinutes(MAX_TIMEOUT_MINUTES);
                var  startTime         = DateTime.UtcNow;
                do
                {
                    response = await lambdaClient.GetFunctionConfigurationAsync(request);

                    if (response.LastUpdateStatus != LastUpdateStatus.InProgress && response.State != State.Pending)
                    {
                        if (response.LastUpdateStatus == LastUpdateStatus.Failed)
                        {
                            // Not throwing exception because it is possible the calling code could be fixing the failed state.
                            logger.WriteLine($"Warning: function {functionName} is currently in failed state: {response.LastUpdateStatusReason}");
                        }

                        return;
                    }

                    if (!logInitialMessage)
                    {
                        logger.WriteLine($"An update is currently in progress for Lambda function {functionName}. Waiting till update completes.");
                        logInitialMessage = true;
                    }
                    else
                    {
                        var ts = DateTime.UtcNow - startTime;
                        logger.WriteLine($"... Waiting ({ts.TotalSeconds.ToString("N2")} seconds)");
                    }
                    await Task.Delay(POLL_INTERVAL);
                } while (DateTime.UtcNow < timeout);
            }
            catch (Exception e)
            {
                throw new LambdaToolsException($"Error waiting for Lambda function to be in available status: {e.Message}", LambdaToolsException.LambdaErrorCode.LambdaWaitTillFunctionAvailable);
            }

            throw new LambdaToolsException($"Timeout waiting for function {functionName} to become available", LambdaToolsException.LambdaErrorCode.LambdaWaitTillFunctionAvailable);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the GetFunctionConfiguration operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the GetFunctionConfiguration operation on AmazonLambdaClient.</param>
        /// <param name="callback">An Action delegate that is invoked when the operation completes.</param>
        /// <param name="options">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        public void GetFunctionConfigurationAsync(GetFunctionConfigurationRequest request, AmazonServiceCallback <GetFunctionConfigurationRequest, GetFunctionConfigurationResponse> callback, AsyncOptions options = null)
        {
            options = options == null?new AsyncOptions():options;
            var marshaller   = new GetFunctionConfigurationRequestMarshaller();
            var unmarshaller = GetFunctionConfigurationResponseUnmarshaller.Instance;
            Action <AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;

            if (callback != null)
            {
                callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => {
                    AmazonServiceResult <GetFunctionConfigurationRequest, GetFunctionConfigurationResponse> responseObject
                        = new AmazonServiceResult <GetFunctionConfigurationRequest, GetFunctionConfigurationResponse>((GetFunctionConfigurationRequest)req, (GetFunctionConfigurationResponse)res, ex, ao.State);
                    callback(responseObject);
                }
            }
            ;
            BeginInvoke <GetFunctionConfigurationRequest>(request, marshaller, unmarshaller, options, callbackHelper);
        }
Example #9
0
        public async Task <GetFunctionConfigurationResponse> GetFunctionConfigurationAsync()
        {
            var request = new GetFunctionConfigurationRequest
            {
                FunctionName = this.GetStringValueOrDefault(this.FunctionName, LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_NAME, true)
            };

            try
            {
                var response = await this.LambdaClient.GetFunctionConfigurationAsync(request);

                return(response);
            }
            catch (ResourceNotFoundException)
            {
                return(null);
            }
            catch (Exception e)
            {
                throw new LambdaToolsException($"Error retrieving configuration for function {request.FunctionName}: {e.Message}", LambdaToolsException.LambdaErrorCode.LambdaGetConfiguration, e);
            }
        }
 public void GetFunctionConfigurationAsync(GetFunctionConfigurationRequest request, AmazonServiceCallback <GetFunctionConfigurationRequest, GetFunctionConfigurationResponse> callback, AsyncOptions options = null)
 {
     throw new System.NotImplementedException();
 }