Exemplo n.º 1
0
        public async Task CompleteTask(SNSEvent.SNSMessage message)
        {
            if (message.Message == "available")
            {
                await stepFunctionsClient.SendTaskSuccessAsync(new SendTaskSuccessRequest
                {
                    Output    = Serialize(new { Status = message.Message }),
                    TaskToken = message.MessageAttributes["TaskToken"].Value
                });

                return;
            }

            await stepFunctionsClient.SendTaskFailureAsync(new SendTaskFailureRequest
            {
                Cause     = message.Message,
                TaskToken = message.MessageAttributes["TaskToken"].Value
            });
        }
 private Amazon.StepFunctions.Model.SendTaskFailureResponse CallAWSServiceOperation(IAmazonStepFunctions client, Amazon.StepFunctions.Model.SendTaskFailureRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Step Functions", "SendTaskFailure");
     try
     {
         #if DESKTOP
         return(client.SendTaskFailure(request));
         #elif CORECLR
         return(client.SendTaskFailureAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
Exemplo n.º 3
0
        private async Task SendFailure(StackDeploymentStatusRequest request)
        {
            var tokenInfo = await tokenInfoRepository.FindByRequest(request);

            if (request.SourceTopic != config.GithubTopicArn)
            {
                var response = await stepFunctionsClient.SendTaskFailureAsync(new SendTaskFailureRequest
                {
                    TaskToken = tokenInfo.ClientRequestToken,
                    Cause     = request.ResourceStatus
                });

                logger.LogInformation($"Received send task failure response: {JsonSerializer.Serialize(response)}");
                await Dequeue(tokenInfo);
            }

            await githubStatusNotifier.NotifyFailure(
                tokenInfo.GithubOwner,
                tokenInfo.GithubRepo,
                tokenInfo.GithubRef,
                request.StackName,
                tokenInfo.EnvironmentName
                );
        }
Exemplo n.º 4
0
        public async Task <Response> Handle(SQSEvent sqsEvent, CancellationToken cancellationToken = default)
        {
            var request         = requestFactory.CreateFromSqsEvent(sqsEvent);
            var owner           = request.CommitInfo.GithubOwner;
            var repository      = request.CommitInfo.GithubRepository;
            var sha             = request.CommitInfo.GithubRef;
            var stackName       = request.StackName;
            var environmentName = request.EnvironmentName;

            try
            {
                var notificationArn = Environment.GetEnvironmentVariable(notificationArnKey);
                var template        = await s3Util.GetZipEntryInObject(request.ZipLocation, request.TemplateFileName);

                var stackConfig = await GetConfig(request);

                var token = await tokenGenerator.Generate(sqsEvent, request);

                await statusNotifier.NotifyPending(owner, repository, sha, stackName, environmentName);

                await stackDeployer.Deploy(new DeployStackContext
                {
                    StackName          = request.StackName,
                    Template           = template,
                    RoleArn            = request.RoleArn,
                    NotificationArn    = config.NotificationArn,
                    Parameters         = MergeParameters(stackConfig?.Parameters, request.ParameterOverrides),
                    Tags               = stackConfig?.Tags,
                    StackPolicyBody    = stackConfig?.StackPolicy?.Value,
                    ClientRequestToken = token,
                    Capabilities       = request.Capabilities,
                });
            }
            catch (NoUpdatesException)
            {
                var outputs = await GetStackOutputs(request.StackName, request.RoleArn);

                var response = await stepFunctionsClient.SendTaskSuccessAsync(new SendTaskSuccessRequest
                {
                    TaskToken = request.Token,
                    Output    = JsonSerializer.Serialize(outputs)
                });

                await statusNotifier.NotifySuccess(owner, repository, sha, stackName, environmentName);

                return(new Response
                {
                    Success = true
                });
            }
            catch (Exception e)
            {
                var response = await stepFunctionsClient.SendTaskFailureAsync(new SendTaskFailureRequest
                {
                    TaskToken = request.Token,
                    Cause     = e.Message
                });

                await statusNotifier.NotifyFailure(owner, repository, sha, stackName, environmentName);

                return(new Response
                {
                    Success = true
                });
            }

            throw new Exception();
        }