Skip to content

Commit ff86c9c

Browse files
authored
Merge pull request #840 from aws/dev
chore: release 1.21
2 parents c512b3c + 5b1c4c2 commit ff86c9c

File tree

44 files changed

+1284
-205
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1284
-205
lines changed

THIRD_PARTY_LICENSES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
** AWSSDK.ElasticLoadBalancingV2; version 3.7.302.33 -- https://www.nuget.org/packages/AWSSDK.ElasticLoadBalancingV2/
2222
** AWSSDK.Core; version 3.7.303.20 -- https://www.nuget.org/packages/AWSSDK.Core
2323
** AWSSDK.CloudWatchLogs; version 3.7.305.18 -- https://www.nuget.org/packages/AWSSDK.CloudWatchLogs
24-
** Amazon.CDK.Lib; version 2.131.0 -- https://www.nuget.org/packages/Amazon.CDK.Lib/
24+
** Amazon.CDK.Lib; version 2.146.0 -- https://www.nuget.org/packages/Amazon.CDK.Lib/
2525

2626
Apache License
2727
Version 2.0, January 2004

site/content/docs/cicd/recipes/ASP.NET Core App to AWS Elastic Beanstalk on Linux.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
* ID: LoadBalancerType
4343
* Description: The type of load balancer for your environment.
4444
* Type: String
45+
* **Load Balancer Scheme**
46+
* ID: LoadBalancerScheme
47+
* Description: Specify "Internal" if your application serves requests only from connected VPCs. "Public" load balancers serve requests from the Internet.
48+
* Type: String
4549
* **Application IAM Role**
4650
* ID: ApplicationIAMRole
4751
* Description: The Identity and Access Management (IAM) role that provides AWS credentials to the application to access AWS services.

site/content/docs/cicd/recipes/ASP.NET Core App to AWS Elastic Beanstalk on Windows.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
* ID: LoadBalancerType
3838
* Description: The type of load balancer for your environment.
3939
* Type: String
40+
* **Load Balancer Scheme**
41+
* ID: LoadBalancerScheme
42+
* Description: Specify "Internal" if your application serves requests only from connected VPCs. "Public" load balancers serve requests from the Internet.
43+
* Type: String
4044
* **Application IAM Role**
4145
* ID: ApplicationIAMRole
4246
* Description: The Identity and Access Management (IAM) role that provides AWS credentials to the application to access AWS services.

src/AWS.Deploy.CLI/App.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private static void SetExecutionEnvironment(string[] args)
7373
Environment.SetEnvironmentVariable(envName, envValue.ToString());
7474
}
7575

