Skip to content

Commit 3bc852c

Browse files
authored
Merge pull request #698 from aws/dev
chore: release 1.3
2 parents 66fb1e3 + e873dae commit 3bc852c

41 files changed

Lines changed: 1059 additions & 90 deletions

Some content is hidden

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

THIRD_PARTY_LICENSES

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
** Amazon.JSII.Runtime; version 1.54.0 -- https://www.nuget.org/packages/Amazon.JSII.Runtime
2222
** AWSSDK.CloudControlApi; version 3.7.2 -- https://www.nuget.org/packages/AWSSDK.CloudControlApi/
2323
** AWSSDK.SimpleSystemsManagement; version 3.7.16 -- https://www.nuget.org/packages/AWSSDK.SimpleSystemsManagement/
24+
** AWSSDK.SSO; version 3.7.0.201 -- https://www.nuget.org/packages/AWSSDK.SSO
25+
** AWSSDK.SSOOIDC; version 3.7.1.4 -- https://www.nuget.org/packages/AWSSDK.SSOOIDC
2426

2527
Apache License
2628
Version 2.0, January 2004
@@ -253,6 +255,10 @@ limitations under the License.
253255
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
254256
* For AWSSDK.SimpleSystemsManagement see also this required NOTICE:
255257
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
258+
* For AWSSDK.SSO see also this required NOTICE:
259+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
260+
* For AWSSDK.SSOOIDC see also this required NOTICE:
261+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
256262

257263
------
258264

@@ -334,8 +340,6 @@ Copyright (c) 2016 .NET Foundation
334340
Copyright (c) 2016 .NET Foundation
335341
** Microsoft.Extensions.Configuration.Json; version 3.1.7 -- https://www.nuget.org/packages/Microsoft.Bcl.AsyncInterhttps://www.nuget.org/packages/Microsoft.Extensions.Configuration.Jsonfaces
336342
Copyright (c) .NET Foundation and Contributors
337-
** System.Text.Json; version 6.0.4 -- https://www.nuget.org/packages/System.Text.Json
338-
Copyright (c) .NET Foundation and Contributors
339343
** Microsoft.Extensions.DependencyInjection; version 6.0.0 -- https://www.nuget.org/packages/Microsoft.Extensions.DependencyInjection
340344
Copyright (c) .NET Foundation and Contributors
341345
** Microsoft.Extensions.DependencyInjection.Abstractions; version 6.0.0 -- https://www.nuget.org/packages/Microsoft.Extensions.DependencyInjection.Abstractions
@@ -344,7 +348,9 @@ Copyright (c) .NET Foundation and Contributors
344348
Copyright (c) .NET Foundation and Contributors
345349
** Microsoft.OpenApi; version 1.2.3 -- https://www.nuget.org/packages/Microsoft.OpenApi/
346350
Copyright (c) Microsoft Corporation.
347-
351+
** System.Text.Json; version 6.0.4 -- https://www.nuget.org/packages/System.Text.Json
352+
Copyright (c) .NET Foundation and Contributors
353+
348354
All rights reserved.
349355

350356
Permission is hereby granted, free of charge, to any person obtaining a copy

site/content/docs/cicd.md

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,68 @@ To turn off the interactive features, use the `-s (--silent)` switch. This will
88

99
dotnet aws deploy --silent
1010

11-
### Creating a deployment setting file
11+
### Creating a deployment settings file
1212

