public async Task DeleteStack(string stackName) { var request = new DeleteStackRequest() { StackName = stackName }; await _cloudFormationClient.DeleteStackAsync(request); }
public async Task DeleteStackAsync(string stackName) { if (!await StackExistsAsync(stackName)) { return; } await _cloudFormationClient.DeleteStackAsync(new DeleteStackRequest { StackName = stackName }); }
public async Task TeardownCloudFormation() { try { await cloudformation.DeleteStackAsync(new DeleteStackRequest { StackName = stackName }); await cloudformation.WaitUntilStackDoesNotExist(stackName); } catch (Exception) { } }
public async Task SetupCloudFormation() { cloudformation = new AmazonCloudFormationClient(); if (await cloudformation.StackExists(stackName)) { await cloudformation.DeleteStackAsync(new DeleteStackRequest { StackName = stackName }); await cloudformation.WaitUntilStackDoesNotExist(stackName); } }
private static async Task DeleteRollbackCompleteStackAsync(ILogger log, IAmazonCloudFormation cloudformation, Stack stack) { try { if (stack.StackStatus == StackStatus.ROLLBACK_COMPLETE) { await cloudformation.DeleteStackAsync(new DeleteStackRequest { StackName = stack.StackName }).ConfigureAwait(false); } await WaitForNoLongerInProgress(log, cloudformation, stack.StackName).ConfigureAwait(false); } catch (Exception ex) { log.Error(ex, "Error removing previous failed stack creation {stackName}", stack.StackName); throw; } }
/// <summary> /// Deletes given CloudFormation stack /// </summary> /// <param name="stackName">The stack name to be deleted</param> /// <exception cref="FailedToDeleteException">Thrown when deletion fails</exception> public async Task ExecuteAsync(string stackName) { var canDelete = await CanDeleteAsync(stackName); if (!canDelete) { return; } var confirmDelete = _consoleUtilities.AskYesNoQuestion($"Are you sure you want to delete {stackName}?", YesNo.No); if (confirmDelete == YesNo.No) { return; } _interactiveService.WriteLine($"{stackName}: deleting..."); var monitor = new StackEventMonitor(stackName, _awsClientFactory, _consoleUtilities); try { await _cloudFormationClient.DeleteStackAsync(new DeleteStackRequest { StackName = stackName }); // Fire and forget the monitor // Monitor updates the stdout with current status of the CloudFormation stack var _ = monitor.StartAsync(); await WaitForStackDelete(stackName); if (_session != null) { await _localUserSettingsEngine.DeleteLastDeployedStack(stackName, _session.ProjectDefinition.ProjectName, _session.AWSAccountId, _session.AWSRegion); } _interactiveService.WriteLine($"{stackName}: deleted"); } finally { // Stop monitoring CloudFormation stack status once the deletion operation finishes monitor.Stop(); } }
/// <summary> /// Deletes given CloudFormation stack /// </summary> /// <param name="stackName">The stack name to be deleted</param> /// <exception cref="FailedToDeleteException">Thrown when deletion fails</exception> public async Task ExecuteAsync(string stackName) { var canDelete = await CanDeleteAsync(stackName); if (!canDelete) { return; } var confirmDelete = _consoleUtilities.AskYesNoQuestion($"Are you sure you want to delete {stackName}?", ConsoleUtilities.YesNo.No); if (confirmDelete == ConsoleUtilities.YesNo.No) { return; } _interactiveService.WriteLine($"{stackName}: deleting..."); var monitor = new StackEventMonitor(stackName, _awsClientFactory, _interactiveService, _session); try { await _cloudFormationClient.DeleteStackAsync(new DeleteStackRequest { StackName = stackName }); // Fire and forget the monitor // Monitor updates the stdout with current status of the CloudFormation stack var _ = monitor.StartAsync(); await WaitForStackDelete(stackName); _interactiveService.WriteLine($"{stackName}: deleted"); } catch (AmazonCloudFormationException) { throw new FailedToDeleteException($"Failed to delete {stackName} stack."); } finally { // Stop monitoring CloudFormation stack status once the deletion operation finishes monitor.Stop(); } }
public static async Task <bool> DeleteStackAsync(ILogger log, IAmazonCloudFormation cloudformation, string stackName, string roleArn) { var request = new DeleteStackRequest { StackName = stackName, RoleARN = roleArn }; try { await cloudformation.DeleteStackAsync(request).ConfigureAwait(false); log.Information("CloudFormation stack {stackName} deleted", request.StackName); return(true); } catch (Exception ex) { log.Error(ex, "Error deleting Cloudformation stack {stackName}", request.StackName); return(false); } }
private Amazon.CloudFormation.Model.DeleteStackResponse CallAWSServiceOperation(IAmazonCloudFormation client, Amazon.CloudFormation.Model.DeleteStackRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS CloudFormation", "DeleteStack"); try { #if DESKTOP return(client.DeleteStack(request)); #elif CORECLR return(client.DeleteStackAsync(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; } }