public async Task <string> DeleteStack(string stackName, AsyncCallback callBack) { var helper = new CloudFormationHelper( GlobalVariables.Enviroment, GlobalVariables.Region, GlobalVariables.Color); return(await helper.DeleteStack(stackName, callBack)); }
protected virtual void Dispose(bool disposing) { if (_isDisposed) { return; } if (disposing) { var isStackDeleted = _cloudFormationHelper.IsStackDeleted(_stackName).GetAwaiter().GetResult(); if (!isStackDeleted) { _cloudFormationHelper.DeleteStack(_stackName).GetAwaiter().GetResult(); } } _isDisposed = true; }
public async Task WebFargateDeploymentNoConfigChanges() { _stackName = $"ServerModeWebFargate{Guid.NewGuid().ToString().Split('-').Last()}"; var projectPath = _testAppManager.GetProjectPath(Path.Combine("testapps", "WebAppWithDockerFile", "WebAppWithDockerFile.csproj")); var portNumber = 4001; using var httpClient = ServerModeHttpClientFactory.ConstructHttpClient(ResolveCredentials); var serverCommand = new ServerModeCommand(_serviceProvider.GetRequiredService <IToolInteractiveService>(), portNumber, null, true); var cancelSource = new CancellationTokenSource(); var serverTask = serverCommand.ExecuteAsync(cancelSource.Token); try { var baseUrl = $"http://localhost:{portNumber}/"; var restClient = new RestAPIClient(baseUrl, httpClient); await WaitTillServerModeReady(restClient); var startSessionOutput = await restClient.StartDeploymentSessionAsync(new StartDeploymentSessionInput { AwsRegion = _awsRegion, ProjectPath = projectPath }); var sessionId = startSessionOutput.SessionId; Assert.NotNull(sessionId); var signalRClient = new DeploymentCommunicationClient(baseUrl); await signalRClient.JoinSession(sessionId); var logOutput = new StringBuilder(); signalRClient.ReceiveLogAllLogAction = (line) => { logOutput.AppendLine(line); }; var getRecommendationOutput = await restClient.GetRecommendationsAsync(sessionId); Assert.NotEmpty(getRecommendationOutput.Recommendations); var fargateRecommendation = getRecommendationOutput.Recommendations.FirstOrDefault(x => string.Equals(x.RecipeId, "AspNetAppEcsFargate")); Assert.NotNull(fargateRecommendation); await restClient.SetDeploymentTargetAsync(sessionId, new SetDeploymentTargetInput { NewDeploymentName = _stackName, NewDeploymentRecipeId = fargateRecommendation.RecipeId }); await restClient.StartDeploymentAsync(sessionId); await WaitForDeployment(restClient, sessionId); var stackStatus = await _cloudFormationHelper.GetStackStatus(_stackName); Assert.Equal(StackStatus.CREATE_COMPLETE, stackStatus); Assert.True(logOutput.Length > 0); Assert.Contains("Initiating deployment", logOutput.ToString()); } finally { cancelSource.Cancel(); await _cloudFormationHelper.DeleteStack(_stackName); _stackName = null; } }