From 56e1b53b502a63fbecec756932bc2115101b03aa Mon Sep 17 00:00:00 2001 From: Norm Johanson Date: Wed, 16 Oct 2024 13:16:34 -0700 Subject: [PATCH] Add support for .NET 9 and support for disabling IMDS v1 for Beanstalk recipes The support for disabling IMDS v1 provides a mechanism for transitions EC2 Launch Configuration to Launch Templates --- .../Properties/DockerFileConfig.json | 15 ++++++++++++-- .../CdkAppSettingsSerializer.cs | 3 ++- .../DeploymentBundleHandler.cs | 4 ++-- .../AWS.Deploy.Recipes.CDK.Common.csproj | 2 +- .../RecipeProps.cs | 10 ++++++++++ .../AspNetAppAppRunner.csproj | 2 +- .../AspNetAppEcsFargate.csproj | 2 +- .../AspNetAppElasticBeanstalkLinux.csproj | 2 +- .../Generated/Configurations/Configuration.cs | 5 +++++ .../Generated/Recipe.cs | 20 +++++++++++++++++-- .../AspNetAppElasticBeanstalkWindows.csproj | 2 +- .../Generated/Configurations/Configuration.cs | 5 +++++ .../Generated/Recipe.cs | 20 +++++++++++++++++-- .../CdkTemplates/BlazorWasm/BlazorWasm.csproj | 2 +- .../ConsoleAppECSFargateScheduleTask.csproj | 2 +- .../ConsoleAppEcsFargateService.csproj | 2 +- .../ASP.NETAppAppRunner.recipe | 2 +- .../ASP.NETAppECSFargate.recipe | 2 +- .../ASP.NETAppElasticBeanstalkLinux.recipe | 17 +++++++++++++++- .../ASP.NETAppElasticBeanstalkWindows.recipe | 17 +++++++++++++++- ....NETAppExistingBeanstalkEnvironment.recipe | 2 +- ...ExistingBeanstalkWindowsEnvironment.recipe | 2 +- .../ConsoleAppECSFargateScheduleTask.recipe | 2 +- .../ConsoleAppECSFargateService.recipe | 2 +- .../DeploymentSettingsHandlerTests.cs | 1 + .../SettingsSnapshot_NonContainer.json | 1 + ...ngsSnapshot_NonContainer_ModifiedOnly.json | 1 + 27 files changed, 122 insertions(+), 25 deletions(-) diff --git a/src/AWS.Deploy.DockerEngine/Properties/DockerFileConfig.json b/src/AWS.Deploy.DockerEngine/Properties/DockerFileConfig.json index 122d06c31..3c0cadf67 100644 --- a/src/AWS.Deploy.DockerEngine/Properties/DockerFileConfig.json +++ b/src/AWS.Deploy.DockerEngine/Properties/DockerFileConfig.json @@ -2,11 +2,17 @@ { "SdkType": "Microsoft.NET.Sdk.Web", "ImageMapping": [ + { + "TargetFramework": "net9.0", + "BaseImage": "mcr.microsoft.com/dotnet/aspnet:9.0", + "BuildImage": "mcr.microsoft.com/dotnet/sdk:9.0" + }, { "TargetFramework": "net8.0", "BaseImage": "mcr.microsoft.com/dotnet/aspnet:8.0", "BuildImage": "mcr.microsoft.com/dotnet/sdk:8.0" - }, { + }, + { "TargetFramework": "net7.0", "BaseImage": "mcr.microsoft.com/dotnet/aspnet:7.0", "BuildImage": "mcr.microsoft.com/dotnet/sdk:7.0" @@ -31,11 +37,16 @@ { "SdkType": "Microsoft.NET.Sdk", "ImageMapping": [ + { + "TargetFramework": "net9.0", + "BaseImage": "mcr.microsoft.com/dotnet/runtime:9.0", + "BuildImage": "mcr.microsoft.com/dotnet/sdk:9.0" + }, { "TargetFramework": "net8.0", "BaseImage": "mcr.microsoft.com/dotnet/runtime:8.0", "BuildImage": "mcr.microsoft.com/dotnet/sdk:8.0" - }, + }, { "TargetFramework": "net7.0", "BaseImage": "mcr.microsoft.com/dotnet/runtime:7.0", diff --git a/src/AWS.Deploy.Orchestration/CdkAppSettingsSerializer.cs b/src/AWS.Deploy.Orchestration/CdkAppSettingsSerializer.cs index 98454fe3b..6bf05cb00 100644 --- a/src/AWS.Deploy.Orchestration/CdkAppSettingsSerializer.cs +++ b/src/AWS.Deploy.Orchestration/CdkAppSettingsSerializer.cs @@ -53,7 +53,8 @@ public string Build(CloudApplication cloudApplication, Recommendation recommenda ECRRepositoryName = recommendation.DeploymentBundle.ECRRepositoryName ?? "", ECRImageTag = recommendation.DeploymentBundle.ECRImageTag ?? "", DotnetPublishZipPath = recommendation.DeploymentBundle.DotnetPublishZipPath ?? "", - DotnetPublishOutputDirectory = recommendation.DeploymentBundle.DotnetPublishOutputDirectory ?? "" + DotnetPublishOutputDirectory = recommendation.DeploymentBundle.DotnetPublishOutputDirectory ?? "", + NewDeployment = !recommendation.IsExistingCloudApplication }; // Persist deployment bundle settings diff --git a/src/AWS.Deploy.Orchestration/DeploymentBundleHandler.cs b/src/AWS.Deploy.Orchestration/DeploymentBundleHandler.cs index 237548dec..ffd687dd2 100644 --- a/src/AWS.Deploy.Orchestration/DeploymentBundleHandler.cs +++ b/src/AWS.Deploy.Orchestration/DeploymentBundleHandler.cs @@ -134,8 +134,8 @@ private void SwitchToSelfContainedBuildIfNeeded(Recommendation recommendation) return; // Elastic Beanstalk doesn't currently have .NET 7 preinstalled. - var unavailableFramework = new List { "net7.0" }; - var frameworkNames = new Dictionary { { "net7.0", ".NET 7" } }; + var unavailableFramework = new List { "net7.0", "net9.0" }; + var frameworkNames = new Dictionary { { "net7.0", ".NET 7" }, { "net9.0", ".NET 9" } }; if (unavailableFramework.Contains(targetFramework)) { _interactiveService.LogInfoMessage($"Using self-contained publish since AWS Elastic Beanstalk does not currently have {frameworkNames[targetFramework]} preinstalled"); diff --git a/src/AWS.Deploy.Recipes.CDK.Common/AWS.Deploy.Recipes.CDK.Common.csproj b/src/AWS.Deploy.Recipes.CDK.Common/AWS.Deploy.Recipes.CDK.Common.csproj index b085004d4..9250a4a47 100644 --- a/src/AWS.Deploy.Recipes.CDK.Common/AWS.Deploy.Recipes.CDK.Common.csproj +++ b/src/AWS.Deploy.Recipes.CDK.Common/AWS.Deploy.Recipes.CDK.Common.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/AWS.Deploy.Recipes.CDK.Common/RecipeProps.cs b/src/AWS.Deploy.Recipes.CDK.Common/RecipeProps.cs index 76f4c0d39..1dabc5a22 100644 --- a/src/AWS.Deploy.Recipes.CDK.Common/RecipeProps.cs +++ b/src/AWS.Deploy.Recipes.CDK.Common/RecipeProps.cs @@ -70,6 +70,11 @@ public interface IRecipeProps /// The account ID used during deployment. /// string? AWSAccountId { get; set; } + + /// + /// True if the recipe is doing a new deployment. + /// + bool NewDeployment { get; set; } } /// @@ -138,6 +143,11 @@ public class RecipeProps : IRecipeProps /// public string? AWSAccountId { get; set; } + /// + /// True if the recipe is doing a redeployment. + /// + public bool NewDeployment { get; set; } = false; + /// A parameterless constructor is needed for /// or the classes will fail to initialize. /// The warnings are disabled since a parameterless constructor will allow non-nullable properties to be initialized with null values. diff --git a/src/AWS.Deploy.Recipes/CdkTemplates/AspNetAppAppRunner/AspNetAppAppRunner.csproj b/src/AWS.Deploy.Recipes/CdkTemplates/AspNetAppAppRunner/AspNetAppAppRunner.csproj index 6293b3808..a50c9a848 100644 --- a/src/AWS.Deploy.Recipes/CdkTemplates/AspNetAppAppRunner/AspNetAppAppRunner.csproj +++ b/src/AWS.Deploy.Recipes/CdkTemplates/AspNetAppAppRunner/AspNetAppAppRunner.csproj @@ -25,7 +25,7 @@ - + - + - + - + - +