13-
To specify the services to deploy and their configurations for your environment, you need to create deployment settings file. The deployment settings file is a JSON configuration file that contains all of the settings that the deployment tool uses to drive the experience. Here is the [JSON file definition](https://github.com/aws/aws-dotnet-deploy/tree/main/src/AWS.Deploy.Recipes/RecipeDefinitions).
13+
You can persist the deployment configuration to a JSON file using the `--save-settings <SETTINGS_FILE_PATH)>` switch. This JSON file can be version controlled and plugged into your CI/CD system for future deployments.
1414

15-
Storing deployment settings in a JSON file also allows those settings to be version controlled.
15+
**Note** - The `--save-settings` switch will only persist settings that have been modified (which means they hold a non-default value). To persist all settings use the `--save-all-settings` switch.
16+
17+
```
18+
dotnet aws deploy --project-path <PROJECT_PATH> [--save-settings|--save-all-settings] <SETTINGS_FILE_PATH>
19+
```
20+
21+
**Note** - The `SETTINGS_FILE_PATH` can be an absolute path or relative to the `PROJECT_PATH`.
22+
23+
Here's an example of a web application with the following directory structure:
24+
25+
MyWebApplication/
26+
┣ MyClassLibrary/
27+
┃ ┣ Class1.cs
28+
┃ ┗ MyClassLibrary.csproj
29+
┣ MyWebApplication/
30+
┃ ┣ Controllers/
31+
┃ ┃ ┗ WeatherForecastController.cs
32+
┃ ┣ appsettings.Development.json
33+
┃ ┣ appsettings.json
34+
┃ ┣ Dockerfile
35+
┃ ┣ MyWebApplication.csproj
36+
┃ ┣ Program.cs
37+
┃ ┣ WeatherForecast.cs
38+
┗ MyWebApplication.sln
39+
40+
To perform a deployment and also persist the deployment configuration to a JSON file, use the following command:
41+
```
42+
dotnet aws deploy --project-path MyWebApplication/MyWebApplication/MyWebApplication.csproj --save-settings deploymentsettings.json
43+
```
44+
45+
This will create a JSON file at `MyWebApplication/MyWebApplication/deploymentsettings.json` with the following structure:
46+
```
47+
{
48+
"AWSProfile": <AWS_PROFILE>
49+
"AWSRegion": <AWS_REGION>,
50+
"ApplicationName": <APPLICATION_NAME>,
51+
"RecipeId": <RECIPE_ID>
52+
"Settings": <JSON_BLOB>
53+
}
54+
55+
```
56+
* _**AWSProfile**_: The name of the AWS profile that was used during deployment.
57+
58+
* _**AWSRegion**_: The name of the AWS region where the deployed application is hosted.
59+
60+
* _**ApplicationName**_: The name that is used to identify your cloud application within AWS. If the application is deployed via AWS CDK, then this name points to the CloudFormation stack.
61+
62+
* _**RecipeId**_: The recipe identifier that was used to deploy your application to AWS.
63+
64+
* _**Settings**_: This is a JSON blob that stores the values of all available settings that can be tweaked to adjust the deployment configuration.
1665

1766
### Invoking from CI/CD
1867

19-
The `--apply` switch on deploy command allows you to specify a deployment settings file.
68+
The `--apply` switch on the deploy command allows you to specify a deployment settings file.
2069

21-
Deployment settings file path is always relative to the `--project-path`. Here's an example of a web application with the following directory structure:
70+
```
71+
dotnet aws deploy --project-path <PROJECT_PATH> --apply <SETTINGS_FILE_PATH>
72+
```
2273

2374
MyWebApplication/
2475
┣ MyClassLibrary/
@@ -36,7 +87,9 @@ Deployment settings file path is always relative to the `--project-path`. Here's
3687
┃ ┗ WeatherForecast.cs
3788
┗ MyWebApplication.sln
3889

39-
To deploy the application with above directory structure in CI/CD pipeline without any prompts, use the following command:
90+
To deploy the application with the above directory structure in CI/CD pipeline without any prompts, use the following command:
4091

4192
dotnet aws deploy --silent --project-path MyWebApplication/MyWebApplication/MyWebApplication.csproj --apply deploymentsettings.json
4293

94+
95+

site/content/docs/commands/deploy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
dotnet aws deploy - Inspect, build, and deploy the .NET project to AWS using the chosen AWS compute.
55

66
### Synopsis
7-
dotnet aws deploy [-d|—-diagnostics] [-s|--silent] [--profile <PROFILE>] [--region <REGION>] [--project-path <PROJECT-PATH>] [--application-name <CLOUD-APPLICATION-NAME>] [--apply <PATH-TO-DEPLOYMENT-SETTINGS>] [--deployment-project <CDK-DEPLOYMENT-PROJECT-PATH>] [-?|-h|--help]
7+
dotnet aws deploy [-d|—-diagnostics] [-s|--silent] [--profile <PROFILE>] [--region <REGION>] [--project-path <PROJECT-PATH>] [[--save-settings|--save-all-settings] <SETTINGS-FILE-PATH>] [--application-name <CLOUD-APPLICATION-NAME>] [--apply <PATH-TO-DEPLOYMENT-SETTINGS>] [--deployment-project <CDK-DEPLOYMENT-PROJECT-PATH>] [-?|-h|--help]
88

99
### Description
1010
Inspects the project and recommends AWS compute that is most suited to the type of deployed application. Then builds the project, generates a deployment CDK project to provision the required infrastructure, and deploys the .NET project to AWS using the chosen AWS compute.

site/content/docs/getting-started/setup-creds.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ The following are some examples of the typical permissions that are required.
1010
1111
|Command| Task | Recommended AWS Managed Policies |
1212
| --- | --- |--- |
13-
|deploy | Deploying to Amazon ECS | AWSCloudFormationFullAccess, AmazonECS_FullAccess, AmazonEC2ContainerRegistryFullAccess, IAMFullAccess |
14-
|deploy | Deploying to AWS App Runner| AWSCloudFormationFullAccess, AWSAppRunnerFullAccess, AmazonEC2ContainerRegistryFullAccess, IAMFullAccess|
15-
|deploy | Deploying to Elastic Beanstalk (deploy) | AWSCloudFormationFullAccess, AdministratorAccess-AWSElasticBeanstalk', AmazonS3FullAccess (*required to upload the application bundle*), IAMFullAccess |
16-
|deploy | Hosting WebAssembly Blazor App in S3 & CloudFront | AmazonS3FullAccess, CloudFrontFullAccess, IAMFullAccess, AWSLambda_FullAccess (*required to copy from CDKBootstrap bucket to S3 bucket*)|
13+
|deploy | Deploying to Amazon ECS | AWSCloudFormationFullAccess, AmazonECS_FullAccess, AmazonEC2ContainerRegistryFullAccess, AmazonSSMFullAccess, IAMFullAccess |
14+
|deploy | Deploying to AWS App Runner| AWSCloudFormationFullAccess, AWSAppRunnerFullAccess, AmazonEC2ContainerRegistryFullAccess, AmazonSSMFullAccess, IAMFullAccess|
15+
|deploy | Deploying to Elastic Beanstalk (deploy) | AWSCloudFormationFullAccess, AdministratorAccess-AWSElasticBeanstalk, AmazonSSMFullAccess, AmazonS3FullAccess (*required to upload the application bundle*), IAMFullAccess |
16+
|deploy | Hosting WebAssembly Blazor App in S3 & CloudFront | AmazonS3FullAccess, CloudFrontFullAccess, IAMFullAccess, AmazonSSMFullAccess, AWSLambda_FullAccess (*required to copy from CDKBootstrap bucket to S3 bucket*)|
1717
| list-deployments | List CF stacks| AWSCloudFormationReadOnlyAccess |
1818
| delete-deployment | Delete a CF stack | AWSCloudFormationFullAccess + permissions for resources being deleted |
1919

site/content/troubleshooting-guide/index.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,13 @@ StagingBucket cdk-hnb659fds-assets-123456789101-us-west-2 already exists
9696
```
9797

9898
**Resolution**: Open the AWS Console, go to S3 service, and manually delete the 'CDKToolkit' S3 bucket. Once the bucket is deleted, go ahead and deploy your application.
99+
100+
## MemorySize Constraint for Blazor WebAssembly
101+
When attempting to deploy using the Blazor WebAssembly App recipe, you may see a deployment failure such as:
102+
```
103+
Resource handler returned message: "'MemorySize' value failed to satisfy constraint: Member must have value less than or equal to 3008
104+
```
105+
106+
**Why this is happening:** The [BucketDeployment](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3_deployment.BucketDeployment.html) CDK Construct used to deploy the Blazor recipe uses an AWS Lambda function to replicate the application files from the CDK bucket to the deployment bucket. In some versions of the deploy tool the default memory limit for this Lambda function exceeded the 3008MB quota placed on new AWS accounts.
107+
108+
**Resolution:** See [Lambda: Concurrency and memory quotas](https://docs.aws.amazon.com/lambda/latest/dg/troubleshooting-deployment.html#troubleshooting-deployment-quotas) for how to request a quota increase.

src/AWS.Deploy.CLI/AWS.Deploy.CLI.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
<PackageReference Include="AWSSDK.IdentityManagement" Version="3.7.2.25" />
2525
<PackageReference Include="AWSSDK.CloudFormation" Version="3.7.7.14" />
2626
<PackageReference Include="AWSSDK.SecurityToken" Version="3.7.1.35" />
27+
<PackageReference Include="AWSSDK.SSO" Version="3.7.0.201" />
28+
<PackageReference Include="AWSSDK.SSOOIDC" Version="3.7.1.4" />
2729
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.1.2" />
2830
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.1.2" />
2931
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20574.7" />

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public class CommandFactory : ICommandFactory
4747
private static readonly Option<string> _optionOutputDirectory = new(new[] { "-o", "--output" }, "Directory path in which the CDK deployment project will be saved.");
4848
private static readonly Option<string> _optionProjectDisplayName = new(new[] { "--project-display-name" }, "The name of the deployment project that will be displayed in the list of available deployment options.");
4949
private static readonly Option<string> _optionDeploymentProject = new(new[] { "--deployment-project" }, "The absolute or relative path of the CDK project that will be used for deployment");
50+
private static readonly Option<string> _optionSaveSettings = new(new[] { "--save-settings" }, "The absolute or the relative JSON file path where the deployment settings will be saved. Only the settings modified by the user will be persisted");
51+
private static readonly Option<string> _optionSaveAllSettings = new(new[] { "--save-all-settings" }, "The absolute or the relative JSON file path where the deployment settings will be saved. All deployment settings will be persisted");
5052
private static readonly object s_root_command_lock = new();
5153
private static readonly object s_child_command_lock = new();
5254

@@ -180,6 +182,8 @@ private Command BuildDeployCommand()
180182
deployCommand.Add(_optionDiagnosticLogging);
181183
deployCommand.Add(_optionDisableInteractive);
182184
deployCommand.Add(_optionDeploymentProject);
185+
deployCommand.Add(_optionSaveSettings);
186+
deployCommand.Add(_optionSaveAllSettings);
183187
}
184188

185189
deployCommand.Handler = CommandHandler.Create(async (DeployCommandHandlerInput input) =>
@@ -252,7 +256,9 @@ private Command BuildDeployCommand()
252256
deploymentProjectPath = Path.GetFullPath(deploymentProjectPath, targetApplicationDirectoryPath);
253257
}
254258

255-
await deploy.ExecuteAsync(input.ApplicationName ?? string.Empty, deploymentProjectPath, deploymentSettings);
259+
var saveSettingsConfig = Helpers.GetSaveSettingsConfiguration(input.SaveSettings, input.SaveAllSettings, targetApplicationDirectoryPath, _fileManager);
260+
261+
await deploy.ExecuteAsync(input.ApplicationName ?? string.Empty, deploymentProjectPath, saveSettingsConfig, deploymentSettings);
256262

257263
return CommandReturnCodes.SUCCESS;
258264
}

src/AWS.Deploy.CLI/Commands/CommandHandlerInput/DeployCommandHandlerInput.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,54 @@ namespace AWS.Deploy.CLI.Commands.CommandHandlerInput
1010
{
1111
public class DeployCommandHandlerInput
1212
{
13+
/// <summary>
14+
/// AWS credential profile used to make calls to AWS.
15+
/// </summary>
1316
public string? Profile { get; set; }
17+
18+
/// <summary>
19+
/// AWS region to deploy the application to. For example, us-west-2.
20+
/// </summary>
1421
public string? Region { get; set; }
22+
23+
/// <summary>
24+
/// Path to the project to deploy.
25+
/// </summary>
1526
public string? ProjectPath { get; set; }
27+
28+
/// <summary>
29+
/// Name of the cloud application.
30+
/// </summary>
1631
public string? ApplicationName { get; set; }
32+
33+
/// <summary>
34+
/// Path to the deployment settings file to be applied.
35+
/// </summary>
1736
public string? Apply { get; set; }
37+
38+
/// <summary>
39+
/// Flag to enable diagnostic output.
40+
/// </summary>
1841
public bool Diagnostics { get; set; }
42+
43+
/// <summary>
44+
/// Flag to disable interactivity to execute commands without any prompts.
45+
/// </summary>
1946
public bool Silent { get; set; }
47+
48+
/// <summary>
49+
/// The absolute or relative path of the CDK project that will be used for deployment.
50+
/// </summary>
2051
public string? DeploymentProject { get; set; }
52+
53+
/// <summary>
54+
/// The absolute or the relative JSON file path where the deployment settings will be saved. Only the settings modified by the user are persisted.
55+
/// </summary>
56+
public string? SaveSettings { get; set; }
57+
58+
/// <summary>
59+
/// The absolute or the relative JSON file path where the deployment settings will be saved. All deployment settings are persisted.
60+
/// </summary>
61+
public string? SaveAllSettings { get; set; }
2162
}
2263
}

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

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public DeployCommand(
113113
_deploymentSettingsHandler = deploymentSettingsHandler;
114114
}
115115

116-
public async Task ExecuteAsync(string applicationName, string deploymentProjectPath, DeploymentSettings? deploymentSettings = null)
116+
public async Task ExecuteAsync(string applicationName, string deploymentProjectPath, SaveSettingsConfiguration saveSettingsConfig, DeploymentSettings? deploymentSettings = null)
117117
{
118118
var (orchestrator, selectedRecommendation, cloudApplication) = await InitializeDeployment(applicationName, deploymentSettings, deploymentProjectPath);
119119

@@ -130,6 +130,12 @@ public async Task ExecuteAsync(string applicationName, string deploymentProjectP
130130

131131
await CreateDeploymentBundle(orchestrator, selectedRecommendation, cloudApplication);
132132

133+
if (saveSettingsConfig.SettingsType != SaveSettingsType.None)
134+
{
135+
await _deploymentSettingsHandler.SaveSettings(saveSettingsConfig, selectedRecommendation, cloudApplication, _session);
136+
_toolInteractiveService.WriteLine($"{Environment.NewLine}Successfully saved the deployment settings at {saveSettingsConfig.FilePath}");
137+
}
138+
133139
await orchestrator.DeployRecommendation(cloudApplication, selectedRecommendation);
134140

135141
var displayedResources = await _displayedResourcesHandler.GetDeploymentOutputs(cloudApplication, selectedRecommendation);
@@ -193,11 +199,27 @@ private void DisplayOutputResources(List<DisplayedResourceItem> displayedResourc
193199
cloudApplicationName = deploymentSettings?.ApplicationName ?? string.Empty;
194200

195201
// Prompt the user with a choice to re-deploy to existing targets or deploy to a new cloud application.
196-
if (string.IsNullOrEmpty(cloudApplicationName))
202+
// This prompt is NOT needed if the user is just pushing the docker image to ECR.
203+
if (string.IsNullOrEmpty(cloudApplicationName) && !string.Equals(deploymentSettings?.RecipeId, Constants.RecipeIdentifier.PUSH_TO_ECR_RECIPE_ID))
197204
cloudApplicationName = AskForCloudApplicationNameFromDeployedApplications(compatibleApplications);
198205

199206
// Find existing application with the same CloudApplication name.
200-
var deployedApplication = allDeployedApplications.FirstOrDefault(x => string.Equals(x.Name, cloudApplicationName));
207+
CloudApplication? deployedApplication = null;
208+
if (!string.IsNullOrEmpty(deploymentSettings?.RecipeId))
209+
{
210+
// if the recommendation is specified via a config file then find the deployed application by matching the deployment type along with the cloudApplicationName
211+
var recommendation = recommendations.FirstOrDefault(x => string.Equals(x.Recipe.Id, deploymentSettings.RecipeId));
212+
if (recommendation == null)
213+
{
214+
var errorMsg = "The recipe ID specified in the deployment settings file does not match any compatible deployment recipes.";
215+
throw new InvalidDeploymentSettingsException(DeployToolErrorCode.DeploymentConfigurationNeedsAdjusting, errorMsg);
216+
}
217+
deployedApplication = allDeployedApplications.FirstOrDefault(x => string.Equals(x.Name, cloudApplicationName) && x.DeploymentType == recommendation.Recipe.DeploymentType);
218+
}
219+
else
220+
{
221+
deployedApplication = allDeployedApplications.FirstOrDefault(x => string.Equals(x.Name, cloudApplicationName));
222+
}
201223

202224
Recommendation? selectedRecommendation = null;
203225
if (deployedApplication != null)

0 commit comments

Comments
 (0)