From eb2bcedfba9e2604fbd596580d461d53edb5fcf1 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 --- .../07AEC2AC-0C7B-4C60-9EAF-C92E6A805559.json | 13 ++++++++++++ ...e App to AWS Elastic Beanstalk on Linux.md | 4 ++++ ...App to AWS Elastic Beanstalk on Windows.md | 4 ++++ .../Properties/DockerFileConfig.json | 15 ++++++++++++-- .../CdkAppSettingsSerializer.cs | 3 ++- .../DeploymentBundleHandler.cs | 6 +++--- .../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 + 30 files changed, 144 insertions(+), 26 deletions(-) create mode 100644 .autover/changes/07AEC2AC-0C7B-4C60-9EAF-C92E6A805559.json diff --git a/.autover/changes/07AEC2AC-0C7B-4C60-9EAF-C92E6A805559.json b/.autover/changes/07AEC2AC-0C7B-4C60-9EAF-C92E6A805559.json new file mode 100644 index 000000000..e9e3c0795 --- /dev/null +++ b/.autover/changes/07AEC2AC-0C7B-4C60-9EAF-C92E6A805559.json @@ -0,0 +1,13 @@ +{ + "Projects": [ + { + "Name": "AWS.Deploy.CLI", + "Type": "Minor", + "ChangelogMessages": [ + "Added support for .NET 9 in deployment recipes.", + "Added ability to configure EC2 IMDSv1 access for the Windows and Linux Elastic Beanstalk recipes.", + "Support Elastic Beanstalk's transition to using EC2 Launch Templates from the deprecated Launch Configuration." + ] + } + ] +} \ No newline at end of file diff --git a/site/content/docs/cicd/recipes/ASP.NET Core App to AWS Elastic Beanstalk on Linux.md b/site/content/docs/cicd/recipes/ASP.NET Core App to AWS Elastic Beanstalk on Linux.md index 2edfb8021..6b2dd6817 100644 --- a/site/content/docs/cicd/recipes/ASP.NET Core App to AWS Elastic Beanstalk on Linux.md +++ b/site/content/docs/cicd/recipes/ASP.NET Core App to AWS Elastic Beanstalk on Linux.md @@ -34,6 +34,10 @@ * ID: InstanceType * Description: The EC2 instance type of the EC2 instances created for the environment. * Type: String +* **Access to IMDS v1** + * ID: IMDSv1Access + * Description: Access to IMDS v1; Default means new deployments will disable IMDSv1, redeployments leave the setting at its current value. + * Type: String * **Environment Type** * ID: EnvironmentType * Description: The type of environment to create; for example, a single instance for development work or load balanced for production. diff --git a/site/content/docs/cicd/recipes/ASP.NET Core App to AWS Elastic Beanstalk on Windows.md b/site/content/docs/cicd/recipes/ASP.NET Core App to AWS Elastic Beanstalk on Windows.md index 4c60763f5..aba416f5c 100644 --- a/site/content/docs/cicd/recipes/ASP.NET Core App to AWS Elastic Beanstalk on Windows.md +++ b/site/content/docs/cicd/recipes/ASP.NET Core App to AWS Elastic Beanstalk on Windows.md @@ -29,6 +29,10 @@ * ID: InstanceType * Description: The EC2 instance type of the EC2 instances created for the environment. * Type: String +* **Access to IMDS v1** + * ID: IMDSv1Access + * Description: Access to IMDS v1; Default means new deployments will disable IMDSv1, redeployments leave the setting at its current value. + * Type: String * **Environment Type** * ID: EnvironmentType * Description: The type of environment to create; for example, a single instance for development work or load balanced for production. 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..ed3fc4568 100644 --- a/src/AWS.Deploy.Orchestration/DeploymentBundleHandler.cs +++ b/src/AWS.Deploy.Orchestration/DeploymentBundleHandler.cs @@ -133,9 +133,9 @@ private void SwitchToSelfContainedBuildIfNeeded(Recommendation recommendation) if (string.IsNullOrEmpty(targetFramework)) return; - // Elastic Beanstalk doesn't currently have .NET 7 preinstalled. - var unavailableFramework = new List { "net7.0" }; - var frameworkNames = new Dictionary { { "net7.0", ".NET 7" } }; + // Elastic Beanstalk doesn't currently have .NET 7 and 9 preinstalled. + 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 @@ - + - + - + - + - +