/// <summary> /// Initiates the asynchronous execution of the DeleteStack operation. /// <seealso cref="Amazon.CloudFormation.IAmazonCloudFormation.DeleteStack"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the DeleteStack operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task <DeleteStackResponse> DeleteStackAsync(DeleteStackRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new DeleteStackRequestMarshaller(); var unmarshaller = DeleteStackResponseUnmarshaller.GetInstance(); return(Invoke <IRequest, DeleteStackRequest, DeleteStackResponse>(request, marshaller, unmarshaller, signer, cancellationToken)); }
/// <summary> /// <para> Deletes a specified stack. Once the call completes successfully, stack deletion starts. Deleted stacks do not show up in the /// DescribeStacks API if the deletion has been completed successfully. </para> /// </summary> /// /// <param name="deleteStackRequest">Container for the necessary parameters to execute the DeleteStack service method on /// AmazonCloudFormation.</param> /// public DeleteStackResponse DeleteStack(DeleteStackRequest deleteStackRequest) { IRequest <DeleteStackRequest> request = new DeleteStackRequestMarshaller().Marshall(deleteStackRequest); DeleteStackResponse response = Invoke <DeleteStackRequest, DeleteStackResponse> (request, this.signer, DeleteStackResponseUnmarshaller.GetInstance()); return(response); }
internal DeleteStackResponse DeleteStack(DeleteStackRequest request) { var marshaller = new DeleteStackRequestMarshaller(); var unmarshaller = DeleteStackResponseUnmarshaller.Instance; return(Invoke <DeleteStackRequest, DeleteStackResponse>(request, marshaller, unmarshaller)); }
protected override void ProcessRecord() { base.ProcessRecord(); if (!ConfirmDelete("OCIResourcemanagerStack", "Remove")) { return; } DeleteStackRequest request; try { request = new DeleteStackRequest { StackId = StackId, OpcRequestId = OpcRequestId, IfMatch = IfMatch }; response = client.DeleteStack(request).GetAwaiter().GetResult(); WriteOutput(response); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
public override async Task <bool> ExecuteAsync() { try { var deleteRequest = new DeleteStackRequest { StackName = this.GetStringValueOrDefault(this.StackName, DefinedCommandOptions.ARGUMENT_STACK_NAME, true) }; try { await this.CloudFormationClient.DeleteStackAsync(deleteRequest); } catch (Exception e) { throw new LambdaToolsException("Error deleting CloudFormation stack: " + e.Message); } this.Logger.WriteLine($"CloudFormation stack {deleteRequest.StackName} deleted"); } catch (LambdaToolsException e) { this.Logger.WriteLine(e.Message); return(false); } catch (Exception e) { this.Logger.WriteLine($"Unknown error deleting CloudFormation stack: {e.Message}"); this.Logger.WriteLine(e.StackTrace); return(false); } return(true); }
/// <summary> /// Initiates the asynchronous execution of the DeleteStack operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the DeleteStack operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task <DeleteStackResponse> DeleteStackAsync(DeleteStackRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new DeleteStackRequestMarshaller(); var unmarshaller = DeleteStackResponseUnmarshaller.Instance; return(InvokeAsync <DeleteStackRequest, DeleteStackResponse>(request, marshaller, unmarshaller, cancellationToken)); }
public void DeleteStack(string stackName) { var request = new DeleteStackRequest { StackName = stackName }; _cloudFormationClient.DeleteStack(request); }
static void TestParentChildTemplates() { string bucket_Name = QSS3BucketName; string templateName = QSS3KeyPrefix + TdwUtils.cfClassPathParentSubnet.Replace("tdw_cf_template\\", ""); string stack_name = templateName.Replace("-", ""); stack_name = stack_name.Replace(".template", ""); string dataPath = null; byte[] dataBytes = null; PutObjectRequest request = null; PutObjectResponse response = null; AmazonS3Client s3Client = new AmazonS3Client(); bucket_Name = TdwUtils.CreateBucket(s3Client, QSS3BucketName); GetObjectRequest getObjectRequest = new GetObjectRequest { BucketName = bucket_Name, Key = templateName, }; string data = null; using (GetObjectResponse getObjectResponse = s3Client.GetObject(getObjectRequest)) { using (var stream = getObjectResponse.ResponseStream) using (var reader = new StreamReader(stream)) { data = reader.ReadToEnd(); } } Amazon.CloudFormation.AmazonCloudFormationClient cfClient = new AmazonCloudFormationClient(); try { DeleteStackRequest deleteRequest = new DeleteStackRequest() { StackName = stack_name }; cfClient.DeleteStack(deleteRequest); } catch (Exception ex) { ex = null; } List <string> CfCapabilities = new List <string>(); CfCapabilities.Add("CAPABILITY_IAM"); CreateStackRequest stackRequest = new CreateStackRequest() { StackName = stack_name, TemplateBody = data, Capabilities = CfCapabilities }; CreateStackResponse stackResponse = cfClient.CreateStack(stackRequest); }
public async Task DeleteStack(string stackName) { var request = new DeleteStackRequest() { StackName = stackName }; await _cloudFormationClient.DeleteStackAsync(request); }
public async Task <string> DeleteStack(string stackName, AsyncCallback callBack) { var getRequest = new DescribeStacksRequest() { StackName = stackName }; var request = new DeleteStackRequest() { StackName = stackName }; var response = await client.DeleteStackAsync(request); await Task.Delay(1000); callBack(null); if (response.HttpStatusCode != System.Net.HttpStatusCode.OK) { return(response.HttpStatusCode.ToString()); } // client.describestack while (true) { await Task.Delay(5000); try { var getResponse = await client.DescribeStacksAsync(getRequest); if (getResponse.Stacks == null || getResponse.Stacks.Count == 0) { return("DELETE_COMPLETE"); } var stack = getResponse.Stacks[0]; if (stack.StackStatus == StackStatus.DELETE_FAILED) { return("DELETE_FAILED"); } else if (stack.StackStatus == StackStatus.DELETE_COMPLETE) { return("DELETE_COMPLETE"); } else { continue; } } catch (Amazon.CloudFormation.AmazonCloudFormationException ex) { if (ex.Message.Trim() == $"Stack with id {stackName} does not exist".Trim()) { return("DELETE_COMPLETE"); } throw ex; } } }
/// <summary> /// <para>Deletes a specified stack. Once the call completes successfully, stack deletion starts. Deleted stacks do not show up in the /// DescribeStacks API if the deletion has been completed successfully.</para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the DeleteStack service method on /// AmazonCloudFormation.</param> public DeleteStackResponse DeleteStack(DeleteStackRequest request) { var task = DeleteStackAsync(request); try { return(task.Result); } catch (AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return(null); } }
/// <summary> /// 本接口(DeleteStack)用于删除一个资源栈(配置、版本、事件信息)。但不会销毁资源管理的云资源。如果需要销毁资源栈管理的云资源,请调用 DestoryStack 接口销毁云资源。 /// </summary> /// <param name="req"><see cref="DeleteStackRequest"/></param> /// <returns><see cref="DeleteStackResponse"/></returns> public DeleteStackResponse DeleteStackSync(DeleteStackRequest req) { JsonResponseModel <DeleteStackResponse> rsp = null; try { var strResp = this.InternalRequestSync(req, "DeleteStack"); rsp = JsonConvert.DeserializeObject <JsonResponseModel <DeleteStackResponse> >(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return(rsp.Response); }
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); } }
public static async Task DeleteQueuesForEndpoint(string endpointName, string queueNamePrefix = null) { using (var client = ClientFactory.CreateCloudFormationClient()) { var endpointNameWithPrefix = QueueNameHelper.GetSqsQueueName(endpointName, queueNamePrefix); var request = new DeleteStackRequest { StackName = endpointNameWithPrefix, }; await client.DeleteStackAsync(request) .ConfigureAwait(false); var describeRequest = new DescribeStacksRequest { StackName = endpointNameWithPrefix }; StackStatus currentStatus = string.Empty; while (currentStatus != StackStatus.DELETE_IN_PROGRESS) // in progress is enough, no need to wait for completion { try { var response = await client.DescribeStacksAsync(describeRequest) .ConfigureAwait(false); var stack = response.Stacks.SingleOrDefault(); currentStatus = stack?.StackStatus; await Task.Delay(1000); } catch (AmazonCloudFormationException) { Console.WriteLine("Stack does not exist"); return; } } } }
protected override async Task <bool> PerformActionAsync() { var deleteRequest = new DeleteStackRequest { StackName = this.GetStringValueOrDefault(this.StackName, LambdaDefinedCommandOptions.ARGUMENT_STACK_NAME, true) }; try { await this.CloudFormationClient.DeleteStackAsync(deleteRequest); } catch (Exception e) { throw new LambdaToolsException("Error deleting CloudFormation stack: " + e.Message, LambdaToolsException.LambdaErrorCode.CloudFormationDeleteStack, e); } this.Logger.WriteLine($"CloudFormation stack {deleteRequest.StackName} deleted"); return(true); }
public static async Task DeleteQueue(string queueName, string queueNamePrefix = null) { using (var client = ClientFactory.CreateCloudFormationClient()) { var sqsQueueName = QueueNameHelper.GetSqsQueueName(queueName, queueNamePrefix); var request = new DeleteStackRequest { StackName = sqsQueueName, }; await client.DeleteStackAsync(request) .ConfigureAwait(false); var describeRequest = new DescribeStacksRequest { StackName = sqsQueueName }; StackStatus currentStatus = string.Empty; while (currentStatus != StackStatus.DELETE_COMPLETE) { try { var response = await client.DescribeStacksAsync(describeRequest) .ConfigureAwait(false); var stack = response.Stacks.SingleOrDefault(); currentStatus = stack?.StackStatus; } catch (AmazonCloudFormationException) { Console.WriteLine("Stack does not exist"); return; } } } }
/// <summary> /// 删除资源栈 /// </summary> /// <param name="request">请求参数信息</param> /// <returns>请求结果信息</returns> public async Task <DeleteStackResponse> DeleteStack(DeleteStackRequest request) { return(await new DeleteStackExecutor().Client(this).Execute <DeleteStackResponse, DeleteStackResult, DeleteStackRequest>(request).ConfigureAwait(false)); }
public async Task TearDownResourcesAsync() { using (var cfClient = new AmazonCloudFormationClient()) { var request = new DeleteStackRequest { StackName = this.FrontendCloudFormationStack }; try { await cfClient.DeleteStackAsync(request); Console.WriteLine($"Frontend CloudFormation Stack {this.FrontendCloudFormationStack} is deleted"); } catch (Exception e) { Console.WriteLine($"Frontend CloudFormation Stack {this.FrontendCloudFormationStack} was not deleted: {e.Message}"); } } using (var lambdaClient = new AmazonLambdaClient()) { var request = new DeleteFunctionRequest { FunctionName = this.DynanmoDBStreamLambdaFunction }; try { await lambdaClient.DeleteFunctionAsync(request); Console.WriteLine($"Function {this.DynanmoDBStreamLambdaFunction} is deleted"); } catch (Exception e) { Console.WriteLine($"Function {this.DynanmoDBStreamLambdaFunction} was not deleted: {e.Message}"); } } using (var cognitoClient = new AmazonCognitoIdentityProviderClient()) { var userPool = (await cognitoClient.ListUserPoolsAsync(new ListUserPoolsRequest { MaxResults = 60 })).UserPools .FirstOrDefault(x => string.Equals(this.CognitoUserPool, x.Name)); if (userPool != null) { var request = new DeleteUserPoolRequest { UserPoolId = userPool.Id }; try { await cognitoClient.DeleteUserPoolAsync(request); Console.WriteLine($"Cognito User Pool {this.CognitoUserPool} is deleted"); } catch (Exception e) { Console.WriteLine($"Cognito User Pool {this.CognitoUserPool} was not deleted: {e.Message}"); } } } using (var ssmClient = new AmazonSimpleSystemsManagementClient()) { try { var parameters = (await ssmClient.GetParametersByPathAsync(new GetParametersByPathRequest { Path = this.ParameterStorePrefix, Recursive = true })).Parameters; Console.WriteLine($"Found {parameters.Count} SSM parameters starting with {this.ParameterStorePrefix}"); foreach (var parameter in parameters) { try { await ssmClient.DeleteParameterAsync(new DeleteParameterRequest { Name = parameter.Name }); Console.WriteLine($"Parameter {parameter.Name} is deleted"); } catch (Exception e) { Console.WriteLine($"Parameter {parameter.Name} was not deleted: {e.Message}"); } } } catch (Exception e) { Console.WriteLine($"Error deleting SSM Parameters: {e.Message}"); } } using (var ddbClient = new AmazonDynamoDBClient()) { var request = new DeleteTableRequest { TableName = this.DynamoDBTableName }; try { await ddbClient.DeleteTableAsync(request); Console.WriteLine($"Table {this.DynamoDBTableName} is deleted"); } catch (Exception e) { Console.WriteLine($"Table {this.DynamoDBTableName} was not deleted: {e.Message}"); } } }
public async Task <DeleteStackResponse> DeleteStackAsync(string stackName, string stackId, DeleteStackRequest request) { AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions(); return(await DeleteStackWithOptionsAsync(stackName, stackId, request, runtime)); }
public DeleteStackResponse DeleteStack(string stackName, string stackId, DeleteStackRequest request) { AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions(); return(DeleteStackWithOptions(stackName, stackId, request, runtime)); }
public async Task <DeleteStackResponse> DeleteStackWithOptionsAsync(string stackName, string stackId, DeleteStackRequest request, AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime) { AlibabaCloud.TeaUtil.Common.ValidateModel(request); return(TeaModel.ToObject <DeleteStackResponse>(await DoRequestAsync("2015-09-01", "HTTPS", "DELETE", "AK", "/stacks/" + stackName + "/" + stackId, AlibabaCloud.TeaUtil.Common.StringifyMapValue(request.Query.ToMap()), request.Headers, null, runtime))); }
/// <summary> /// 删除资源栈 /// </summary> /// <param name="request">请求参数信息</param> /// <returns>请求结果信息</returns> public DeleteStackResponse DeleteStack(DeleteStackRequest request) { return(new DeleteStackExecutor().Client(this).Execute <DeleteStackResponse, DeleteStackResult, DeleteStackRequest>(request)); }