コード例 #1
0
        /// <summary>
        /// Creates an alias that points to the specified Lambda function version.
        /// </summary>
        /// <param name="functionName">The name of an AWS Lambda function.</param>
        /// <param name="settings">The <see cref="AliasSettings"/> 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 <bool> CreateAlias(string functionName, AliasSettings settings, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (String.IsNullOrEmpty(functionName))
            {
                throw new ArgumentNullException(nameof(functionName));
            }



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

            CreateAliasRequest request = new CreateAliasRequest()
            {
                Name = settings.Name,

                FunctionName    = functionName,
                FunctionVersion = settings.Version,

                Description = settings.Description
            };



            // Check Response
            CreateAliasResponse response = await client.CreateAliasAsync(request, cancellationToken);

            if (response.HttpStatusCode == HttpStatusCode.OK)
            {
                _Log.Verbose("Successfully published function '{0}'", functionName);
                return(true);
            }
            else
            {
                _Log.Error("Failed to published function '{0}'", functionName);
                return(false);
            }
        }