Esempio n. 1
0
        private async Task WaitForChangeSetCreate(string stackId, DeployContext context, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            Console.WriteLine("Waiting for changeset creation to complete...");
            var status = ChangeSetStatus.CREATE_PENDING;
            var reason = string.Empty;

            while (status != ChangeSetStatus.CREATE_COMPLETE)
            {
                cancellationToken.ThrowIfCancellationRequested();

                if (status == ChangeSetStatus.FAILED)
                {
                    throw new Exception($"Change set {context.ChangeSetName} failed: {reason}");
                }

                await Task.Delay(1000, cancellationToken);

                var request = new DescribeChangeSetRequest {
                    ChangeSetName = context.ChangeSetName, StackName = stackId
                };
                var response = await cloudformation.DescribeChangeSetAsync(request, cancellationToken);

                status = response.Status;
                reason = response.StatusReason;
            }
        }
Esempio n. 2
0
        private static async Task <DeployStackResult> WaitForChangeSetBeingAvailableAsync(ILogger log, IAmazonCloudFormation cloudformation, string changeSetId)
        {
            try
            {
                var request = new DescribeChangeSetRequest
                {
                    ChangeSetName = changeSetId
                };

                log.Information("... Waiting for change set to be reviewed");

                DescribeChangeSetResponse response;
                do
                {
                    await Task.Delay(POLLING_PERIOD).ConfigureAwait(false);

                    response = await cloudformation.DescribeChangeSetAsync(request).ConfigureAwait(false);
                } while (response.Status == ChangeSetStatus.CREATE_IN_PROGRESS || response.Status == ChangeSetStatus.CREATE_PENDING);

                if (response.Status == ChangeSetStatus.FAILED)
                {
                    if (response.StatusReason == "The submitted information didn't contain changes. Submit different information to create a change set.")
                    {
                        log.Information("Cloudformation update not needed.");
                        return(DeployStackResult.NoChanges);
                    }

                    log.Information($"Failed to create CloudFormation change set: {response.StatusReason}");
                    return(DeployStackResult.Failed);
                }

                return(DeployStackResult.Ok);
            }
            catch (Exception e)
            {
                log.Error(e, "Error getting status of change set");
                throw;
            }
        }
 private Amazon.CloudFormation.Model.DescribeChangeSetResponse CallAWSServiceOperation(IAmazonCloudFormation client, Amazon.CloudFormation.Model.DescribeChangeSetRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS CloudFormation", "DescribeChangeSet");
     try
     {
         #if DESKTOP
         return(client.DescribeChangeSet(request));
         #elif CORECLR
         return(client.DescribeChangeSetAsync(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;
     }
 }