public static async Task CompleteCloudFormation(object data, CloudFormationRequest request, ILambdaContext context)
        {
            // We must always have a physicalResourceId, if the function did not populate it, make one here
            if (string.IsNullOrWhiteSpace(request.PhysicalResourceId))
            {
                request.PhysicalResourceId = Guid.NewGuid().ToString();
            }

            await ProcessCloudFormationResponse(new CloudFormationResponse
            {
                Status             = "SUCCESS",
                Reason             = "",
                PhysicalResourceId = request.PhysicalResourceId,
                StackId            = request.StackId,
                RequestId          = request.RequestId,
                LogicalResourceId  = request.LogicalResourceId,
                Data = data
            }, request, context);
        }
        public static async Task FailCloudFormation(Exception ex, CloudFormationRequest request, ILambdaContext context)
        {
            context.Logger.Log($"FailCloudFormation with exception: {ex.ToString()}");

            // We must always have a physicalResourceId, if the function did not populate it, make one here
            if (string.IsNullOrWhiteSpace(request.PhysicalResourceId))
            {
                request.PhysicalResourceId = Guid.NewGuid().ToString();
            }

            await ProcessCloudFormationResponse(new CloudFormationResponse
            {
                Status             = "FAILED",
                Reason             = ex.Message,
                PhysicalResourceId = request.PhysicalResourceId,
                StackId            = request.StackId,
                RequestId          = request.RequestId,
                LogicalResourceId  = request.LogicalResourceId,
                Data = null
            }, request, context);
        }
        private static async Task ProcessCloudFormationResponse(CloudFormationResponse response, CloudFormationRequest request, ILambdaContext context)
        {
            try
            {
                var jsonPayload = JsonConvert.SerializeObject(response);

                context.Logger.Log($"ProcessCloudFormationResponse: {jsonPayload}");

                var client      = new HttpClient();
                var jsonContent = new StringContent(jsonPayload);

                jsonContent.Headers.Remove("Content-Type");

                var postResponse = await client.PutAsync(request.ResponseURL, jsonContent);

                postResponse.EnsureSuccessStatusCode();
            }
            catch (Exception ex)
            {
                context.Logger.Log("Exception in ProcessCloudFormationResponse: " + ex.ToString());
            }
        }