Ejemplo n.º 1
0
        public override async Task <bool> ProcessMessageAsync(CloudFormationRequest message, ILambdaContext context)
        {
            Log.LogInformation("Starting StackCreated strategy");


            return(await Task.Run(() => true));

            //send sqs to start lambda.
        }
Ejemplo n.º 2
0
        public async Task OnCFTEvent(CloudFormationRequest request, ILambdaContext context)
        {
            var response = new CloudFormationResponse();

            if (!Enum.TryParse <CFTEvent>(request.RequestType, out var eventType))
            {
                Log.LogInformation($"Skipping CFT Event {request.RequestType} - no handler found.");
                await response.CompleteCloudFormationResponse(true, request, context);
            }
            else
            {
                var success = await CFTStrategies[eventType].ProcessMessageAsync(request, context);
                await response.CompleteCloudFormationResponse(success, request, context);
            }

            await Task.Run(() =>
            {
                Log.LogInformation($"CFT Event: {request}");
            });
        }
Ejemplo n.º 3
0
        public async Task <CloudFormationResponse> CompleteCloudFormationResponse(bool success, CloudFormationRequest request, ILambdaContext context)
        {
            Log.LogInformation("Generating cloud formation response...");
            var responseBody = new CloudFormationResponse
            {
                Status             = success ? "SUCCESS" : "FAILED",
                Reason             = "See the details in CloudWatch Log Stream: " + context.LogStreamName,
                PhysicalResourceId = request.StackId,
                RequestId          = request.RequestId,
                LogicalResourceId  = request.LogicalResourceId,
                Data = null
            };

            Log.LogInformation("Sending response...");
            try
            {
                var client = new HttpClient();
                var json   = new StringContent(JsonConvert.SerializeObject(responseBody));
                json.Headers.Remove("Content-Type");

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

                var content = await postResponse.Content.ReadAsStringAsync();

                Log.LogInformation("Response: " + postResponse.ToJsonString() + content);
                postResponse.EnsureSuccessStatusCode();
            }
            catch (Exception ex)
            {
                Log.LogError($"ERROR: {ex.ToJsonString()}");
                responseBody.Status = "FAILED";
                responseBody.Data   = ex;
            }
            return(responseBody);
        }
Ejemplo n.º 4
0
 public async Task OnCFTEvent(CloudFormationRequest request, ILambdaContext context)
 {
     await new CFTLambdaProxy().OnCFTEvent(request, context);
 }
Ejemplo n.º 5
0
 public abstract Task <bool> ProcessMessageAsync(CloudFormationRequest message, ILambdaContext context);