diff --git a/src/AWS.Deploy.CLI/Commands/GenerateDeploymentProjectCommand.cs b/src/AWS.Deploy.CLI/Commands/GenerateDeploymentProjectCommand.cs index bccd4641f..1b68391f5 100644 --- a/src/AWS.Deploy.CLI/Commands/GenerateDeploymentProjectCommand.cs +++ b/src/AWS.Deploy.CLI/Commands/GenerateDeploymentProjectCommand.cs @@ -107,7 +107,7 @@ public async Task ExecuteAsync(string saveCdkDirectoryPath, string projectDispla var saveCdkDirectoryFullPath = _directoryManager.GetDirectoryInfo(saveCdkDirectoryPath).FullName; _toolInteractiveService.WriteLine(); - _toolInteractiveService.WriteLine($"The CDK deployment project is saved at: {saveCdkDirectoryFullPath}"); + _toolInteractiveService.WriteLine($"Saving AWS CDK deployment project to: {saveCdkDirectoryFullPath}"); await _deploymentManifestEngine.UpdateDeploymentManifestFile(saveCdkDirectoryFullPath, _targetApplicationFullPath); } diff --git a/src/AWS.Deploy.Orchestration/CdkProjectHandler.cs b/src/AWS.Deploy.Orchestration/CdkProjectHandler.cs index 6c6196f69..b8a7f680c 100644 --- a/src/AWS.Deploy.Orchestration/CdkProjectHandler.cs +++ b/src/AWS.Deploy.Orchestration/CdkProjectHandler.cs @@ -48,7 +48,7 @@ public async Task ConfigureCdkProject(OrchestratorSession session, Cloud else { // Create a new temporary CDK project for a new deployment - _interactiveService.LogMessageLine($"Generating a {recommendation.Recipe.Name} CDK Project"); + _interactiveService.LogMessageLine("Generating AWS Cloud Development Kit (AWS CDK) deployment project"); cdkProjectPath = CreateCdkProject(recommendation, session); } @@ -69,7 +69,7 @@ public async Task DeployCdkProject(OrchestratorSession session, string cdkProjec { EnvironmentVariableKeys.AWS_EXECUTION_ENV, recipeInfo } }; - _interactiveService.LogMessageLine("Starting deployment of CDK Project"); + _interactiveService.LogMessageLine("Deploying AWS CDK project"); // Ensure region is bootstrapped await _commandLineWrapper.Run($"npx cdk bootstrap aws://{session.AWSAccountId}/{session.AWSRegion}", @@ -115,7 +115,7 @@ public string CreateCdkProject(Recommendation recommendation, OrchestratorSessio var templateEngine = new TemplateEngine(); templateEngine.GenerateCDKProjectFromTemplate(recommendation, session, saveCdkDirectoryPath, assemblyName); - _interactiveService.LogDebugLine($"The CDK Project is saved at: {saveCdkDirectoryPath}"); + _interactiveService.LogDebugLine($"Saving AWS CDK deployment project to: {saveCdkDirectoryPath}"); return saveCdkDirectoryPath; } diff --git a/src/AWS.Deploy.Orchestration/Orchestrator.cs b/src/AWS.Deploy.Orchestration/Orchestrator.cs index 5faadb96a..987446c7f 100644 --- a/src/AWS.Deploy.Orchestration/Orchestrator.cs +++ b/src/AWS.Deploy.Orchestration/Orchestrator.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Threading; using System.Threading.Tasks; using AWS.Deploy.Common; using AWS.Deploy.Common.IO; @@ -25,6 +26,7 @@ namespace AWS.Deploy.Orchestration /// public class Orchestrator { + private static readonly SemaphoreSlim s_cdkManagerSemaphoreSlim = new(1,1); private const string REPLACE_TOKEN_LATEST_DOTNET_BEANSTALK_PLATFORM_ARN = "{LatestDotnetBeanstalkPlatformArn}"; private readonly ICdkProjectHandler? _cdkProjectHandler; @@ -158,12 +160,22 @@ public async Task DeployRecommendation(CloudApplication cloudApplication, Recomm throw new InvalidOperationException($"{nameof(_directoryManager)} must not be null."); } + _interactiveService.LogMessageLine("Configuring AWS Cloud Development Kit (CDK)..."); var cdkProject = await _cdkProjectHandler.ConfigureCdkProject(_session, cloudApplication, recommendation); - _interactiveService.LogMessageLine("AWS CDK is being configured."); var projFiles = _directoryManager.GetProjFiles(cdkProject); var cdkVersion = _cdkVersionDetector.Detect(projFiles); - await _cdkManager.EnsureCompatibleCDKExists(Constants.CDK.DeployToolWorkspaceDirectoryRoot, cdkVersion); + + await s_cdkManagerSemaphoreSlim.WaitAsync(); + + try + { + await _cdkManager.EnsureCompatibleCDKExists(Constants.CDK.DeployToolWorkspaceDirectoryRoot, cdkVersion); + } + finally + { + s_cdkManagerSemaphoreSlim.Release(); + } try { diff --git a/test/AWS.Deploy.CLI.IntegrationTests/BlazorWasmTests.cs b/test/AWS.Deploy.CLI.IntegrationTests/BlazorWasmTests.cs index 612314737..183d58361 100644 --- a/test/AWS.Deploy.CLI.IntegrationTests/BlazorWasmTests.cs +++ b/test/AWS.Deploy.CLI.IntegrationTests/BlazorWasmTests.cs @@ -73,8 +73,8 @@ public async Task DefaultConfigurations(params string[] components) var deployStdOut = _interactiveService.StdOutReader.ReadAllLines(); - var tempCdkProjectLine = deployStdOut.First(line => line.StartsWith("The CDK Project is saved at:")); - var tempCdkProject = tempCdkProjectLine.Split(":")[1].Trim(); + var tempCdkProjectLine = deployStdOut.First(line => line.StartsWith("Saving AWS CDK deployment project to: ")); + var tempCdkProject = tempCdkProjectLine.Split(": ")[1].Trim(); Assert.False(Directory.Exists(tempCdkProject), $"{tempCdkProject} must not exist."); // Example URL string: BlazorWasm5068e7a879d5ee.EndpointURL = http://blazorwasm5068e7a879d5ee-blazorhostc7106839-a2585dcq9xve.s3-website-us-west-2.amazonaws.com/ diff --git a/test/AWS.Deploy.CLI.IntegrationTests/ConsoleAppTests.cs b/test/AWS.Deploy.CLI.IntegrationTests/ConsoleAppTests.cs index 718d2eae7..fc3f4fc6c 100644 --- a/test/AWS.Deploy.CLI.IntegrationTests/ConsoleAppTests.cs +++ b/test/AWS.Deploy.CLI.IntegrationTests/ConsoleAppTests.cs @@ -85,8 +85,8 @@ public async Task DefaultConfigurations(params string[] components) var deployStdOut = _interactiveService.StdOutReader.ReadAllLines(); - var tempCdkProjectLine = deployStdOut.First(line => line.StartsWith("The CDK Project is saved at:")); - var tempCdkProject = tempCdkProjectLine.Split(":")[1].Trim(); + var tempCdkProjectLine = deployStdOut.First(line => line.StartsWith("Saving AWS CDK deployment project to: ")); + var tempCdkProject = tempCdkProjectLine.Split(": ")[1].Trim(); Assert.False(Directory.Exists(tempCdkProject), $"{tempCdkProject} must not exist."); // list diff --git a/test/AWS.Deploy.CLI.IntegrationTests/SaveCdkDeploymentProject/Utilities.cs b/test/AWS.Deploy.CLI.IntegrationTests/SaveCdkDeploymentProject/Utilities.cs index 80976f61c..a53e52992 100644 --- a/test/AWS.Deploy.CLI.IntegrationTests/SaveCdkDeploymentProject/Utilities.cs +++ b/test/AWS.Deploy.CLI.IntegrationTests/SaveCdkDeploymentProject/Utilities.cs @@ -45,7 +45,7 @@ public static async Task CreateCDKDeploymentProject(string targetApplicationPath // Verify project is saved var stdOut = interactiveService.StdOutReader.ReadAllLines(); - var successMessage = $"The CDK deployment project is saved at: {saveDirectoryPath}"; + var successMessage = $"Saving AWS CDK deployment project to: {saveDirectoryPath}"; if (!isValid) { @@ -87,7 +87,7 @@ public static async Task CreateCDKDeploymentProjectWithRecipeName(string targetA // Verify project is saved var stdOut = interactiveService.StdOutReader.ReadAllLines(); - var successMessage = $"The CDK deployment project is saved at: {saveDirectoryPath}"; + var successMessage = $"Saving AWS CDK deployment project to: {saveDirectoryPath}"; if (!isValid) { diff --git a/test/AWS.Deploy.CLI.IntegrationTests/WebAppNoDockerFileTests.cs b/test/AWS.Deploy.CLI.IntegrationTests/WebAppNoDockerFileTests.cs index 19a3c96e7..a54dd7dc8 100644 --- a/test/AWS.Deploy.CLI.IntegrationTests/WebAppNoDockerFileTests.cs +++ b/test/AWS.Deploy.CLI.IntegrationTests/WebAppNoDockerFileTests.cs @@ -70,8 +70,8 @@ public async Task DefaultConfigurations() var deployStdOut = _interactiveService.StdOutReader.ReadAllLines(); - var tempCdkProjectLine = deployStdOut.First(line => line.StartsWith("The CDK Project is saved at:")); - var tempCdkProject = tempCdkProjectLine.Split(":")[1].Trim(); + var tempCdkProjectLine = deployStdOut.First(line => line.StartsWith("Saving AWS CDK deployment project to: ")); + var tempCdkProject = tempCdkProjectLine.Split(": ")[1].Trim(); Assert.False(Directory.Exists(tempCdkProject), $"{tempCdkProject} must not exist."); // Example: Endpoint: http://52.36.216.238/ diff --git a/test/AWS.Deploy.CLI.IntegrationTests/WebAppWithDockerFileTests.cs b/test/AWS.Deploy.CLI.IntegrationTests/WebAppWithDockerFileTests.cs index 7867d733a..dd72995b0 100644 --- a/test/AWS.Deploy.CLI.IntegrationTests/WebAppWithDockerFileTests.cs +++ b/test/AWS.Deploy.CLI.IntegrationTests/WebAppWithDockerFileTests.cs @@ -78,8 +78,8 @@ public async Task DefaultConfigurations() var deployStdOut = _interactiveService.StdOutReader.ReadAllLines(); - var tempCdkProjectLine = deployStdOut.First(line => line.StartsWith("The CDK Project is saved at:")); - var tempCdkProject = tempCdkProjectLine.Split(":")[1].Trim(); + var tempCdkProjectLine = deployStdOut.First(line => line.StartsWith("Saving AWS CDK deployment project to: ")); + var tempCdkProject = tempCdkProjectLine.Split(": ")[1].Trim(); Assert.False(Directory.Exists(tempCdkProject), $"{tempCdkProject} must not exist."); var applicationUrl = deployStdOut.First(line => line.Trim().StartsWith("Endpoint:"))