Skip to content

Commit

Permalink
Merge pull request #710 from aws/dev
Browse files Browse the repository at this point in the history
chore: release 1.4
  • Loading branch information
philasmar authored Sep 29, 2022
2 parents 3bc852c + 3cd1d58 commit 4f04da1
Show file tree
Hide file tree
Showing 74 changed files with 1,506 additions and 247 deletions.
1 change: 1 addition & 0 deletions .github/workflows/codebuild-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
role-duration-seconds: 7200
aws-region: us-west-2
- name: Run CodeBuild
id: codebuild
Expand Down
2 changes: 1 addition & 1 deletion THIRD_PARTY_LICENSES
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
** AWSSDK.IdentityManagement; version 3.7.2.25 -- https://www.nuget.org/packages/AWSSDK.IdentityManagement
** AWSSDK.SecurityToken; version 3.7.1.35 -- https://www.nuget.org/packages/AWSSDK.SecurityToken
** Constructs; version 10.0.0 -- https://www.nuget.org/packages/Constructs
** Amazon.CDK.Lib; version 2.13.0 -- https://www.nuget.org/packages/Amazon.CDK.Lib/
** Amazon.CDK.Lib; version 2.43.1 -- https://www.nuget.org/packages/Amazon.CDK.Lib/
** Amazon.JSII.Runtime; version 1.54.0 -- https://www.nuget.org/packages/Amazon.JSII.Runtime
** AWSSDK.CloudControlApi; version 3.7.2 -- https://www.nuget.org/packages/AWSSDK.CloudControlApi/
** AWSSDK.SimpleSystemsManagement; version 3.7.16 -- https://www.nuget.org/packages/AWSSDK.SimpleSystemsManagement/
Expand Down
1 change: 1 addition & 0 deletions buildtools/ci.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Resources:
BuildSpec: buildtools/ci.buildspec.yml
Artifacts:
Type: NO_ARTIFACTS
TimeoutInMinutes: 120

CodeBuildProjectRole:
Type: AWS::IAM::Role
Expand Down
10 changes: 10 additions & 0 deletions site/content/troubleshooting-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,13 @@ Resource handler returned message: "'MemorySize' value failed to satisfy constra
**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.

**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.

## App Runner Failed with _Resource handler returned message: "null"_
When attempting to deploy to App Runner, creation of the `AWS::AppRunner::Service` resource may fail with a message such as:
```
CREATE_FAILED | AWS::AppRunner::Service | Recipe/AppRunnerService (RecipeAppRunnerService) Resource handler returned message: "null"
```

**Why this is happening:** This error could happen for a variety of reasons, such as the application failing its initial health check or limited permissions.