76-
private static string GetToolVersion()
76+
internal static string GetToolVersion()
7777
{
7878
var assembly = typeof(App).GetTypeInfo().Assembly;
7979
var version = assembly.GetCustomAttribute<AssemblyFileVersionAttribute>()?.Version;

src/AWS.Deploy.CLI/Commands/CommandFactory.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,16 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
using System;
5-
using System.Collections;
65
using System.CommandLine;
76
using System.CommandLine.Invocation;
87
using System.IO;
9-
using System.Collections.Generic;
10-
using System.Diagnostics;
11-
using System.Runtime.InteropServices;
128
using Amazon;
139
using AWS.Deploy.CLI.Commands.TypeHints;
1410
using AWS.Deploy.CLI.Utilities;
1511
using AWS.Deploy.Common;
1612
using AWS.Deploy.Common.Extensions;
1713
using AWS.Deploy.Orchestration;
1814
using AWS.Deploy.Orchestration.CDK;
19-
using AWS.Deploy.Orchestration.Data;
2015
using AWS.Deploy.Orchestration.Utilities;
2116
using AWS.Deploy.CLI.Commands.CommandHandlerInput;
2217
using AWS.Deploy.Common.IO;
@@ -37,6 +32,7 @@ public interface ICommandFactory
3732

3833
public class CommandFactory : ICommandFactory
3934
{
35+
private static readonly Option<bool> _optionVersion = new(new[] { "-v", "--version" }, "Show version information");
4036
private static readonly Option<string> _optionProfile = new("--profile", "AWS credential profile used to make calls to AWS.");
4137
private static readonly Option<string> _optionRegion = new("--region", "AWS region to deploy the application to. For example, us-west-2.");
4238
private static readonly Option<string> _optionProjectPath = new("--project-path", () => Directory.GetCurrentDirectory(), "Path to the project to deploy.");
@@ -156,13 +152,23 @@ public Command BuildRootCommand()
156152

157153
lock(s_root_command_lock)
158154
{
155+
rootCommand.AddOption(_optionVersion);
159156
rootCommand.Add(BuildDeployCommand());
160157
rootCommand.Add(BuildListCommand());
161158
rootCommand.Add(BuildDeleteCommand());
162159
rootCommand.Add(BuildDeploymentProjectCommand());
163160
rootCommand.Add(BuildServerModeCommand());
164161
}
165162

163+
rootCommand.Handler = CommandHandler.Create((bool version) =>
164+
{
165+
if (version)
166+
{
167+
var toolVersion = App.GetToolVersion();
168+
_toolInteractiveService.WriteLine($"Version: {toolVersion}");
169+
}
170+
});
171+
166172
return rootCommand;
167173
}
168174

src/AWS.Deploy.CLI/Commands/DeployCommand.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ public async Task ExecuteAsync(string applicationName, string deploymentProjectP
128128
return;
129129
}
130130

131+
// Because we're starting a deployment, clear the cached system capabilities checks
132+
// in case the deployment fails and the user reruns it after modifying Docker or Node
133+
_systemCapabilityEvaluator.ClearCachedCapabilityChecks();
134+
131135
await CreateDeploymentBundle(orchestrator, selectedRecommendation, cloudApplication);
132136

133137
if (saveSettingsConfig.SettingsType != SaveSettingsType.None)
@@ -282,14 +286,14 @@ private void DisplayOutputResources(List<DisplayedResourceItem> displayedResourc
282286
/// <param name="selectedRecommendation">The selected recommendation settings used for deployment.<see cref="Recommendation"/></param>
283287
public async Task EvaluateSystemCapabilities(Recommendation selectedRecommendation)
284288
{
285-
var systemCapabilities = await _systemCapabilityEvaluator.EvaluateSystemCapabilities(selectedRecommendation);
289+
var missingSystemCapabilities = await _systemCapabilityEvaluator.EvaluateSystemCapabilities(selectedRecommendation);
286290
var missingCapabilitiesMessage = "";
287-
foreach (var capability in systemCapabilities)
291+
foreach (var capability in missingSystemCapabilities)
288292
{
289293
missingCapabilitiesMessage = $"{missingCapabilitiesMessage}{Environment.NewLine}{capability.GetMessage()}{Environment.NewLine}";
290294
}
291295

292-
if (systemCapabilities.Any())
296+
if (missingSystemCapabilities.Any())
293297
throw new MissingSystemCapabilityException(DeployToolErrorCode.MissingSystemCapabilities, missingCapabilitiesMessage);
294298
}
295299

src/AWS.Deploy.CLI/ServerMode/Controllers/DeploymentController.cs

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,18 @@ public async Task<IActionResult> StartDeploymentSession(StartDeploymentSessionIn
7474
Guid.NewGuid().ToString()
7575
);
7676

77-
var serviceProvider = CreateSessionServiceProvider(output.SessionId, input.AWSRegion);
78-
var awsResourceQueryer = serviceProvider.GetRequiredService<IAWSResourceQueryer>();
79-
8077
var state = new SessionState(
8178
output.SessionId,
8279
input.ProjectPath,
8380
input.AWSRegion,
84-
(await awsResourceQueryer.GetCallerIdentity(input.AWSRegion)).Account,
8581
await _projectParserUtility.Parse(input.ProjectPath)
8682
);
8783

84+
var serviceProvider = CreateSessionServiceProvider(state);
85+
var awsResourceQueryer = serviceProvider.GetRequiredService<IAWSResourceQueryer>();
86+
87+
state.AWSAccountId = (await awsResourceQueryer.GetCallerIdentity(input.AWSRegion)).Account;
88+
8889
_stateServer.Save(output.SessionId, state);
8990

9091
var deployedApplicationQueryer = serviceProvider.GetRequiredService<IDeployedApplicationQueryer>();
@@ -581,6 +582,10 @@ public async Task<IActionResult> StartDeployment(string sessionId)
581582
if (capabilities.Any())
582583
return Problem($"Unable to start deployment due to missing system capabilities.{Environment.NewLine}{missingCapabilitiesMessage}", statusCode: Microsoft.AspNetCore.Http.StatusCodes.Status424FailedDependency);
583584

585+
// Because we're starting a deployment, clear the cached system capabilities checks
586+
// in case the deployment fails and the user reruns it after modifying Docker or Node
587+
systemCapabilityEvaluator.ClearCachedCapabilityChecks();
588+
584589
var task = new DeployRecommendationTask(orchestratorSession, orchestrator, state.ApplicationDetails, state.SelectedRecommendation);
585590
state.DeploymentTask = task.Execute();
586591

@@ -668,28 +673,41 @@ public async Task<IActionResult> GetDeploymentDetails(string sessionId)
668673
}
669674

670675
private IServiceProvider CreateSessionServiceProvider(SessionState state)
671-
{
672-
return CreateSessionServiceProvider(state.SessionId, state.AWSRegion);
673-
}
674-
675-
private IServiceProvider CreateSessionServiceProvider(string sessionId, string awsRegion)
676676
{
677677
var awsCredentials = HttpContext.User.ToAWSCredentials();
678678
if(awsCredentials == null)
679679
{
680680
throw new FailedToRetrieveAWSCredentialsException("AWS credentials are missing for the current session.");
681681
}
682682

683-
var interactiveServices = new SessionOrchestratorInteractiveService(sessionId, _hubContext);
683+
var interactiveServices = new SessionOrchestratorInteractiveService(state.SessionId, _hubContext);
684684
var services = new ServiceCollection();
685685
services.AddSingleton<IOrchestratorInteractiveService>(interactiveServices);
686686
services.AddSingleton<ICommandLineWrapper>(services =>
687687
{
688688
var wrapper = new CommandLineWrapper(interactiveServices, true);
689-
wrapper.RegisterAWSContext(awsCredentials, awsRegion);
689+
wrapper.RegisterAWSContext(awsCredentials, state.AWSRegion);
690690
return wrapper;
691691
});
692692

693+
if (state.AWSResourceQueryService == null)
694+
{
695+
services.AddSingleton<IAWSResourceQueryer, SessionAWSResourceQuery>();
696+
}
697+
else
698+
{
699+
services.AddSingleton<IAWSResourceQueryer>(state.AWSResourceQueryService);
700+
}
701+
702+
if (state.SystemCapabilityEvaluator == null)
703+
{
704+
services.AddSingleton<ISystemCapabilityEvaluator, SystemCapabilityEvaluator>();
705+
}
706+
else
707+
{
708+
services.AddSingleton<ISystemCapabilityEvaluator>(state.SystemCapabilityEvaluator);
709+
}
710+
693711
services.AddCustomServices();
694712
var serviceProvider = services.BuildServiceProvider();
695713

@@ -698,9 +716,15 @@ private IServiceProvider CreateSessionServiceProvider(string sessionId, string a
698716
awsClientFactory.ConfigureAWSOptions(awsOptions =>
699717
{
700718
awsOptions.Credentials = awsCredentials;
701-
awsOptions.Region = RegionEndpoint.GetBySystemName(awsRegion);
719+
awsOptions.Region = RegionEndpoint.GetBySystemName(state.AWSRegion);
702720
});
703721

722+
// Cache the SessionAWSResourceQuery and SystemCapabilityEvaluator with the session state
723+
// so they can be reused in future ServerMode API calls with the same session id. This avoids reloading
724+
// existing resources from AWS and running the Docker/Node checks when they're not expected to change.
725+
state.AWSResourceQueryService = serviceProvider.GetRequiredService<IAWSResourceQueryer>() as SessionAWSResourceQuery;
726+
state.SystemCapabilityEvaluator = serviceProvider.GetRequiredService<ISystemCapabilityEvaluator>() as SystemCapabilityEvaluator;
727+
704728
return serviceProvider;
705729
}
706730

0 commit comments

Comments
 (0)