Exemple #1
0
        /// <summary>
        /// This function takes in the name of the Route 53 domain to be updated, inspects the request to find the public IP, and assigns this IP to the domain name in Route 53.
        /// </summary>
        /// <param name="request">the request model containing HostedZonneId, DomainName, PublicIps</param>
        /// <param name="context">the Lambda context</param>
        /// <returns>an <c>APIGatewayProxyResponse</c> indicating if the function call was successfull</returns>
        public static async Task <Response> SetMyPublicIp(Request request, ILambdaContext context)
        {
            Logging.Log("Entrypoint...");

            // Validate and get the arguments from request
            ValidateRequest(request);

            // Update the recorset with the public IP
            var(requestId, requestStatus) = await _routeHandler.UpsertRecordset(request.HostedZoneId, request.DomainName, GeneralHelpers.GetFirstIp(request.PublicIps));

            // Buid response
            var response = new Response()
            {
                ChangeRequestId     = requestId,
                ChangeRequestStatus = requestStatus,
                PublicIp            = GeneralHelpers.GetFirstIp(request.PublicIps)
            };

            // Return
            Logging.Log($"Response: ChangeRequestId:{response.ChangeRequestId}, ChangeRequestStatus:{response.ChangeRequestStatus}, PublicIp:{response.PublicIp}");
            return(response);
        }