**Resolution:** The resolution will depend on the failure reason. To aid diagnosis, attempt to deploy your application again. While it is deploying, navigate to the the Deployment and Application logs sections of _App Runner > Services > [name of your cloud application]_ in the AWS Console and review the logs for any unexpected errors. See [Viewing App Runner logs streamed to CloudWatch Logs](https://docs.aws.amazon.com/apprunner/latest/dg/monitor-cwl.html) for more details.
9 changes: 7 additions & 2 deletions src/AWS.Deploy.CLI/Commands/DeployCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,14 @@ private async Task<Recommendation> GetSelectedRecommendationFromPreviousDeployme

IDictionary<string, object> previousSettings;
if (deployedApplication.ResourceType == CloudApplicationResourceType.CloudFormationStack)
previousSettings = (await _cloudFormationTemplateReader.LoadCloudApplicationMetadata(deployedApplication.Name)).Settings;
{
var metadata = await _cloudFormationTemplateReader.LoadCloudApplicationMetadata(deployedApplication.Name);
previousSettings = metadata.Settings.Union(metadata.DeploymentBundleSettings).ToDictionary(x => x.Key, x => x.Value);
}
else
previousSettings = await _deployedApplicationQueryer.GetPreviousSettings(deployedApplication);
{
previousSettings = await _deployedApplicationQueryer.GetPreviousSettings(deployedApplication, selectedRecommendation);
}

await orchestrator.ApplyAllReplacementTokens(selectedRecommendation, deployedApplication.Name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public static void AddCustomServices(this IServiceCollection serviceCollection,
serviceCollection.TryAdd(new ServiceDescriptor(typeof(IAWSUtilities), typeof(AWSUtilities), lifetime));
serviceCollection.TryAdd(new ServiceDescriptor(typeof(ICDKInstaller), typeof(CDKInstaller), lifetime));
serviceCollection.TryAdd(new ServiceDescriptor(typeof(ICDKManager), typeof(CDKManager), lifetime));
serviceCollection.TryAdd(new ServiceDescriptor(typeof(ICdkAppSettingsSerializer), typeof(CdkAppSettingsSerializer), lifetime));
serviceCollection.TryAdd(new ServiceDescriptor(typeof(ICdkProjectHandler), typeof(CdkProjectHandler), lifetime));
serviceCollection.TryAdd(new ServiceDescriptor(typeof(ICloudApplicationNameGenerator), typeof(CloudApplicationNameGenerator), lifetime));
serviceCollection.TryAdd(new ServiceDescriptor(typeof(ICommandLineWrapper), typeof(CommandLineWrapper), lifetime));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,14 @@ public async Task<IActionResult> SetDeploymentTarget(string sessionId, [FromBody

IDictionary<string, object> previousSettings;
if (existingDeployment.ResourceType == CloudApplicationResourceType.CloudFormationStack)
previousSettings = (await templateMetadataReader.LoadCloudApplicationMetadata(existingDeployment.Name)).Settings;
{
var metadata = await templateMetadataReader.LoadCloudApplicationMetadata(existingDeployment.Name);
previousSettings = metadata.Settings.Union(metadata.DeploymentBundleSettings).ToDictionary(x => x.Key, x => x.Value);
}
else
previousSettings = await deployedApplicationQueryer.GetPreviousSettings(existingDeployment);
{
previousSettings = await deployedApplicationQueryer.GetPreviousSettings(existingDeployment, state.SelectedRecommendation);
}

state.SelectedRecommendation = await orchestrator.ApplyRecommendationPreviousSettings(state.SelectedRecommendation, previousSettings);

Expand Down Expand Up @@ -719,7 +724,9 @@ private CdkProjectHandler CreateCdkProjectHandler(SessionState state, IServicePr
serviceProvider.GetRequiredService<IOrchestratorInteractiveService>(),
serviceProvider.GetRequiredService<ICommandLineWrapper>(),
serviceProvider.GetRequiredService<IAWSResourceQueryer>(),
serviceProvider.GetRequiredService<ICdkAppSettingsSerializer>(),
serviceProvider.GetRequiredService<IFileManager>(),
serviceProvider.GetRequiredService<IDirectoryManager>(),
serviceProvider.GetRequiredService<IOptionSettingHandler>(),
serviceProvider.GetRequiredService<IDeployToolWorkspaceMetadata>(),
serviceProvider.GetRequiredService<ICloudFormationTemplateReader>()
Expand Down
5 changes: 5 additions & 0 deletions src/AWS.Deploy.Common/CloudApplicationMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public class CloudApplicationMetadata
/// </summary>
public IDictionary<string, object> Settings { get; set; } = new Dictionary<string, object>();

/// <summary>
/// Comprises of option settings that are part of the deployment bundle definition.
/// </summary>
public IDictionary<string, object> DeploymentBundleSettings { get; set; } = new Dictionary<string , object>();

public CloudApplicationMetadata(string recipeId, string recipeVersion)
{
RecipeId = recipeId;
Expand Down
8 changes: 8 additions & 0 deletions src/AWS.Deploy.Common/Recipes/IOptionSettingHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Collections.Generic;
using System.Threading.Tasks;
using AWS.Deploy.Common.IO;
using AWS.Deploy.Common.Recipes.Validation;

namespace AWS.Deploy.Common.Recipes
Expand Down Expand Up @@ -84,5 +85,12 @@ public interface IOptionSettingHandler
/// </summary>
/// <returns>true if the option setting item has been modified or false otherwise</returns>
bool IsOptionSettingModified(Recommendation recommendation, OptionSettingItem optionSetting);

/// <summary>
/// <para>Returns a Dictionary containing the configurable option settings for the specified recommendation. The returned dictionary can contain specific types of option settings depending on the value of <see cref="OptionSettingsType"/>.</para>
/// <para>The key in the dictionary is the fully qualified ID of each option setting</para>
/// <para>The value in the dictionary is the value of each option setting</para>
/// </summary>
Dictionary<string, object> GetOptionSettingsMap(Recommendation recommendation, ProjectDefinition projectDefinition, IDirectoryManager directoryManager, OptionSettingsType optionSettingsType = OptionSettingsType.All);
}
}
30 changes: 30 additions & 0 deletions src/AWS.Deploy.Common/Recipes/OptionSettingsType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

using System;
using System.Collections.Generic;
using System.Text;

namespace AWS.Deploy.Common.Recipes
{
/// <summary>
/// This enum is used to specify the type of option settings that are retrieved when invoking <see cref="IOptionSettingHandler.GetOptionSettingsMap(Recommendation, ProjectDefinition, IO.IDirectoryManager, OptionSettingsType)"/>
/// </summary>
public enum OptionSettingsType
{
/// <summary>
/// Theses option settings are part of the individual recipe files.
/// </summary>
Recipe,

/// <summary>
/// These option settings are part of the deployment bundle definitions.
/// </summary>
DeploymentBundle,

/// <summary>
/// Comprises of all types of option settings
/// </summary>
All
}
}
5 changes: 5 additions & 0 deletions src/AWS.Deploy.Common/Recipes/RecipeDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public class RecipeDefinition
/// </summary>
public string TargetService { get; set; }

/// <summary>
/// The environment platform the recipe deploys to. This is used to publish a self-contained .NET application for that platform.
/// </summary>
public TargetPlatform? TargetPlatform { get; set; }

/// <summary>
/// The list of DisplayedResources that lists logical CloudFormation IDs with a description.
/// </summary>
Expand Down
11 changes: 11 additions & 0 deletions src/AWS.Deploy.Common/Recipes/TargetPlatform.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

namespace AWS.Deploy.Common.Recipes
{
public enum TargetPlatform
{
Linux,
Windows
}
}
7 changes: 6 additions & 1 deletion src/AWS.Deploy.Constants/CloudFormationIdentifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ internal static class CloudFormationIdentifier
public const string STACK_DESCRIPTION_PREFIX = "AWSDotnetDeployCDKStack";

/// <summary>
/// The CloudFormation template metadata key used to hold the last used settings to deploy the application.
/// The CloudFormation template metadata key used to hold the last used recipe option settings to deploy the application.
/// </summary>
public const string STACK_METADATA_SETTINGS = "aws-dotnet-deploy-settings";

/// <summary>
/// The CloudFormation template metadata key used to hold the last used deployment bundle settings to deploy the application.
/// </summary>
public const string STACK_METADATA_DEPLOYMENT_BUNDLE_SETTINGS = "aws-dotnet-deploy-deployment-bundle-settings";

/// <summary>
/// The CloudFormation template metadata key for storing the id of the AWS .NET deployment tool recipe.
/// </summary>
Expand Down
22 changes: 22 additions & 0 deletions src/AWS.Deploy.Constants/ElasticBeanstalk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ internal static class ElasticBeanstalk
public const string HealthCheckURLOptionNameSpace = "aws:elasticbeanstalk:application";
public const string HealthCheckURLOptionName = "Application Healthcheck URL";

public const string LinuxPlatformType = ".NET Core";
public const string WindowsPlatformType = "Windows Server";

public const string IISAppPathOptionId = "IISAppPath";
public const string IISWebSiteOptionId = "IISWebSite";

public const string WindowsManifestName = "aws-windows-deployment-manifest.json";

/// <summary>
/// This list stores a named tuple of OptionSettingId, OptionSettingNameSpace and OptionSettingName.
/// <para>OptionSettingId refers to the Id property for an option setting item in the recipe file.</para>
Expand All @@ -35,5 +43,19 @@ internal static class ElasticBeanstalk
new (ProxyOptionId, ProxyOptionNameSpace, ProxyOptionName),
new (HealthCheckURLOptionId, HealthCheckURLOptionNameSpace, HealthCheckURLOptionName)
};

/// <summary>
/// This is the list of option settings available for Windows Beanstalk deployments.
/// This list stores a named tuple of OptionSettingId, OptionSettingNameSpace and OptionSettingName.
/// <para>OptionSettingId refers to the Id property for an option setting item in the recipe file.</para>
/// <para>OptionSettingNameSpace and OptionSettingName provide a way to configure the environments metadata and update its behaviour.</para>
/// <para>A comprehensive list of all configurable settings can be found <see href="https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/beanstalk-environment-configuration-advanced.html">here</see></para>
/// </summary>
public static List<(string OptionSettingId, string OptionSettingNameSpace, string OptionSettingName)> WindowsOptionSettingQueryList = new()
{
new (EnhancedHealthReportingOptionId, EnhancedHealthReportingOptionNameSpace, EnhancedHealthReportingOptionName),
new (XRayTracingOptionId, XRayTracingOptionNameSpace, XRayTracingOptionName),
new (HealthCheckURLOptionId, HealthCheckURLOptionNameSpace, HealthCheckURLOptionName)
};
}
}
1 change: 1 addition & 0 deletions src/AWS.Deploy.Constants/RecipeIdentifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ internal static class RecipeIdentifier
{
// Recipe IDs
public const string EXISTING_BEANSTALK_ENVIRONMENT_RECIPE_ID = "AspNetAppExistingBeanstalkEnvironment";
public const string EXISTING_BEANSTALK_WINDOWS_ENVIRONMENT_RECIPE_ID = "AspNetAppExistingBeanstalkWindowsEnvironment";
public const string PUSH_TO_ECR_RECIPE_ID = "PushContainerImageEcr";

// Replacement Tokens
Expand Down
31 changes: 20 additions & 11 deletions src/AWS.Deploy.Orchestration/CdkAppSettingsSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,30 @@
using System.Collections.Generic;
using System.IO;
using AWS.Deploy.Common;
using AWS.Deploy.Common.IO;
using AWS.Deploy.Common.Recipes;
using AWS.Deploy.Recipes.CDK.Common;
using Newtonsoft.Json;

namespace AWS.Deploy.Orchestration
{
public class CdkAppSettingsSerializer
public interface ICdkAppSettingsSerializer
{
/// <summary>
/// Creates the contents for the appsettings.json file inside the CDK project. This file is deserialized into <see cref="IRecipeProps{T}"/> to be used the by the CDK templates.
/// </summary>
string Build(CloudApplication cloudApplication, Recommendation recommendation, OrchestratorSession session);
}

public class CdkAppSettingsSerializer : ICdkAppSettingsSerializer
{
private readonly IOptionSettingHandler _optionSettingHandler;
private readonly IDirectoryManager _directoryManager;

public CdkAppSettingsSerializer(IOptionSettingHandler optionSettingHandler)
public CdkAppSettingsSerializer(IOptionSettingHandler optionSettingHandler, IDirectoryManager directoryManager)
{
_optionSettingHandler = optionSettingHandler;
_directoryManager = directoryManager;
}

public string Build(CloudApplication cloudApplication, Recommendation recommendation, OrchestratorSession session)
Expand All @@ -33,23 +44,21 @@ public string Build(CloudApplication cloudApplication, Recommendation recommenda
recommendation.Recipe.Version,
session.AWSAccountId,
session.AWSRegion,
new ()
settings: _optionSettingHandler.GetOptionSettingsMap(recommendation, session.ProjectDefinition, _directoryManager, OptionSettingsType.Recipe)
)
{
// These deployment bundle settings need to be set separately because they are not configurable by the user.
// These settings will not be part of the CloudFormation template metadata.
// The only exception to this is the ECR Repository name.
ECRRepositoryName = recommendation.DeploymentBundle.ECRRepositoryName ?? "",
ECRImageTag = recommendation.DeploymentBundle.ECRImageTag ?? "",
DotnetPublishZipPath = recommendation.DeploymentBundle.DotnetPublishZipPath ?? "",
DotnetPublishOutputDirectory = recommendation.DeploymentBundle.DotnetPublishOutputDirectory ?? ""
};

// Option Settings
foreach (var optionSetting in recommendation.Recipe.OptionSettings)
{
var optionSettingValue = _optionSettingHandler.GetOptionSettingValue(recommendation, optionSetting);

if (optionSettingValue != null)
appSettingsContainer.Settings[optionSetting.Id] = optionSettingValue;
}
// Persist deployment bundle settings
var deploymentBundleSettingsMap = _optionSettingHandler.GetOptionSettingsMap(recommendation, session.ProjectDefinition, _directoryManager, OptionSettingsType.DeploymentBundle);
appSettingsContainer.DeploymentBundleSettings = JsonConvert.SerializeObject(deploymentBundleSettingsMap);

return JsonConvert.SerializeObject(appSettingsContainer, Formatting.Indented);
}
Expand Down
8 changes: 5 additions & 3 deletions src/AWS.Deploy.Orchestration/CdkProjectHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class CdkProjectHandler : ICdkProjectHandler
{
private readonly IOrchestratorInteractiveService _interactiveService;
private readonly ICommandLineWrapper _commandLineWrapper;
private readonly CdkAppSettingsSerializer _appSettingsBuilder;
private readonly ICdkAppSettingsSerializer _appSettingsBuilder;
private readonly IDirectoryManager _directoryManager;
private readonly IAWSResourceQueryer _awsResourceQueryer;
private readonly IFileManager _fileManager;
Expand All @@ -42,16 +42,18 @@ public CdkProjectHandler(
IOrchestratorInteractiveService interactiveService,
ICommandLineWrapper commandLineWrapper,
IAWSResourceQueryer awsResourceQueryer,
ICdkAppSettingsSerializer cdkAppSettingsSerializer,
IFileManager fileManager,
IDirectoryManager directoryManager,
IOptionSettingHandler optionSettingHandler,
IDeployToolWorkspaceMetadata workspaceMetadata,
ICloudFormationTemplateReader cloudFormationTemplateReader)
{
_interactiveService = interactiveService;
_commandLineWrapper = commandLineWrapper;
_awsResourceQueryer = awsResourceQueryer;
_appSettingsBuilder = new CdkAppSettingsSerializer(optionSettingHandler);
_directoryManager = new DirectoryManager();
_appSettingsBuilder = cdkAppSettingsSerializer;
_directoryManager = directoryManager;
_fileManager = fileManager;
_workspaceMetadata = workspaceMetadata;
_cloudFormationTemplateReader = cloudFormationTemplateReader;
Expand Down
Loading

0 comments on commit 4f04da1

Please sign in to comment.