From 80c2ace6319aa7514731004774f4d4791878fc3e Mon Sep 17 00:00:00 2001 From: Ashish Dhingra <67916761+ashishdhingra@users.noreply.github.com> Date: Thu, 5 Sep 2024 14:16:39 -0700 Subject: [PATCH 01/26] chore: Modified bug issue template to add checkbox to report potential regression. --- .github/ISSUE_TEMPLATE/bug-report.yml | 8 +++++ .../workflows/issue-regression-labeler.yml | 32 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 .github/workflows/issue-regression-labeler.yml diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index dcaccb18..940eed31 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -12,6 +12,14 @@ body: description: What is the problem? A clear and concise description of the bug. validations: required: true + - type: checkboxes + id: regression + attributes: + label: Regression Issue + description: What is a regression? If it worked in a previous version but doesn't in the latest version, it's considered a regression. In this case, please provide specific version number in the report. + options: + - label: Select this option if this issue appears to be a regression. + required: false - type: textarea id: expected attributes: diff --git a/.github/workflows/issue-regression-labeler.yml b/.github/workflows/issue-regression-labeler.yml new file mode 100644 index 00000000..bd000719 --- /dev/null +++ b/.github/workflows/issue-regression-labeler.yml @@ -0,0 +1,32 @@ +# Apply potential regression label on issues +name: issue-regression-label +on: + issues: + types: [opened, edited] +jobs: + add-regression-label: + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - name: Fetch template body + id: check_regression + uses: actions/github-script@v7 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TEMPLATE_BODY: ${{ github.event.issue.body }} + with: + script: | + const regressionPattern = /\[x\] Select this option if this issue appears to be a regression\./i; + const template = `${process.env.TEMPLATE_BODY}` + const match = regressionPattern.test(template); + core.setOutput('is_regression', match); + - name: Manage regression label + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if [ "${{ steps.check_regression.outputs.is_regression }}" == "true" ]; then + gh issue edit ${{ github.event.issue.number }} --add-label "potential-regression" -R ${{ github.repository }} + else + gh issue edit ${{ github.event.issue.number }} --remove-label "potential-regression" -R ${{ github.repository }} + fi From 969aa52f204b96d03f4e012b7f78e29b6c1e3c6d Mon Sep 17 00:00:00 2001 From: Norm Johanson Date: Wed, 9 Oct 2024 10:43:47 -0700 Subject: [PATCH 02/26] Add support configuring logging for Lambda functions --- .../Amazon.Lambda.Tools.csproj | 2 +- .../Commands/DeployFunctionCommand.cs | 19 ++- .../Commands/GetFunctionConfigCommand.cs | 9 ++ .../Commands/UpdateFunctionConfigCommand.cs | 82 +++++++++++- .../LambdaDefinedCommandOptions.cs | 36 +++++ .../ApplySettingsTest.cs | 124 ++++++++++++++++++ 6 files changed, 269 insertions(+), 3 deletions(-) create mode 100644 test/Amazon.Lambda.Tools.Test/ApplySettingsTest.cs diff --git a/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj b/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj index 5850b88f..8a248049 100644 --- a/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj +++ b/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj @@ -15,7 +15,7 @@ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. AWS Lambda Tools for .NET CLI false - 5.10.7 + 5.11.0 diff --git a/src/Amazon.Lambda.Tools/Commands/DeployFunctionCommand.cs b/src/Amazon.Lambda.Tools/Commands/DeployFunctionCommand.cs index 42ae6cbe..d346f28e 100644 --- a/src/Amazon.Lambda.Tools/Commands/DeployFunctionCommand.cs +++ b/src/Amazon.Lambda.Tools/Commands/DeployFunctionCommand.cs @@ -79,7 +79,12 @@ public class DeployFunctionCommand : UpdateFunctionConfigCommand LambdaDefinedCommandOptions.ARGUMENT_USE_CONTAINER_FOR_BUILD, LambdaDefinedCommandOptions.ARGUMENT_CONTAINER_IMAGE_FOR_BUILD, - LambdaDefinedCommandOptions.ARGUMENT_CODE_MOUNT_DIRECTORY + LambdaDefinedCommandOptions.ARGUMENT_CODE_MOUNT_DIRECTORY, + + LambdaDefinedCommandOptions.ARGUMENT_LOG_FORMAT, + LambdaDefinedCommandOptions.ARGUMENT_LOG_APPLICATION_LEVEL, + LambdaDefinedCommandOptions.ARGUMENT_LOG_SYSTEM_LEVEL, + LambdaDefinedCommandOptions.ARGUMENT_LOG_GROUP, }); public string Architecture { get; set; } @@ -319,6 +324,13 @@ protected override async Task PerformActionAsync() { SubnetIds = this.GetStringValuesOrDefault(this.SubnetIds, LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_SUBNETS, false)?.ToList(), SecurityGroupIds = this.GetStringValuesOrDefault(this.SecurityGroupIds, LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_SECURITY_GROUPS, false)?.ToList() + }, + LoggingConfig = new LoggingConfig + { + LogFormat = this.GetStringValueOrDefault(this.LogFormat, LambdaDefinedCommandOptions.ARGUMENT_LOG_FORMAT, false), + ApplicationLogLevel = this.GetStringValueOrDefault(this.LogApplicationLevel, LambdaDefinedCommandOptions.ARGUMENT_LOG_APPLICATION_LEVEL, false), + SystemLogLevel = this.GetStringValueOrDefault(this.LogSystemLevel, LambdaDefinedCommandOptions.ARGUMENT_LOG_SYSTEM_LEVEL, false), + LogGroup = this.GetStringValueOrDefault(this.LogGroup, LambdaDefinedCommandOptions.ARGUMENT_LOG_GROUP, false), } }; @@ -622,6 +634,11 @@ protected override void SaveConfigFile(JsonData data) data.SetIfNotNull(LambdaDefinedCommandOptions.ARGUMENT_USE_CONTAINER_FOR_BUILD.ConfigFileKey, this.GetBoolValueOrDefault(this.UseContainerForBuild, LambdaDefinedCommandOptions.ARGUMENT_USE_CONTAINER_FOR_BUILD, false)); data.SetIfNotNull(LambdaDefinedCommandOptions.ARGUMENT_CONTAINER_IMAGE_FOR_BUILD.ConfigFileKey, this.GetStringValueOrDefault(this.ContainerImageForBuild, LambdaDefinedCommandOptions.ARGUMENT_CONTAINER_IMAGE_FOR_BUILD, false)); data.SetIfNotNull(LambdaDefinedCommandOptions.ARGUMENT_CODE_MOUNT_DIRECTORY.ConfigFileKey, this.GetStringValueOrDefault(this.CodeMountDirectory, LambdaDefinedCommandOptions.ARGUMENT_CODE_MOUNT_DIRECTORY, false)); + + data.SetIfNotNull(LambdaDefinedCommandOptions.ARGUMENT_LOG_FORMAT.ConfigFileKey, this.GetStringValueOrDefault(this.LogFormat, LambdaDefinedCommandOptions.ARGUMENT_LOG_FORMAT, false)); + data.SetIfNotNull(LambdaDefinedCommandOptions.ARGUMENT_LOG_APPLICATION_LEVEL.ConfigFileKey, this.GetStringValueOrDefault(this.LogApplicationLevel, LambdaDefinedCommandOptions.ARGUMENT_LOG_APPLICATION_LEVEL, false)); + data.SetIfNotNull(LambdaDefinedCommandOptions.ARGUMENT_LOG_SYSTEM_LEVEL.ConfigFileKey, this.GetStringValueOrDefault(this.LogSystemLevel, LambdaDefinedCommandOptions.ARGUMENT_LOG_SYSTEM_LEVEL, false)); + data.SetIfNotNull(LambdaDefinedCommandOptions.ARGUMENT_LOG_GROUP.ConfigFileKey, this.GetStringValueOrDefault(this.LogGroup, LambdaDefinedCommandOptions.ARGUMENT_LOG_GROUP, false)); } } } diff --git a/src/Amazon.Lambda.Tools/Commands/GetFunctionConfigCommand.cs b/src/Amazon.Lambda.Tools/Commands/GetFunctionConfigCommand.cs index 5e1770b1..50aa7155 100644 --- a/src/Amazon.Lambda.Tools/Commands/GetFunctionConfigCommand.cs +++ b/src/Amazon.Lambda.Tools/Commands/GetFunctionConfigCommand.cs @@ -146,6 +146,15 @@ protected override async Task PerformActionAsync() this.Logger.WriteLine(" Auth: ".PadRight(PAD_SIZE) + urlConfig.AuthType.Value); } + if (response.LoggingConfig != null) + { + this.Logger.WriteLine("Logging Config"); + this.Logger.WriteLine(" Format: ".PadRight(PAD_SIZE) + response.LoggingConfig.LogFormat); + this.Logger.WriteLine(" Application Log Level: ".PadRight(PAD_SIZE) + response.LoggingConfig.ApplicationLogLevel); + this.Logger.WriteLine(" System Log Level: ".PadRight(PAD_SIZE) + response.LoggingConfig.SystemLogLevel); + this.Logger.WriteLine(" Log Group: ".PadRight(PAD_SIZE) + response.LoggingConfig.LogGroup); + } + return true; } diff --git a/src/Amazon.Lambda.Tools/Commands/UpdateFunctionConfigCommand.cs b/src/Amazon.Lambda.Tools/Commands/UpdateFunctionConfigCommand.cs index f854b860..b884fe6a 100644 --- a/src/Amazon.Lambda.Tools/Commands/UpdateFunctionConfigCommand.cs +++ b/src/Amazon.Lambda.Tools/Commands/UpdateFunctionConfigCommand.cs @@ -54,7 +54,12 @@ public class UpdateFunctionConfigCommand : LambdaBaseCommand LambdaDefinedCommandOptions.ARGUMENT_ENVIRONMENT_VARIABLES, LambdaDefinedCommandOptions.ARGUMENT_APPEND_ENVIRONMENT_VARIABLES, LambdaDefinedCommandOptions.ARGUMENT_KMS_KEY_ARN, - LambdaDefinedCommandOptions.ARGUMENT_APPLY_DEFAULTS_FOR_UPDATE_OBSOLETE + LambdaDefinedCommandOptions.ARGUMENT_APPLY_DEFAULTS_FOR_UPDATE_OBSOLETE, + + LambdaDefinedCommandOptions.ARGUMENT_LOG_FORMAT, + LambdaDefinedCommandOptions.ARGUMENT_LOG_APPLICATION_LEVEL, + LambdaDefinedCommandOptions.ARGUMENT_LOG_SYSTEM_LEVEL, + LambdaDefinedCommandOptions.ARGUMENT_LOG_GROUP, }); public string FunctionName { get; set; } @@ -88,6 +93,12 @@ public class UpdateFunctionConfigCommand : LambdaBaseCommand public string FunctionUrlLink { get; private set; } + public string LogFormat { get; set; } + public string LogApplicationLevel { get; set; } + public string LogSystemLevel { get; set; } + public string LogGroup { get; set; } + + public UpdateFunctionConfigCommand(IToolLogger logger, string workingDirectory, string[] args) : base(logger, workingDirectory, UpdateCommandOptions, args) { @@ -161,6 +172,15 @@ protected override void ParseCommandArguments(CommandOptions values) this.FunctionUrlEnable = tuple.Item2.BoolValue; if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_URL_AUTH.Switch)) != null) this.FunctionUrlAuthType = tuple.Item2.StringValue; + + if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_LOG_FORMAT.Switch)) != null) + this.LogFormat = tuple.Item2.StringValue; + if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_LOG_APPLICATION_LEVEL.Switch)) != null) + this.LogApplicationLevel = tuple.Item2.StringValue; + if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_LOG_SYSTEM_LEVEL.Switch)) != null) + this.LogSystemLevel = tuple.Item2.StringValue; + if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_LOG_GROUP.Switch)) != null) + this.LogGroup = tuple.Item2.StringValue; } @@ -623,6 +643,66 @@ private UpdateFunctionConfigurationRequest CreateConfigurationRequestIfDifferent } } + var logFormat = this.GetStringValueOrDefault(this.LogFormat, LambdaDefinedCommandOptions.ARGUMENT_LOG_FORMAT, false); + if (!string.IsNullOrEmpty(logFormat)) + { + if (request.LoggingConfig == null) + { + request.LoggingConfig = new LoggingConfig(); + } + + if (!string.Equals(request.LoggingConfig.LogFormat, existingConfiguration.LoggingConfig?.LogFormat, StringComparison.Ordinal)) + { + request.LoggingConfig.LogFormat = logFormat; + different = true; + } + } + + var logApplicationLevel = this.GetStringValueOrDefault(this.LogApplicationLevel, LambdaDefinedCommandOptions.ARGUMENT_LOG_APPLICATION_LEVEL, false); + if (!string.IsNullOrEmpty(logApplicationLevel)) + { + if (request.LoggingConfig == null) + { + request.LoggingConfig = new LoggingConfig(); + } + + if (!string.Equals(request.LoggingConfig.ApplicationLogLevel, existingConfiguration.LoggingConfig?.ApplicationLogLevel, StringComparison.Ordinal)) + { + request.LoggingConfig.ApplicationLogLevel = logApplicationLevel; + different = true; + } + } + + var logSystemLevel = this.GetStringValueOrDefault(this.LogSystemLevel, LambdaDefinedCommandOptions.ARGUMENT_LOG_SYSTEM_LEVEL, false); + if (!string.IsNullOrEmpty(logSystemLevel)) + { + if (request.LoggingConfig == null) + { + request.LoggingConfig = new LoggingConfig(); + } + + if (!string.Equals(request.LoggingConfig.SystemLogLevel, existingConfiguration.LoggingConfig?.SystemLogLevel, StringComparison.Ordinal)) + { + request.LoggingConfig.SystemLogLevel = logSystemLevel; + different = true; + } + } + + var logGroup = this.GetStringValueOrDefault(this.LogGroup, LambdaDefinedCommandOptions.ARGUMENT_LOG_GROUP, false); + if (logGroup != null) // Allow empty string to reset back to Lambda's default log group. + { + if (request.LoggingConfig == null) + { + request.LoggingConfig = new LoggingConfig(); + } + + if (!string.Equals(request.LoggingConfig.LogGroup, existingConfiguration.LoggingConfig?.LogGroup, StringComparison.Ordinal)) + { + request.LoggingConfig.LogGroup = logGroup; + different = true; + } + } + if (!different) return null; diff --git a/src/Amazon.Lambda.Tools/LambdaDefinedCommandOptions.cs b/src/Amazon.Lambda.Tools/LambdaDefinedCommandOptions.cs index c01b5fd7..fbf40ed7 100644 --- a/src/Amazon.Lambda.Tools/LambdaDefinedCommandOptions.cs +++ b/src/Amazon.Lambda.Tools/LambdaDefinedCommandOptions.cs @@ -486,5 +486,41 @@ public static class LambdaDefinedCommandOptions ValueType = CommandOption.CommandOptionValueType.StringValue, Description = $"Path to the directory to mount to the build container. Otherwise, look upward for a solution folder." }; + public static readonly CommandOption ARGUMENT_LOG_FORMAT = + new CommandOption + { + Name = "Log Format", + Switch = "--log-format", + ShortSwitch = "-lf", + ValueType = CommandOption.CommandOptionValueType.StringValue, + Description = $"The log format used by the Lambda function. Valid values are: Text or JSON. Default is Text" + }; + public static readonly CommandOption ARGUMENT_LOG_APPLICATION_LEVEL = + new CommandOption + { + Name = "Application Log Level", + Switch = "--log-application-level", + ShortSwitch = "-lal", + ValueType = CommandOption.CommandOptionValueType.StringValue, + Description = $"The log level. Valid values are: TRACE, DEBUG, INFO, WARN, ERROR or FATAL. Default is INFO." + }; + public static readonly CommandOption ARGUMENT_LOG_SYSTEM_LEVEL = + new CommandOption + { + Name = "System Log", + Switch = "--log-system-level", + ShortSwitch = "-lsl", + ValueType = CommandOption.CommandOptionValueType.StringValue, + Description = $"The log system level. Valid values are: DEBUG, INFO, WARN. Default is INFO." + }; + public static readonly CommandOption ARGUMENT_LOG_GROUP = + new CommandOption + { + Name = "Log Group", + Switch = "--log-group", + ShortSwitch = "-lg", + ValueType = CommandOption.CommandOptionValueType.StringValue, + Description = $"The name of the Amazon CloudWatch log group the function sends logs to. Default is /aws/lambda/." + }; } } diff --git a/test/Amazon.Lambda.Tools.Test/ApplySettingsTest.cs b/test/Amazon.Lambda.Tools.Test/ApplySettingsTest.cs new file mode 100644 index 00000000..8cbe4ed7 --- /dev/null +++ b/test/Amazon.Lambda.Tools.Test/ApplySettingsTest.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Amazon.Lambda.Model; +using Amazon.Lambda.Tools.Commands; +using Moq; +using Xunit; +using Xunit.Abstractions; + +namespace Amazon.Lambda.Tools.Test +{ + public class ApplySettingsTest + { + private readonly ITestOutputHelper _testOutputHelper; + + public ApplySettingsTest(ITestOutputHelper testOutputHelper) + { + this._testOutputHelper = testOutputHelper; + } + + [Fact] + public async Task SetLoggingPropertiesForCreateRequest() + { + var mockClient = new Mock(); + + mockClient.Setup(client => client.CreateFunctionAsync(It.IsAny(), It.IsAny())) + .Callback((request, token) => + { + Assert.Equal("JSON", request.LoggingConfig.LogFormat); + Assert.Equal("TheGroup", request.LoggingConfig.LogGroup); + Assert.Equal("DEBUG", request.LoggingConfig.ApplicationLogLevel); + Assert.Equal("WARN", request.LoggingConfig.SystemLogLevel); + }) + .Returns((CreateFunctionRequest r, CancellationToken token) => + { + return Task.FromResult(new CreateFunctionResponse()); + }); + + var assembly = this.GetType().GetTypeInfo().Assembly; + + var fullPath = Path.GetFullPath(Path.GetDirectoryName(assembly.Location) + "../../../../../../testapps/TestFunction"); + var command = new DeployFunctionCommand(new TestToolLogger(_testOutputHelper), fullPath, new string[0]); + command.FunctionName = "test-function-" + DateTime.Now.Ticks; + command.Handler = "TestFunction::TestFunction.Function::ToUpper"; + command.Timeout = 10; + command.MemorySize = 512; + command.Role = await TestHelper.GetTestRoleArnAsync(); + command.Configuration = "Release"; + command.Runtime = "dotnet8"; + command.LogFormat = "JSON"; + command.LogGroup = "TheGroup"; + command.LogApplicationLevel = "DEBUG"; + command.LogSystemLevel = "WARN"; + command.DisableInteractive = true; + command.LambdaClient = mockClient.Object; + + var created = await command.ExecuteAsync(); + Assert.True(created); + } + + [Fact] + public async Task SetLoggingPropertiesForUpdateRequest() + { + var assembly = this.GetType().GetTypeInfo().Assembly; + + var fullPath = Path.GetFullPath(Path.GetDirectoryName(assembly.Location) + "../../../../../../testapps/TestFunction"); + var command = new DeployFunctionCommand(new TestToolLogger(_testOutputHelper), fullPath, new string[0]); + command.FunctionName = "test-function-" + DateTime.Now.Ticks; + command.Handler = "TestFunction::TestFunction.Function::ToUpper"; + command.Timeout = 10; + command.MemorySize = 512; + command.Role = await TestHelper.GetTestRoleArnAsync(); + command.Configuration = "Release"; + command.Runtime = "dotnet8"; + command.LogFormat = "JSON"; + command.LogGroup = "TheGroup"; + command.LogApplicationLevel = "DEBUG"; + command.LogSystemLevel = "WARN"; + command.DisableInteractive = true; + + var mockClient = new Mock(); + + mockClient.Setup(client => client.GetFunctionConfigurationAsync(It.IsAny(), It.IsAny())) + .Returns((GetFunctionConfigurationRequest r, CancellationToken token) => + { + var response = new GetFunctionConfigurationResponse + { + FunctionName = command.FunctionName, + Handler = command.Handler, + Timeout = command.Timeout.Value, + MemorySize = command.MemorySize.Value, + Role = command.Role, + Runtime = command.Runtime + }; + + return Task.FromResult(response); + }); + + mockClient.Setup(client => client.UpdateFunctionConfigurationAsync(It.IsAny(), It.IsAny())) + .Callback((request, token) => + { + Assert.Equal("JSON", request.LoggingConfig.LogFormat); + Assert.Equal("TheGroup", request.LoggingConfig.LogGroup); + Assert.Equal("DEBUG", request.LoggingConfig.ApplicationLogLevel); + Assert.Equal("WARN", request.LoggingConfig.SystemLogLevel); + }) + .Returns((CreateFunctionRequest r, CancellationToken token) => + { + return Task.FromResult(new UpdateFunctionConfigurationResponse()); + }); + + + command.LambdaClient = mockClient.Object; + + var created = await command.ExecuteAsync(); + Assert.True(created); + } + } +} From 2e5f84b59dfdb05eae42c76d7cb56b197549a6cc Mon Sep 17 00:00:00 2001 From: Norm Johanson Date: Wed, 9 Oct 2024 15:01:32 -0700 Subject: [PATCH 03/26] Update RELEASE.CHANGELOG.md --- RELEASE.CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/RELEASE.CHANGELOG.md b/RELEASE.CHANGELOG.md index b7adf8de..9f10da31 100644 --- a/RELEASE.CHANGELOG.md +++ b/RELEASE.CHANGELOG.md @@ -1,3 +1,8 @@ +### Release 2024-10-09 +* **Amazon.Lambda.Tools (5.11.0)** + * Add the `--log-format`, `--log-application-level`, `--log-system-level` and `--log-group` switches to the deploy-function command for configuring logging for the Lambda function. + + ### Release 2024-07-09 * **Amazon.Lambda.Tools (5.10.7)** * Fixed an issue where `CodeUri` set in `Globals` section is ignored for `AWS::Serverless::Function` resource. From 6da5f67d7e88e2c6ab9f60bd34ada49d2e9b4d7a Mon Sep 17 00:00:00 2001 From: Phil Asmar Date: Sun, 27 Oct 2024 12:26:24 -0400 Subject: [PATCH 04/26] ci: create release PRs using autover --- .autover/autover.json | 20 + .github/workflows/aws-ci.yml | 2 +- .github/workflows/create-release-pr.yml | 101 ++++ CHANGELOG.md | 533 ++++++++++++++++++ CONTRIBUTING.md | 45 ++ RELEASE.CHANGELOG.md | 466 --------------- .../Amazon.Common.DotNetCli.Tools.csproj | 2 - 7 files changed, 700 insertions(+), 469 deletions(-) create mode 100644 .autover/autover.json create mode 100644 .github/workflows/create-release-pr.yml create mode 100644 CHANGELOG.md delete mode 100644 RELEASE.CHANGELOG.md diff --git a/.autover/autover.json b/.autover/autover.json new file mode 100644 index 00000000..15f2b11e --- /dev/null +++ b/.autover/autover.json @@ -0,0 +1,20 @@ +{ + "Projects": [ + { + "Name": "Amazon.ECS.Tools", + "Path": "src/Amazon.ECS.Tools/Amazon.ECS.Tools.csproj" + }, + { + "Name": "Amazon.ElasticBeanstalk.Tools", + "Path": "src/Amazon.ElasticBeanstalk.Tools/Amazon.ElasticBeanstalk.Tools.csproj" + }, + { + "Name": "Amazon.Lambda.Tools", + "Path": "src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj" + } + ], + "UseCommitsForChangelog": false, + "UseSameVersionForAllProjects": false, + "DefaultIncrementType": "Patch", + "ChangeFilesDetermineIncrementType": true + } \ No newline at end of file diff --git a/.github/workflows/aws-ci.yml b/.github/workflows/aws-ci.yml index 87f74a0f..f35e6249 100644 --- a/.github/workflows/aws-ci.yml +++ b/.github/workflows/aws-ci.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: pull_request: branches: - - main + - master - dev - 'feature/**' diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml new file mode 100644 index 00000000..d2f72f77 --- /dev/null +++ b/.github/workflows/create-release-pr.yml @@ -0,0 +1,101 @@ +# This GitHub Workflow will create a new release branch that contains the updated C# project versions and changelog. +# The workflow will also create a PR that targets `dev` from the release branch. +name: Create Release PR + +# This workflow is manually triggered when in preparation for a release. The workflow should be dispatched from the `dev` branch. +on: + workflow_dispatch: + inputs: + OVERRIDE_VERSION: + description: "Override Version" + type: string + required: false + +permissions: + id-token: write + +jobs: + release-pr: + name: Release PR + runs-on: ubuntu-latest + + env: + INPUT_OVERRIDE_VERSION: ${{ github.event.inputs.OVERRIDE_VERSION }} + + steps: + # Assume an AWS Role that provides access to the Access Token + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 #v4 + with: + role-to-assume: ${{ secrets.RELEASE_WORKFLOW_ACCESS_TOKEN_ROLE_ARN }} + aws-region: us-west-2 + # Retrieve the Access Token from Secrets Manager + - name: Retrieve secret from AWS Secrets Manager + uses: aws-actions/aws-secretsmanager-get-secrets@v2 + with: + secret-ids: | + AWS_SECRET, ${{ secrets.RELEASE_WORKFLOW_ACCESS_TOKEN_NAME }} + parse-json-secrets: true + # Checkout a full clone of the repo + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: '0' + token: ${{ env.AWS_SECRET_TOKEN }} + # Install .NET8 which is needed for AutoVer + - name: Setup .NET 8.0 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + # Install AutoVer to automate versioning and changelog creation + - name: Install AutoVer + run: dotnet tool install --global AutoVer --version 0.0.24 + # Set up a git user to be able to run git commands later on + - name: Setup Git User + run: | + git config --global user.email "github-aws-sdk-dotnet-automation@amazon.com" + git config --global user.name "aws-sdk-dotnet-automation" + # Create the release branch which will contain the version changes and updated changelog + - name: Create Release Branch + id: create-release-branch + run: | + branch=releases/next-release + git checkout -b $branch + echo "BRANCH=$branch" >> $GITHUB_OUTPUT + # Update the version of projects based on the change files + - name: Increment Version + run: autover version + if: env.INPUT_OVERRIDE_VERSION == '' + # Update the version of projects based on the override version + - name: Increment Version + run: autover version --use-version "$INPUT_OVERRIDE_VERSION" + if: env.INPUT_OVERRIDE_VERSION != '' + # Update the changelog based on the change files + - name: Update Changelog + run: autover changelog + # Push the release branch up as well as the created tag + - name: Push Changes + run: | + branch=${{ steps.create-release-branch.outputs.BRANCH }} + git push origin $branch + git push origin $branch --tags + # Get the release name that will be used to create a PR + - name: Read Release Name + id: read-release-name + run: | + version=$(autover changelog --release-name) + echo "VERSION=$version" >> $GITHUB_OUTPUT + # Get the changelog that will be used to create a PR + - name: Read Changelog + id: read-changelog + run: | + changelog=$(autover changelog --output-to-console) + echo "CHANGELOG<> "$GITHUB_OUTPUT" + # Create the Release PR and label it + - name: Create Pull Request + env: + GITHUB_TOKEN: ${{ env.AWS_SECRET_TOKEN }} + run: | + pr_url="$(gh pr create --title "${{ steps.read-release-name.outputs.VERSION }}" --body "${{ steps.read-changelog.outputs.CHANGELOG }}" --base dev --head ${{ steps.create-release-branch.outputs.BRANCH }})" + gh label create "Release PR" --description "A Release PR that includes versioning and changelog changes" -c "#FF0000" -f + gh pr edit $pr_url --add-label "Release PR" \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..fd047d80 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,533 @@ +## Release 2024-10-09 + +### Amazon.Lambda.Tools (5.11.0) +* Add the `--log-format`, `--log-application-level`, `--log-system-level` and `--log-group` switches to the deploy-function command for configuring logging for the Lambda function. + +## Release 2024-07-09 + +### Amazon.Lambda.Tools (5.10.7) +* Fixed an issue where `CodeUri` set in `Globals` section is ignored for `AWS::Serverless::Function` resource. +### Amazon.ElasticBeanstalk.Tools (4.4.0) +* Added support for new command line parameter `--disable-imds-v1` to disable IMDSv1 for Elastic BeanStalk environments. + +## Release 2024-06-14 + +### Amazon.Lambda.Tools (5.10.6) +* Update the dependencies for the embedded zipping utility used to set file permissions correctly when creating deployment bundles on Windows + +## Release 2024-04-24 + +### Amazon.Lambda.Tools (5.10.5) +* Update User-Agent string +### Amazon.ECS.Tools (3.5.6) +* Update User-Agent string +### Amazon.ElasticBeanstalk.Tools (4.3.4) +* Update User-Agent string + +## Release 2024-04-04 + +### Amazon.Lambda.Tools (5.10.4) +* Fixed an issue where deploying .NET 8 Native AOT Web Apps fails because of a check that looks for the OutputType property explicitly in the .csproj. + +## Release 2024-03-14 + +### Amazon.Lambda.Tools (5.10.3) +* Fixed issue not correctly identifying running on Amazon Linux 2023 forcing a container build for Native AOT. + +## Release 2024-03-01 + +### Amazon.Lambda.Tools (5.10.2) +* Fixed incorrectly using "JSON Data" as the architecture value from CloudFormation template + +## Release 2024-02-23 + +### Amazon.Lambda.Tools (5.10.1) +* Fixed issue with the configured architecture of the Lambda function not being used when building the container image. This caused images to be built for X64 when the function was configured for ARM64. + +## Release 2024-02-12 + +### Amazon.Lambda.Tools (5.10.0) +* Added the default .NET 8 build image when using container builds. Container builds are most often used when building for Native AOT. + +## Release 2023-11-14 + +### Amazon.Lambda.Tools (5.9.0) +* For Amazon Linux 2023 when building for Native AOT container build defaults to false. This is the same behavior as Amazon Linux 2. + +## Release 2023-10-13 + +### Amazon.Lambda.Tools (5.8.1) +* Update AWSSDK dependencies. This is primarily to pull in a fix to support sso_session in the config file when using SSO credentials. +### Amazon.ECS.Tools (3.5.5) +* Update AWSSDK dependencies. This is primarily to pull in a fix to support sso_session in the config file when using SSO credentials. +### Amazon.ElasticBeanstalk.Tools (4.3.3) +* Update AWSSDK dependencies. This is primarily to pull in a fix to support sso_session in the config file when using SSO credentials. + +## Release 2023-09-11 + +### Amazon.ECS.Tools (3.5.4) +* Pull Request [#224](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/224) Fix task-definition-volumes and container-mount-points not work issue. Thanks [Gary zhurongbo111 ](https://github.com/zhurongbo111) + +## Release 2023-08-18 + +### Amazon.ECS.Tools (3.5.3) +* Pull Request [#286](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/286) to improve error reporting with ECS workflows. Thanks [Shruti Sinha](https://github.com/shruti0085) + +## Release 2023-08-02 + +### Amazon.Lambda.Tools (5.8.0) +* Pull Request [#287](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/287) adding a new `--stack-polling-delay` switch to control polling interval to CloudFormation. This is useful for environments that are seeing CloudFormation throttling issues. Thanks [Alex Gausman](https://github.com/alex-gausman). + +## Release 2023-06-28 + +### Amazon.Lambda.Tools (5.7.2) +* fix: ensure net6.0 runtimes are copied with the publish artifacts + +## Release 2023-06-26 + +### Amazon.Lambda.Tools (5.7.1) +* Improve error reporting back for AWS Toolkit for Visual Studio integration. + +## Release 2023-06-02 + +### Amazon.Lambda.Tools (5.7.0) +* Enabled support for using container builds for .NET 7 ARM. This includes support for producing .NET 7 ARM AOT Lambda functions. + +## Release 2023-04-13 + +### Amazon.Lambda.Tools (5.6.6) +* Fixed issue reading self contained property from project file. + +## Release 2023-04-11 + +### Amazon.Lambda.Tools (5.6.5) +* Allow self contained in csproj. +* Fixed an issue where lambda deploy-serverless command tries to build image when ImageUri is set in template without any Metadata. + +## Release 2023-03-15 + +### Amazon.Lambda.Tools (5.6.4) +* Fixed an issue which caused upgrading from an End-of-Life .NET version to a supported version to fail. + +## Release 2023-01-18 + +### Amazon.Lambda.Tools (5.6.3) +* Pull Request [#257](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/257) supporting non-root users when doing container based builds. Thanks [Jason T](https://github.com/jasonterando) +* Pull Request [#260](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/260) fixed typo in Security Groups option name. Thanks [Mohammad Sadegh Shad](https://github.com/m-sadegh-sh) + +## Release 2022-11-14 + +### Amazon.Lambda.Tools (5.6.2) +* Fixed regression in 5.6.0 that prevented the package command for non managed .NET runtime like .NET 5 and 7. This feature is required for SAM container image builds. + +## Release 2022-11-08 + +### Amazon.Lambda.Tools (5.6.1) +* Fixed regression in 5.6.0 that excluded pdb files from being packaged in deployment bundle breaking SAM debugger experience. + +## Release 2022-11-08 + +### Amazon.Lambda.Tools (5.6.0) +* Added support for deploying Native AOT .NET 7 Lambda functions. To enable Native AOT set the PublishAot property in project file to true. +* Added support for container builds when creating deployment bundle. + +## Release 2022-10-26 + +### Amazon.Lambda.Tools (5.5.0) +* Add new --resolve-s3 switch that can replace the --s3-bucket switch. When --resolve-s3 is set true the tool will ensure a default bucket exists and use that bucket for storing deployment bundles. + +## Release 2022-08-18 + +### Amazon.Common.DotNetCli.Tools (3.1.0.1) +* Fixes an issue where exception could occur while expanding null policy name and attaching it to a role. +### Amazon.Lambda.Tools (5.4.5) +* Fixes an issue where Lambda deploy-function fails when choosing option to add permissions later. +### Amazon.ECS.Tools (3.5.2) +* Updated to reference the latest version of Amazon.Common.DotNetCli.Tools. +### Amazon.ElasticBeanstalk.Tools (4.3.2) +* Updated to reference the latest version of Amazon.Common.DotNetCli.Tools. + +## Release 2022-06-27 + +### Amazon.Lambda.Tools (5.4.4) +* Bump Newtonsoft.Json to 13.0.1 + +## Release 2022-06-21 + +### Amazon.Lambda.Tools (5.4.3) +* Added ability to use DockerBuildArgs in Amazon.Lambda.Tools serverless template. + +## Release 2022-06-02 + +### Amazon.Lambda.Tools (5.4.2) +* Only modify Function Url if `--function-url-enable` flag is set. +* Fixed an issue where lambda push-image command was ignoring Docker options. + +## Release 2022-04-25 + +### Amazon.Lambda.Tools (5.4.1) +* Fixed issue when `--function-url-enable` is absent the function url config was unintendedly removed. + +## Release 2022-04-25 + +### Amazon.Lambda.Tools (5.4.0) +* Added `--function-url-enable` and `--function-url-auth` switches to configure Lambda Function Url. +* Added `--ephemerals-storage-size` switch to configure the size of writable the `/tmp` folder. +* Fixed issue with removing all values from the following collection properties: Environment Variables, Layers and VPC subnets and security groups. + +## Release 2022-02-14 + +### Amazon.Lambda.Tools (5.3.0) +* Package the tool targeting .NET 6 as well as the previous .NET Core 3.1 to support Mac M1 developers. +* Add .NET 6 target framework moniker to .NET 6 Lambda runtime enum mapping. +### Amazon.ECS.Tools (3.5.0) +* Package the tool targeting .NET 6 as well as the previous .NET Core 3.1 to support Mac M1 developers. +### Amazon.ElasticBeanstalk.Tools (4.3.0) +* Package the tool targeting .NET 6 as well as the previous .NET Core 3.1 to support Mac M1 developers. + +## Release 2021-09-29 + +### Amazon.Lambda.Tools (5.2.0) +* Added support for deploying ARM based Lambda functions with the new `--function-architecture` switch. + +## Release 2021-09-28 + +### Amazon.ECS.Tools (3.4.3) +* Fixed an issue where ECS log configuration argument is overwritten with awslogs defaults. + +## Release 2021-06-17 + +### Amazon.Lambda.Tools (5.1.4) +* Added reference to AWSSDK.SSO and AWSSDK.SSOOIDC for SSO flow. +### Amazon.ECS.Tools (3.4.2) +* Added reference to AWSSDK.SSO and AWSSDK.SSOOIDC for SSO flow. +### Amazon.ElasticBeanstalk.Tools (4.2.2) +* Added reference to AWSSDK.SSO and AWSSDK.SSOOIDC for SSO flow. + +## Release 2021-06-02 + +### Amazon.Lambda.Tools (5.1.3) +* Updated to version 3.7.0.27 of AWSSDK.Core +* Updated to version 3.7.1.15 of AWSSDK.SecurityToken +### Amazon.ECS.Tools (3.4.1) +* Updated to version 3.7.0.27 of AWSSDK.Core +* Updated to version 3.7.1.15 of AWSSDK.SecurityToken +### Amazon.ElasticBeanstalk.Tools (4.2.1) +* Updated to version 3.7.0.27 of AWSSDK.Core +* Updated to version 3.7.1.15 of AWSSDK.SecurityToken + +## Release 2021-05-03 + +### Amazon.Lambda.Tools (5.1.2) +* Pull request [#170](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/170) Fixed issue with unnecessary function config update when using VPC settings. Thanks [Abubaker Bashir](https://github.com/AbubakerB) +* Pull request [#169](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/169) Fixed issue with runtime and handler fields not being updated. Thanks [Abubaker Bashir](https://github.com/AbubakerB) + +## Release 2021-04-14 + +### Amazon.Lambda.Tools (5.1.1) +* Fixed an issue where relative paths in package-ci command were not working. + +## Release 2021-04-02 + +### Amazon.Lambda.Tools (5.1.0) +* Update to latest version of the AWS SDK for .NET. +### Amazon.ECS.Tools (3.4.0) +* Update to latest version of the AWS SDK for .NET. +### Amazon.ElasticBeanstalk.Tools (4.2.0) +* Update to latest version of the AWS SDK for .NET. + +## Release 2021-03-24 + +### Amazon.Lambda.Tools (5.01.0) +* Updated to version 3.7 of the AWS SDK for .NET +### Amazon.ECS.Tools (3.4.0) +* Updated to version 3.7 of the AWS SDK for .NET +### Amazon.ElasticBeanstalk.Tools (4.2.0) +* Updated to version 3.7 of the AWS SDK for .NET + +## Release 2021-03-24 + +### Amazon.Lambda.Tools (5.0.2) +* Updated version of the AWS SDK for .NET used to include support for SSO. +* Pull request [#163](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/163) Fixed random manifest names causing zip package hash refresh on every build. Thanks [aohotnik](https://github.com/aohotnik) +* Pull request [#152](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/152) Pass OriginalCommandLineArguments to Command constructor. Thanks [Vickram Ravichandran](https://github.com/vickramravichandran) +### Amazon.ECS.Tools (3.3.1) +* Updated version of the AWS SDK for .NET used to include support for SSO. +### Amazon.ElasticBeanstalk.Tools (4.1.1) +* Updated version of the AWS SDK for .NET used to include support for SSO. + +## Release 2021-01-21 + +### Amazon.Lambda.Tools (5.0.1) +* Fixed issue with handling Lambda projects that were multi targeting .NET versions +### Amazon.ECS.Tools (3.3.0) +* Added support for deploying scheduled tasks using AWS Fargate. +* The docker image tag will be used from either the newer `--image-tag` switch or the deprecated `--tag` switch. + +## Release 2020-12-01 + +### Amazon.Lambda.Tools (5.0.0) +* Updated deploy-function to have the following switches to support Lambda functions packaged as container images. + * `--package-type`: Determines the format for packaging Lambda function. Valid values are `zip` and `image`. Default is `zip`. + * `--image-entrypoint`: Overrides the image's ENTRYPOINT when package type is set `image` + * `--image-command`: Overrides the image's CMD when package type is set `image` + * `--image-working-directory`: Overrides the image's working directory when package type is set `image` + * `--image-tag`: Name and optionally a tag in the 'name:tag' format + * `--local-docker-image`: If set the docker build command is skipped and the indicated local image is pushed to ECR + * `--dockerfile`: The docker file used build image. Default value is "Dockerfile" + * `--docker-build-options`: Additional options passed to the "docker build" command + * `--docker-build-working-dir`: The directory to execute the "docker build" command from + * `--docker-host-build-output-dir`: If set a "dotnet publish" command is executed on the host machine before executing "docker build". The output can be copied into image being built. +* Updated `deploy-serverless` command to build and push Lambda functions as container images if CloudFormation resource has `PackageType` set to `image` +* Updated `package` command to build container image if `--package-type` is set to `image`. The image can later be used with `deploy-function` using the `--local-docker-image` +* Added push-image command to build .NET Lambda project and push to ECR + +## Release 2020-10-19 + +### Amazon.Lambda.Tools (4.3.0) +* Update to latest version of the AWS SDK for .NET. +### Amazon.ECS.Tools (3.2.0) +* Update to latest version of the AWS SDK for .NET. +### Amazon.ElasticBeanstalk.Tools (4.1.0) +* Update to latest version of the AWS SDK for .NET. + +## Release 2020-10-15 + +### Amazon.Lambda.Tools (4.2.0) +* Add support for creating .NET Lambda layers for .NET Core 3.1. + +## Release 2020-07-22 + +### Amazon.Lambda.Tools (4.1.0) +* Pull Request [$120](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/120): Echo the full `dotnet publish` command using during lambda deployment. Thanks [Tom Makin](https://github.com/tmakin) +* Fixed issue when publish PowerShell Lambda functions with PowerShell unable to find system modules folder when deployed to Lambda. + +## Release 2020-06-23 + +### Amazon.ElasticBeanstalk.Tools (4.0.0) +* Added support to to deploy to the new Beanstalk ".NET Core for Linux" platform. +* Added ability to enable sticky sessions. +* Added switch to do a self contained publish + +## Release 2020-03-31 + +### Amazon.Lambda.Tools (4.0.0) +* Added support to deploy to .NET Core 3.1 Lambda runtime +* Switch RID to linux-x64 when packaging runtimes on Amazon Linux 2. Currently that is only .NET Core 3.1. +* If `--runtime` is set by the user via `--msbuild-parameters` switch then Amazon.Lambda.Tools will not set the `--runtime` switch itself when calling `dotnet package`. +* Disable creating of Lambda layers for .NET Core 3.1 due to an issue in `dotnet store` command. Read here on the issue. https://github.com/dotnet/sdk/issues/10973 + +## Release 2019-09-17 + +### Amazon.Lambda.Tools (3.3.0) +* Fixed issue [#90](https://github.com/aws/aws-extensions-for-dotnet-cli/issues/90): Error parsing layer description while listing layers +* Fixed issue [#30](https://github.com/aws/aws-extensions-for-dotnet-cli/issues/30): Parsed yaml CloudFormaion template failure if there was no Properties node. +* Pull request [#89](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/89) Fixed typo warning how to set the DOTNET_SHARED_STORE environment varaible. Thanks [Oleg Kosmakov](https://github.com/kosmakoff) + +## Release 2019-08-16 + +### Amazon.Lambda.Tools (3.3.0) +* Added MFA support +* Add runtime config setting to roll forward to major versions of .NET Core if 2.X is not installed. +### Amazon.ECS.Tools (3.1.0) +* Added MFA support +* Add runtime config setting to roll forward to major versions of .NET Core if 2.X is not installed. +### Amazon.ElasticBeanstalk.Tools (3.2.0) +* Added MFA support +* Add runtime config setting to roll forward to major versions of .NET Core if 2.X is not installed. + + +## Release 2019-05-02 + +### Amazon.Lambda.Tools (3.2.3) +* Fixed issue filename or extension is too long when passing a large number of file arguments to the zip utility. + +## Release 2019-04-19 + +### Amazon.Lambda.Tools (3.2.2) +* Fixed issue with package not being able to installed on non-windows platforms. + +## Release 2019-04-18 + +### Amazon.Lambda.Tools (3.2.1) +* Removed ASP.NET Core version check. This is no longer needed now that the .NET Core SDK no longer sets the runtime version to the latest patched version that is installed on the machine that is creating the deployment package. +* Fixed issue of not handling embedded node.js or python code in CloudFormation template. + +## Release 2019-03-25 + +### Amazon.Lambda.Tools (3.2.0) +* Added support for using .NET Core runtime package stores as Lambda layers. For a full description checkout the [.NET Lambda Layer docs](https://github.com/aws/aws-extensions-for-dotnet-cli/blob/master/docs/Layers.md). +* Fixed issue with Windows line ending when deploy a Custom Runtime Lambda function. + +## Release 2019-03-18 + +### Amazon.Lambda.Tools (3.1.4) +* Make `--framework` switch optional. If it is not set then the project file will be inspected to determine framework. +* Add deprecation warning message when using .NET Core 2.0 Lambda runtime. + +## Release 2019-03-07 + +### Amazon.ElasticBeanstalk.Tools (3.1.0) +* Pull request [#55](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/55) add **package** command to package an application as a zip file to later be deployed to Beanstalk. Thanks [Anthony Abate](https://github.com/abbotware) +* Pull Request [#57](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/57) allows string parameters to point to environment variables. Thanks [Anthony Abate](https://github.com/abbotware) + * For example the in the following **aws-beanstalk-tools-defaults.json** file the Beanstalk application name will come from the EB_APP + environment variable and the environment name will come from EB_ENV. +```json +{ + "application" : "$(EN_APP)", + "environment" : "$(EB_ENV)" +} +``` + +## Release 2019-03-06 + +### Amazon.Lambda.Tools (3.1.3) +* Changes to get this tool ready for the upcoming ability to use a custom .NET Core runtimes. +Follow [#405](https://github.com/aws/aws-lambda-dotnet/issues/405) GitHub issue for the upcoming **Amazon.Lambda.RuntimeSupport** library. + * Zipping the deployment bundle on Windows was switch to use a new Go executable to +allow setting linux file permisisons. The Go executable is distributed with this tool so this change should be transparent to users. +* Fixed issue with config files specified with the `--config-file` not being found when the `--project-location` +switch was used. + +## Release 2019-01-04 + +### Amazon.Lambda.Tools (3.1.2) +* Fixed issue with failed deployments when CloudFormation template was greater then 50,000 . +* Added support for CAPABILITY_AUTO_EXPAND for deploy-serverless command. + +## Release 2018-11-19 + +### Amazon.Lambda.Tools (3.1.1) +* Fix issue looking for Lambda runtime from CloudFormation template when runtime specified in the Globals section. +### Amazon.ElasticBeanstalk.Tools (3.0.1) +* Pull request [#43](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/43), fixing issue with wrong directory separater when creating zip file. Thanks [bartoszsiekanski](https://github.com/bartoszsiekanski) + +## Release 2018-10-12 + +### Amazon.Lambda.Tools (3.1.0) +* Updated the `deploy-serverless` and `package-ci` command to support deploying multiple projects. +Each `AWS::Lambda::Function` or `AWS::Serverless::Function` can now point to different .NET projects locally using the CloudFormation resource's code properties. +If the code property is not set then the current directory assumed. +* Pull request [#39](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/39), fixing issue related to yaml templates containing intrinsic functions in the short form. Thanks to [Albert Szilvasy](https://github.com/szilvaa) +* Added `--tags` property to `deploy-serverless` command to apply AWS Tags to the CloudFormation stack and the resources the stack creates. + +## Release 2018-09-11 + +### Amazon.Lambda.Tools (3.0.1) +* Fixed issue incorrectly checking if deployment command was being executed in a project directory when using a precompiled package zip file. + +## Release 2018-09-10 + +### Amazon.Lambda.Tools (3.0.0) +* Switch to Global Tool. +* Made the **--apply-defaults** switch **obsolete**. Defaults from config file are now always applied. +* Added new **--append-environment-variables** switch to add new environment variables without overwriting existing environment variables. +* Added validation that if a config file is explicitly set and the file can not be found then throw an exception +* Improve error reporting when failed to parse command line arguments. +* Pull request [#29](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/29) changing publishing RID to rhel.7.2-x64 the closest match to Amazon Linux. +* **PreserveCompilationContext** in the **--msbuild-parameters** switch overrides this tool's default behavior of setting /p:PreserveCompilationContext=false. +* Fixed bug incorrectly executing chmod on a file with spaces in the name. +* Add ability to pass AWS credentials using the switches --aws-access-key-id, --aws-secret-key and --aws-session-token +### Amazon.ECS.Tools (3.0.0) +* Switch to Global Tool. +### Amazon.ElasticBeanstalk.Tools (3.0.0) +* Switch to Global Tool. + +## Release 2018-07-09 + +### Amazon.Lambda.Tools (2.2.0) +* Added support for the .NET Core 2.1 AWS Lambda runtime. +* Fixed issue with not correct determining CloudFormation parameters when using YAML. +* Fixed issue handling CloudFormation parameter renames. +### Amazon.ECS.Tools (1.2.0) +* Improve detection for when the `docker build` command should run from the solution folder. +* Added new switch `--docker-build-working-dir` to set the directory where `docker build` should run. This is useful when this tool can't detect whether the build should run from the project or the solution. +* Added new switch `--docker-build-options` to pass additional options to the `docker build` command. + +## Relesae 2018-05-29 + +### Amazon.Lambda.Tools (2.1.4) +* Change AWS credential lookup logic to continue searching if the profile specified cannot be found. This allows +easier switching between development environment and CI/CD environments. +* Pull request [#11](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/11). Fixed issue with `deploy-serverless` breaking Swagger definitions in yaml. +* Fixed issue when validating version of Microsoft.AspNetCore.All for F# project files. +* Switch to warning when validating S3 bucket in same region as target deployment region if the region can not be determined. This is commonly due to lack of +S3 permission to get the region for a bucket. +### Amazon.ECS.Tools (1.1.5) +* Change AWS credential lookup logic to continue searching if the profile specified cannot be found. This allows +easier switching between development environment and CI/CD environments. +* Add `--publish-options` switch to allow passing additional parameters to the `dotnet publish` command. +### Amazon.ElasticBeanstalk.Tools (1.1.4) +* Change AWS credential lookup logic to continue searching if the profile specified cannot be found. This allows +easier switching between development environment and CI/CD environments. +* Add `--publish-options` switch to allow passing additional parameters to the `dotnet publish` command. +* Fixed issue with instance profile not being persisted when the flat to save configuration is set. + +## Release 2018-04-30 + +### Amazon.Lambda.Tools (2.1.2) +* If a CloudFormation parameter's NoEcho property is to true then output **** when displaying the template parameters set for the deployment. +* Stop persisting **--stack-wait** switch when saving config file because it will always be set to false when called from Visual Studio. + +## Release 2018-03-26 + +### Amazon.Lambda.Tools (2.1.2) +* Moved here from the [AWS Lambda for .NET Core](https://github.com/aws/aws-lambda-dotnet) repository +### Amazon.ElasticBeanstalk.Tools (1.1.3) +* Fixed issue with setting the IAM service role for new Beanstalk environments +* Fixed issue with Beanstalk Solution Stack not being persisted in defaults file. +* All commands can now persist the settings used with the **-pcfg true** flag. +### Amazon.ECS.Tools (1.1.4) +* All commands can now persist the settings used with the **-pcfg true** flag. + +## Release 2018-03-13 + +### Amazon.ECS.Tools (1.1.3) +* Fixed issue detecting docker build working directory for latest VS 2017 created Dockerfile. +* Fixed issue not detected when a cluster should be created because of inactive cluster with the same name. +### Amazon.ElasticBeanstalk.Tools (1.1.2) +* Pull request [#8](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/8). Add **--version-label** switch to set a version label when deploying. Thanks to [kalexii](https://github.com/kalexii). + +## Release 2018-02-25 + +### Amazon.ECS.Tools (1.1.2) +* Fixed issue with docker tag incorrectly being written out to the aws-beanstalk-tools-defaults.json. +* Fixed error handling when searching for the solution file for the project being deployed. + +## Release 2018-02-14 + +### Amazon.ECS.Tools (1.1.1) +* Added dependency to **AWSSDK.SecurityToken** to support profiles that use assume role features of Security Token Service. +* Allow task defintion cpu and memory to be read from **aws-ecs-tools-defaults.json** either as a string or number. Previously only string was supported. +* Fixed issue with reading desired count from **aws-ecs-tools-defaults.json**. +* Fixed issue persisting last settings for scheduled task to **aws-ecs-tools-defaults.json**. +### Amazon.ElasticBeanstalk.Tools (1.1.1) +* Added dependency to **AWSSDK.SecurityToken** to support profiles that use assume role features of Security Token Service. + +## Release 2018-02-02 + +### Amazon.ElasticBeanstalk.Tools (1.1.0) +* Add **--enable-xray** switch to enable the AWS X-Ray daemon in the environment + +## Release 2018-01-21 + +### Amazon.ECS.Tools (1.1.0) +* Use default subnets if no subnets provided for Fargate deployments +* Inspect Docker file to see if **dotnet publish** needs to run before **docker build** +* If redeploying to an existing Fargate service reuse network configuration if one is not provided +* Fix issue with docker image name being asked for multiple times +### Amazon.ElasticBeanstalk.Tools (1.0.1) +* Set description for NuGet package + +## Release 2017-11-29 + +### Amazon.ECS.Tools (1.0.0) +* Added command **deploy-service** +* Added command **deploy-task** +* Added command **deploy-task** +* Added command **deploy-scheduled-task** +* Added command **push-image** +### Amazon.ElasticBeanstalk.Tools (1.0.0) +* Added command **deploy-environment** +* Added command **delete-environment** +* Added command **list-environments** diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ee37301b..f1820fa7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -39,6 +39,51 @@ To send us a pull request, please: GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). +## Adding a `change file` to your contribution branch + +Each contribution branch should include a `change file` that contains a changelog message for each project that has been updated, as well as the type of increment to perform for those changes when versioning the project. + +A `change file` looks like the following example: +```json +{ + "Projects": [ + { + "Name": "Amazon.Lambda.Tools", + "Type": "Patch", + "ChangelogMessages": [ + "Fixed an issue causing a failure somewhere" + ] + } + ] +} +``` +The `change file` lists all the modified projects, the changelog message for each project as well as the increment type. + +These files are located in the repo at .autover/changes/ + +You can use the `AutoVer` tool to create the change file. You can install it using the following command: +``` +dotnet tool install -g AutoVer +``` + +You can create the `change file` using the following command: +``` +autover change --project-name "Amazon.Lambda.Tools" -m "Fixed an issue causing a failure somewhere +``` +Note: Make sure to run the command from the root of the repository. + +You can update the command to specify which project you are updating. +The available projects are: +* Amazon.ECS.Tools +* Amazon.ElasticBeanstalk.Tools +* Amazon.Lambda.Tools + +The possible increment types are: +* Patch +* Minor +* Major + +Note: You do not need to create a new `change file` for every changelog message or project within your branch. You can create one `change file` that contains all the modified projects and the changelog messages. ## Finding contributions to work on Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels ((enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/aws/aws-extensions-for-dotnet-cli/labels/help%20wanted) issues is a great place to start. diff --git a/RELEASE.CHANGELOG.md b/RELEASE.CHANGELOG.md deleted file mode 100644 index 9f10da31..00000000 --- a/RELEASE.CHANGELOG.md +++ /dev/null @@ -1,466 +0,0 @@ -### Release 2024-10-09 -* **Amazon.Lambda.Tools (5.11.0)** - * Add the `--log-format`, `--log-application-level`, `--log-system-level` and `--log-group` switches to the deploy-function command for configuring logging for the Lambda function. - - -### Release 2024-07-09 -* **Amazon.Lambda.Tools (5.10.7)** - * Fixed an issue where `CodeUri` set in `Globals` section is ignored for `AWS::Serverless::Function` resource. -* **Amazon.ElasticBeanstalk.Tools (4.4.0)** - * Added support for new command line parameter `--disable-imds-v1` to disable IMDSv1 for Elastic BeanStalk environments. - -### Release 2024-06-14 -* **Amazon.Lambda.Tools (5.10.6)** - * Update the dependencies for the embedded zipping utility used to set file permissions correctly when creating deployment bundles on Windows - -### Release 2024-04-24 -* **Amazon.Lambda.Tools (5.10.5)** - * Update User-Agent string -* **Amazon.ECS.Tools (3.5.6)** - * Update User-Agent string -* **Amazon.ElasticBeanstalk.Tools (4.3.4)** - * Update User-Agent string - -### Release 2024-04-04 -* **Amazon.Lambda.Tools (5.10.4)** - * Fixed an issue where deploying .NET 8 Native AOT Web Apps fails because of a check that looks for the OutputType property explicitly in the .csproj. - -### Release 2024-03-14 -* **Amazon.Lambda.Tools (5.10.3)** - * Fixed issue not correctly identifying running on Amazon Linux 2023 forcing a container build for Native AOT. - -### Release 2024-03-01 -* **Amazon.Lambda.Tools (5.10.2)** - * Fixed incorrectly using "JSON Data" as the architecture value from CloudFormation template - -### Release 2024-02-23 -* **Amazon.Lambda.Tools (5.10.1)** - * Fixed issue with the configured architecture of the Lambda function not being used when building the container image. This caused images to be built for X64 when the function was configured for ARM64. - -### Release 2024-02-12 -* **Amazon.Lambda.Tools (5.10.0)** - * Added the default .NET 8 build image when using container builds. Container builds are most often used when building for Native AOT. - -### Release 2023-11-14 -* **Amazon.Lambda.Tools (5.9.0)** - * For Amazon Linux 2023 when building for Native AOT container build defaults to false. This is the same behavior as Amazon Linux 2. - -### Release 2023-10-13 -* **Amazon.Lambda.Tools (5.8.1)** - * Update AWSSDK dependencies. This is primarily to pull in a fix to support sso_session in the config file when using SSO credentials. -* **Amazon.ECS.Tools (3.5.5)** - * Update AWSSDK dependencies. This is primarily to pull in a fix to support sso_session in the config file when using SSO credentials. -* **Amazon.ElasticBeanstalk.Tools (4.3.3)** - * Update AWSSDK dependencies. This is primarily to pull in a fix to support sso_session in the config file when using SSO credentials. - -### Release 2023-09-11 -* **Amazon.ECS.Tools (3.5.4)** - * Pull Request [#224](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/224) Fix task-definition-volumes and container-mount-points not work issue. Thanks [Gary zhurongbo111 ](https://github.com/zhurongbo111) - -### Release 2023-08-18 -* **Amazon.ECS.Tools (3.5.3)** - * Pull Request [#286](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/286) to improve error reporting with ECS workflows. Thanks [Shruti Sinha](https://github.com/shruti0085) - -### Release 2023-08-02 -* **Amazon.Lambda.Tools (5.8.0)** - * Pull Request [#287](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/287) adding a new `--stack-polling-delay` switch to control polling interval to CloudFormation. This is useful for environments that are seeing CloudFormation throttling issues. Thanks [Alex Gausman](https://github.com/alex-gausman). - -### Release 2023-06-28 -* **Amazon.Lambda.Tools (5.7.2)** - * fix: ensure net6.0 runtimes are copied with the publish artifacts - -### Release 2023-06-26 -* **Amazon.Lambda.Tools (5.7.1)** - * Improve error reporting back for AWS Toolkit for Visual Studio integration. - -### Release 2023-06-02 -* **Amazon.Lambda.Tools (5.7.0)** - * Enabled support for using container builds for .NET 7 ARM. This includes support for producing .NET 7 ARM AOT Lambda functions. - -### Release 2023-04-13 -* **Amazon.Lambda.Tools (5.6.6)** - * Fixed issue reading self contained property from project file. - -### Release 2023-04-11 -* **Amazon.Lambda.Tools (5.6.5)** - * Allow self contained in csproj. - * Fixed an issue where lambda deploy-serverless command tries to build image when ImageUri is set in template without any Metadata. - -### Release 2023-03-15 -* **Amazon.Lambda.Tools (5.6.4)** - * Fixed an issue which caused upgrading from an End-of-Life .NET version to a supported version to fail. - -### Release 2023-01-18 -* **Amazon.Lambda.Tools (5.6.3)** - * Pull Request [#257](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/257) supporting non-root users when doing container based builds. Thanks [Jason T](https://github.com/jasonterando) - * Pull Request [#260](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/260) fixed typo in Security Groups option name. Thanks [Mohammad Sadegh Shad](https://github.com/m-sadegh-sh) - -### Release 2022-11-14 -* **Amazon.Lambda.Tools (5.6.2)** - * Fixed regression in 5.6.0 that prevented the package command for non managed .NET runtime like .NET 5 and 7. This feature is required for SAM container image builds. - -### Release 2022-11-08 -* **Amazon.Lambda.Tools (5.6.1)** - * Fixed regression in 5.6.0 that excluded pdb files from being packaged in deployment bundle breaking SAM debugger experience. - -### Release 2022-11-08 -* **Amazon.Lambda.Tools (5.6.0)** - * Added support for deploying Native AOT .NET 7 Lambda functions. To enable Native AOT set the PublishAot property in project file to true. - * Added support for container builds when creating deployment bundle. - -### Release 2022-10-26 -* **Amazon.Lambda.Tools (5.5.0)** - * Add new --resolve-s3 switch that can replace the --s3-bucket switch. When --resolve-s3 is set true the tool will ensure a default bucket exists and use that bucket for storing deployment bundles. - -### Release 2022-08-18 -* **Amazon.Common.DotNetCli.Tools (3.1.0.1)** - * Fixes an issue where exception could occur while expanding null policy name and attaching it to a role. -* **Amazon.Lambda.Tools (5.4.5)** - * Fixes an issue where Lambda deploy-function fails when choosing option to add permissions later. -* **Amazon.ECS.Tools (3.5.2)** - * Updated to reference the latest version of Amazon.Common.DotNetCli.Tools. -* **Amazon.ElasticBeanstalk.Tools (4.3.2)** - * Updated to reference the latest version of Amazon.Common.DotNetCli.Tools. - -### Release 2022-06-27 -* **Amazon.Lambda.Tools (5.4.4)** - * Bump Newtonsoft.Json to 13.0.1 - -### Release 2022-06-21 -* **Amazon.Lambda.Tools (5.4.3)** - * Added ability to use DockerBuildArgs in Amazon.Lambda.Tools serverless template. - -### Release 2022-06-02 -* **Amazon.Lambda.Tools (5.4.2)** - * Only modify Function Url if `--function-url-enable` flag is set. - * Fixed an issue where lambda push-image command was ignoring Docker options. - -### Release 2022-04-25 -* **Amazon.Lambda.Tools (5.4.1)** - * Fixed issue when `--function-url-enable` is absent the function url config was unintendedly removed. - -### Release 2022-04-25 -* **Amazon.Lambda.Tools (5.4.0)** - * Added `--function-url-enable` and `--function-url-auth` switches to configure Lambda Function Url. - * Added `--ephemerals-storage-size` switch to configure the size of writable the `/tmp` folder. - * Fixed issue with removing all values from the following collection properties: Environment Variables, Layers and VPC subnets and security groups. - -### Release 2022-02-14 -* **Amazon.Lambda.Tools (5.3.0)** - * Package the tool targeting .NET 6 as well as the previous .NET Core 3.1 to support Mac M1 developers. - * Add .NET 6 target framework moniker to .NET 6 Lambda runtime enum mapping. -* **Amazon.ECS.Tools (3.5.0)** - * Package the tool targeting .NET 6 as well as the previous .NET Core 3.1 to support Mac M1 developers. -* **Amazon.ElasticBeanstalk.Tools (4.3.0)** - * Package the tool targeting .NET 6 as well as the previous .NET Core 3.1 to support Mac M1 developers. - -### Release 2021-09-29 -* **Amazon.Lambda.Tools (5.2.0)** - * Added support for deploying ARM based Lambda functions with the new `--function-architecture` switch. - -### Release 2021-09-28 -* **Amazon.ECS.Tools (3.4.3)** - * Fixed an issue where ECS log configuration argument is overwritten with awslogs defaults. - -### Release 2021-06-17 -* **Amazon.Lambda.Tools (5.1.4)** - * Added reference to AWSSDK.SSO and AWSSDK.SSOOIDC for SSO flow. -* **Amazon.ECS.Tools (3.4.2)** - * Added reference to AWSSDK.SSO and AWSSDK.SSOOIDC for SSO flow. -* **Amazon.ElasticBeanstalk.Tools (4.2.2)** - * Added reference to AWSSDK.SSO and AWSSDK.SSOOIDC for SSO flow. - -### Release 2021-06-02 -* **Amazon.Lambda.Tools (5.1.3)** - * Updated to version 3.7.0.27 of AWSSDK.Core - * Updated to version 3.7.1.15 of AWSSDK.SecurityToken -* **Amazon.ECS.Tools (3.4.1)** - * Updated to version 3.7.0.27 of AWSSDK.Core - * Updated to version 3.7.1.15 of AWSSDK.SecurityToken -* **Amazon.ElasticBeanstalk.Tools (4.2.1)** - * Updated to version 3.7.0.27 of AWSSDK.Core - * Updated to version 3.7.1.15 of AWSSDK.SecurityToken - -### Release 2021-05-03 -* **Amazon.Lambda.Tools (5.1.2)** - * Pull request [#170](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/170) Fixed issue with unnecessary function config update when using VPC settings. Thanks [Abubaker Bashir](https://github.com/AbubakerB) - * Pull request [#169](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/169) Fixed issue with runtime and handler fields not being updated. Thanks [Abubaker Bashir](https://github.com/AbubakerB) - -### Release 2021-04-14 -* **Amazon.Lambda.Tools (5.1.1)** - * Fixed an issue where relative paths in package-ci command were not working. - -### Release 2021-04-02 -* **Amazon.Lambda.Tools (5.1.0)** - * Update to latest version of the AWS SDK for .NET. -* **Amazon.ECS.Tools (3.4.0)** - * Update to latest version of the AWS SDK for .NET. -* **Amazon.ElasticBeanstalk.Tools (4.2.0)** - * Update to latest version of the AWS SDK for .NET. - -### Release 2021-03-24 -* **Amazon.Lambda.Tools (5.01.0)** - * Updated to version 3.7 of the AWS SDK for .NET -* **Amazon.ECS.Tools (3.4.0)** - * Updated to version 3.7 of the AWS SDK for .NET -* **Amazon.ElasticBeanstalk.Tools (4.2.0)** - * Updated to version 3.7 of the AWS SDK for .NET - -### Release 2021-03-24 -* **Amazon.Lambda.Tools (5.0.2)** - * Updated version of the AWS SDK for .NET used to include support for SSO. - * Pull request [#163](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/163) Fixed random manifest names causing zip package hash refresh on every build. Thanks [aohotnik](https://github.com/aohotnik) - * Pull request [#152](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/152) Pass OriginalCommandLineArguments to Command constructor. Thanks [Vickram Ravichandran](https://github.com/vickramravichandran) -* **Amazon.ECS.Tools (3.3.1)** - * Updated version of the AWS SDK for .NET used to include support for SSO. -* **Amazon.ElasticBeanstalk.Tools (4.1.1)** - * Updated version of the AWS SDK for .NET used to include support for SSO. - -### Release 2021-01-21 -* **Amazon.Lambda.Tools (5.0.1)** - * Fixed issue with handling Lambda projects that were multi targeting .NET versions -* **Amazon.ECS.Tools (3.3.0)** - * Added support for deploying scheduled tasks using AWS Fargate. - * The docker image tag will be used from either the newer `--image-tag` switch or the deprecated `--tag` switch. - -### Release 2020-12-01 -* **Amazon.Lambda.Tools (5.0.0)** - * Updated deploy-function to have the following switches to support Lambda functions packaged as container images. - * `--package-type`: Determines the format for packaging Lambda function. Valid values are `zip` and `image`. Default is `zip`. - * `--image-entrypoint`: Overrides the image's ENTRYPOINT when package type is set `image` - * `--image-command`: Overrides the image's CMD when package type is set `image` - * `--image-working-directory`: Overrides the image's working directory when package type is set `image` - * `--image-tag`: Name and optionally a tag in the 'name:tag' format - * `--local-docker-image`: If set the docker build command is skipped and the indicated local image is pushed to ECR - * `--dockerfile`: The docker file used build image. Default value is "Dockerfile" - * `--docker-build-options`: Additional options passed to the "docker build" command - * `--docker-build-working-dir`: The directory to execute the "docker build" command from - * `--docker-host-build-output-dir`: If set a "dotnet publish" command is executed on the host machine before executing "docker build". The output can be copied into image being built. - * Updated `deploy-serverless` command to build and push Lambda functions as container images if CloudFormation resource has `PackageType` set to `image` - * Updated `package` command to build container image if `--package-type` is set to `image`. The image can later be used with `deploy-function` using the `--local-docker-image` - * Added push-image command to build .NET Lambda project and push to ECR - -### Release 2020-10-19 -* **Amazon.Lambda.Tools (4.3.0)** - * Update to latest version of the AWS SDK for .NET. -* **Amazon.ECS.Tools (3.2.0)** - * Update to latest version of the AWS SDK for .NET. -* **Amazon.ElasticBeanstalk.Tools (4.1.0)** - * Update to latest version of the AWS SDK for .NET. - -### Release 2020-10-15 -* **Amazon.Lambda.Tools (4.2.0)** - * Add support for creating .NET Lambda layers for .NET Core 3.1. - -### Release 2020-07-22 -* **Amazon.Lambda.Tools (4.1.0)** - * Pull Request [$120](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/120): Echo the full `dotnet publish` command using during lambda deployment. Thanks [Tom Makin](https://github.com/tmakin) - * Fixed issue when publish PowerShell Lambda functions with PowerShell unable to find system modules folder when deployed to Lambda. - -### Release 2020-06-23 -* **Amazon.ElasticBeanstalk.Tools (4.0.0)** - * Added support to to deploy to the new Beanstalk ".NET Core for Linux" platform. - * Added ability to enable sticky sessions. - * Added switch to do a self contained publish - -### Release 2020-03-31 -* **Amazon.Lambda.Tools (4.0.0)** - * Added support to deploy to .NET Core 3.1 Lambda runtime - * Switch RID to linux-x64 when packaging runtimes on Amazon Linux 2. Currently that is only .NET Core 3.1. - * If `--runtime` is set by the user via `--msbuild-parameters` switch then Amazon.Lambda.Tools will not set the `--runtime` switch itself when calling `dotnet package`. - * Disable creating of Lambda layers for .NET Core 3.1 due to an issue in `dotnet store` command. Read here on the issue. https://github.com/dotnet/sdk/issues/10973 - -### Release 2019-09-17 -* **Amazon.Lambda.Tools (3.3.0)** - * Fixed issue [#90](https://github.com/aws/aws-extensions-for-dotnet-cli/issues/90): Error parsing layer description while listing layers - * Fixed issue [#30](https://github.com/aws/aws-extensions-for-dotnet-cli/issues/30): Parsed yaml CloudFormaion template failure if there was no Properties node. - * Pull request [#89](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/89) Fixed typo warning how to set the DOTNET_SHARED_STORE environment varaible. Thanks [Oleg Kosmakov](https://github.com/kosmakoff) -### Release 2019-08-16 -* **Amazon.Lambda.Tools (3.3.0)** - * Added MFA support - * Add runtime config setting to roll forward to major versions of .NET Core if 2.X is not installed. -* **Amazon.ECS.Tools (3.1.0)** - * Added MFA support - * Add runtime config setting to roll forward to major versions of .NET Core if 2.X is not installed. -* **Amazon.ElasticBeanstalk.Tools (3.2.0)** - * Added MFA support - * Add runtime config setting to roll forward to major versions of .NET Core if 2.X is not installed. - - -### Release 2019-05-02 -* **Amazon.Lambda.Tools (3.2.3)** - * Fixed issue filename or extension is too long when passing a large number of file arguments to the zip utility. - -### Release 2019-04-19 -* **Amazon.Lambda.Tools (3.2.2)** - * Fixed issue with package not being able to installed on non-windows platforms. - -### Release 2019-04-18 -* **Amazon.Lambda.Tools (3.2.1)** - * Removed ASP.NET Core version check. This is no longer needed now that the .NET Core SDK no longer sets the runtime version to the latest patched version that is installed on the machine that is creating the deployment package. - * Fixed issue of not handling embedded node.js or python code in CloudFormation template. - -### Release 2019-03-25 -* **Amazon.Lambda.Tools (3.2.0)** - * Added support for using .NET Core runtime package stores as Lambda layers. For a full description checkout the [.NET Lambda Layer docs](https://github.com/aws/aws-extensions-for-dotnet-cli/blob/master/docs/Layers.md). - * Fixed issue with Windows line ending when deploy a Custom Runtime Lambda function. - -### Release 2019-03-18 -* **Amazon.Lambda.Tools (3.1.4)** - * Make `--framework` switch optional. If it is not set then the project file will be inspected to determine framework. - * Add deprecation warning message when using .NET Core 2.0 Lambda runtime. - -### Release 2019-03-07 -* **Amazon.ElasticBeanstalk.Tools (3.1.0)** - * Pull request [#55](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/55) add **package** command to package an application as a zip file to later be deployed to Beanstalk. Thanks [Anthony Abate](https://github.com/abbotware) - * Pull Request [#57](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/57) allows string parameters to point to environment variables. Thanks [Anthony Abate](https://github.com/abbotware) - * For example the in the following **aws-beanstalk-tools-defaults.json** file the Beanstalk application name will come from the EB_APP - environment variable and the environment name will come from EB_ENV. -```json -{ - "application" : "$(EN_APP)", - "environment" : "$(EB_ENV)" -} -``` - -### Release 2019-03-06 -* **Amazon.Lambda.Tools (3.1.3)** - * Changes to get this tool ready for the upcoming ability to use a custom .NET Core runtimes. -Follow [#405](https://github.com/aws/aws-lambda-dotnet/issues/405) GitHub issue for the upcoming **Amazon.Lambda.RuntimeSupport** library. - * Zipping the deployment bundle on Windows was switch to use a new Go executable to -allow setting linux file permisisons. The Go executable is distributed with this tool so this change should be transparent to users. - * Fixed issue with config files specified with the `--config-file` not being found when the `--project-location` -switch was used. - -### Release 2019-01-04 -* **Amazon.Lambda.Tools (3.1.2)** - * Fixed issue with failed deployments when CloudFormation template was greater then 50,000 . - * Added support for CAPABILITY_AUTO_EXPAND for deploy-serverless command. - -### Release 2018-11-19 -* **Amazon.Lambda.Tools (3.1.1)** - * Fix issue looking for Lambda runtime from CloudFormation template when runtime specified in the Globals section. -* **Amazon.ElasticBeanstalk.Tools (3.0.1)** - * Pull request [#43](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/43), fixing issue with wrong directory separater when creating zip file. Thanks [bartoszsiekanski](https://github.com/bartoszsiekanski) - -### Release 2018-10-12 -* **Amazon.Lambda.Tools (3.1.0)** - * Updated the `deploy-serverless` and `package-ci` command to support deploying multiple projects. -Each `AWS::Lambda::Function` or `AWS::Serverless::Function` can now point to different .NET projects locally using the CloudFormation resource's code properties. -If the code property is not set then the current directory assumed. - * Pull request [#39](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/39), fixing issue related to yaml templates containing intrinsic functions in the short form. Thanks to [Albert Szilvasy](https://github.com/szilvaa) - * Added `--tags` property to `deploy-serverless` command to apply AWS Tags to the CloudFormation stack and the resources the stack creates. - -### Release 2018-09-11 -* **Amazon.Lambda.Tools (3.0.1)** - * Fixed issue incorrectly checking if deployment command was being executed in a project directory when using a precompiled package zip file. - -### Release 2018-09-10 -* **Amazon.Lambda.Tools (3.0.0)** - * Switch to Global Tool. - * Made the **--apply-defaults** switch **obsolete**. Defaults from config file are now always applied. - * Added new **--append-environment-variables** switch to add new environment variables without overwriting existing environment variables. - * Added validation that if a config file is explicitly set and the file can not be found then throw an exception - * Improve error reporting when failed to parse command line arguments. - * Pull request [#29](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/29) changing publishing RID to rhel.7.2-x64 the closest match to Amazon Linux. - * **PreserveCompilationContext** in the **--msbuild-parameters** switch overrides this tool's default behavior of setting /p:PreserveCompilationContext=false. - * Fixed bug incorrectly executing chmod on a file with spaces in the name. - * Add ability to pass AWS credentials using the switches --aws-access-key-id, --aws-secret-key and --aws-session-token -* **Amazon.ECS.Tools (3.0.0)** - * Switch to Global Tool. -* **Amazon.ElasticBeanstalk.Tools (3.0.0)** - * Switch to Global Tool. - -### Release 2018-07-09 -* **Amazon.Lambda.Tools (2.2.0)** - * Added support for the .NET Core 2.1 AWS Lambda runtime. - * Fixed issue with not correct determining CloudFormation parameters when using YAML. - * Fixed issue handling CloudFormation parameter renames. -* **Amazon.ECS.Tools (1.2.0)** - * Improve detection for when the `docker build` command should run from the solution folder. - * Added new switch `--docker-build-working-dir` to set the directory where `docker build` should run. This is useful when this tool can't detect whether the build should run from the project or the solution. - * Added new switch `--docker-build-options` to pass additional options to the `docker build` command. - -### Relesae 2018-05-29 -* **Amazon.Lambda.Tools (2.1.4)** - * Change AWS credential lookup logic to continue searching if the profile specified cannot be found. This allows -easier switching between development environment and CI/CD environments. - * Pull request [#11](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/11). Fixed issue with `deploy-serverless` breaking Swagger definitions in yaml. - * Fixed issue when validating version of Microsoft.AspNetCore.All for F# project files. - * Switch to warning when validating S3 bucket in same region as target deployment region if the region can not be determined. This is commonly due to lack of -S3 permission to get the region for a bucket. - -* **Amazon.ECS.Tools (1.1.5)** - * Change AWS credential lookup logic to continue searching if the profile specified cannot be found. This allows -easier switching between development environment and CI/CD environments. - * Add `--publish-options` switch to allow passing additional parameters to the `dotnet publish` command. -* **Amazon.ElasticBeanstalk.Tools (1.1.4)** - * Change AWS credential lookup logic to continue searching if the profile specified cannot be found. This allows -easier switching between development environment and CI/CD environments. - * Add `--publish-options` switch to allow passing additional parameters to the `dotnet publish` command. - * Fixed issue with instance profile not being persisted when the flat to save configuration is set. - -### Release 2018-04-30 -* **Amazon.Lambda.Tools (2.1.2)** - * If a CloudFormation parameter's NoEcho property is to true then output **** when displaying the template parameters set for the deployment. - * Stop persisting **--stack-wait** switch when saving config file because it will always be set to false when called from Visual Studio. - -### Release 2018-03-26 -* **Amazon.Lambda.Tools (2.1.2)** - * Moved here from the [AWS Lambda for .NET Core](https://github.com/aws/aws-lambda-dotnet) repository -* **Amazon.ElasticBeanstalk.Tools (1.1.3)** - * Fixed issue with setting the IAM service role for new Beanstalk environments - * Fixed issue with Beanstalk Solution Stack not being persisted in defaults file. - * All commands can now persist the settings used with the **-pcfg true** flag. -* **Amazon.ECS.Tools (1.1.4)** - * All commands can now persist the settings used with the **-pcfg true** flag. - -### Release 2018-03-13 - -* **Amazon.ECS.Tools (1.1.3)** - * Fixed issue detecting docker build working directory for latest VS 2017 created Dockerfile. - * Fixed issue not detected when a cluster should be created because of inactive cluster with the same name. -* **Amazon.ElasticBeanstalk.Tools (1.1.2)** - * Pull request [#8](https://github.com/aws/aws-extensions-for-dotnet-cli/pull/8). Add **--version-label** switch to set a version label when deploying. Thanks to [kalexii](https://github.com/kalexii). - -### Release 2018-02-25 - -* **Amazon.ECS.Tools (1.1.2)** - * Fixed issue with docker tag incorrectly being written out to the aws-beanstalk-tools-defaults.json. - * Fixed error handling when searching for the solution file for the project being deployed. - -### Release 2018-02-14 - -* **Amazon.ECS.Tools (1.1.1)** - * Added dependency to **AWSSDK.SecurityToken** to support profiles that use assume role features of Security Token Service. - * Allow task defintion cpu and memory to be read from **aws-ecs-tools-defaults.json** either as a string or number. Previously only string was supported. - * Fixed issue with reading desired count from **aws-ecs-tools-defaults.json**. - * Fixed issue persisting last settings for scheduled task to **aws-ecs-tools-defaults.json**. - -* **Amazon.ElasticBeanstalk.Tools (1.1.1)** - * Added dependency to **AWSSDK.SecurityToken** to support profiles that use assume role features of Security Token Service. - -### Release 2018-02-02 -* **Amazon.ElasticBeanstalk.Tools (1.1.0)** - * Add **--enable-xray** switch to enable the AWS X-Ray daemon in the environment - -### Release 2018-01-21 -* **Amazon.ECS.Tools (1.1.0)** - * Use default subnets if no subnets provided for Fargate deployments - * Inspect Docker file to see if **dotnet publish** needs to run before **docker build** - * If redeploying to an existing Fargate service reuse network configuration if one is not provided - * Fix issue with docker image name being asked for multiple times -* **Amazon.ElasticBeanstalk.Tools (1.0.1)** - * Set description for NuGet package - -### Release 2017-11-29 -* **Amazon.ECS.Tools (1.0.0)** - * Added command **deploy-service** - * Added command **deploy-task** - * Added command **deploy-task** - * Added command **deploy-scheduled-task** - * Added command **push-image** -* **Amazon.ElasticBeanstalk.Tools (1.0.0)** - * Added command **deploy-environment** - * Added command **delete-environment** - * Added command **list-environments** diff --git a/src/Amazon.Common.DotNetCli.Tools/Amazon.Common.DotNetCli.Tools.csproj b/src/Amazon.Common.DotNetCli.Tools/Amazon.Common.DotNetCli.Tools.csproj index 2ebc4ce2..8500202a 100644 --- a/src/Amazon.Common.DotNetCli.Tools/Amazon.Common.DotNetCli.Tools.csproj +++ b/src/Amazon.Common.DotNetCli.Tools/Amazon.Common.DotNetCli.Tools.csproj @@ -2,8 +2,6 @@ netcoreapp3.1;net6.0 - 3.1.0.1 - 3.1.0.1 From 5c8d1dc9d69355c2cba486ae02ac7c2c14c100a8 Mon Sep 17 00:00:00 2001 From: Ashish Dhingra <67916761+ashishdhingra@users.noreply.github.com> Date: Wed, 30 Oct 2024 14:33:04 -0700 Subject: [PATCH 05/26] Fixed an issue where primitive values in payload for InvokeFunctionCommand were not working. --- .../8795398d-3505-4b1f-8d8f-eadf6d32d4db.json | 11 +++++ aws-extensions-for-dotnet-cli.sln | 9 +++- .../Commands/InvokeFunctionCommand.cs | 16 +++++-- .../Amazon.Lambda.Tools.Test.csproj | 1 + test/Amazon.Lambda.Tools.Test/DeployTest.cs | 45 ++++++++++++++++++- testapps/TestIntegerFunction/Function.cs | 17 +++++++ .../TestIntegerFunction.csproj | 14 ++++++ .../aws-lambda-tools-defaults.json | 5 +++ 8 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 .autover/changes/8795398d-3505-4b1f-8d8f-eadf6d32d4db.json create mode 100644 testapps/TestIntegerFunction/Function.cs create mode 100644 testapps/TestIntegerFunction/TestIntegerFunction.csproj create mode 100644 testapps/TestIntegerFunction/aws-lambda-tools-defaults.json diff --git a/.autover/changes/8795398d-3505-4b1f-8d8f-eadf6d32d4db.json b/.autover/changes/8795398d-3505-4b1f-8d8f-eadf6d32d4db.json new file mode 100644 index 00000000..dce52f7d --- /dev/null +++ b/.autover/changes/8795398d-3505-4b1f-8d8f-eadf6d32d4db.json @@ -0,0 +1,11 @@ +{ + "Projects": [ + { + "Name": "Amazon.Lambda.Tools", + "Type": "Patch", + "ChangelogMessages": [ + "Fixed an issue where primitive values in payload for InvokeFunctionCommand were not working." + ] + } + ] +} \ No newline at end of file diff --git a/aws-extensions-for-dotnet-cli.sln b/aws-extensions-for-dotnet-cli.sln index cb8ef54d..58ba0fea 100644 --- a/aws-extensions-for-dotnet-cli.sln +++ b/aws-extensions-for-dotnet-cli.sln @@ -63,7 +63,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Amazon.Lambda.Tools.Integ.T EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestHttpFunction", "testapps\TestHttpFunction\TestHttpFunction.csproj", "{AD31D053-97C5-4262-B187-EC42BFD51A9F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestNativeAotNet8WebApp", "testapps\TestNativeAotNet8WebApp\TestNativeAotNet8WebApp.csproj", "{69FFA03C-D29F-40E0-9E7F-572D5E10AF77}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestNativeAotNet8WebApp", "testapps\TestNativeAotNet8WebApp\TestNativeAotNet8WebApp.csproj", "{69FFA03C-D29F-40E0-9E7F-572D5E10AF77}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestIntegerFunction", "testapps\TestIntegerFunction\TestIntegerFunction.csproj", "{D7F1DFA4-066B-469C-B04C-DF032CF152C1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -163,6 +165,10 @@ Global {69FFA03C-D29F-40E0-9E7F-572D5E10AF77}.Debug|Any CPU.Build.0 = Debug|Any CPU {69FFA03C-D29F-40E0-9E7F-572D5E10AF77}.Release|Any CPU.ActiveCfg = Release|Any CPU {69FFA03C-D29F-40E0-9E7F-572D5E10AF77}.Release|Any CPU.Build.0 = Release|Any CPU + {D7F1DFA4-066B-469C-B04C-DF032CF152C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D7F1DFA4-066B-469C-B04C-DF032CF152C1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D7F1DFA4-066B-469C-B04C-DF032CF152C1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D7F1DFA4-066B-469C-B04C-DF032CF152C1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -193,6 +199,7 @@ Global {7B2AE176-8AB5-4050-8E22-A2A80E88BB92} = {BB0A8314-3127-4159-8B6A-64F97FEF9474} {AD31D053-97C5-4262-B187-EC42BFD51A9F} = {BB3CF729-8213-4DDD-85AE-A5E7754F3944} {69FFA03C-D29F-40E0-9E7F-572D5E10AF77} = {BB3CF729-8213-4DDD-85AE-A5E7754F3944} + {D7F1DFA4-066B-469C-B04C-DF032CF152C1} = {BB3CF729-8213-4DDD-85AE-A5E7754F3944} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DBFC70D6-49A2-40A1-AB08-5D9504AB7112} diff --git a/src/Amazon.Lambda.Tools/Commands/InvokeFunctionCommand.cs b/src/Amazon.Lambda.Tools/Commands/InvokeFunctionCommand.cs index c7a9e943..a895199e 100644 --- a/src/Amazon.Lambda.Tools/Commands/InvokeFunctionCommand.cs +++ b/src/Amazon.Lambda.Tools/Commands/InvokeFunctionCommand.cs @@ -62,7 +62,6 @@ protected override void ParseCommandArguments(CommandOptions values) protected override async Task PerformActionAsync() { - var invokeRequest = new InvokeRequest { FunctionName = this.GetStringValueOrDefault(this.FunctionName, LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_NAME, true), @@ -81,9 +80,20 @@ protected override async Task PerformActionAsync() invokeRequest.Payload = this.Payload.Trim(); } - if(!invokeRequest.Payload.StartsWith("{")) + // We should still check for empty payload in case it is read from a file. + if (!string.IsNullOrEmpty(invokeRequest.Payload)) { - invokeRequest.Payload = "\"" + invokeRequest.Payload + "\""; + if (invokeRequest.Payload[0] != '\"' && invokeRequest.Payload[0] != '{' && invokeRequest.Payload[0] != '[') + { + double d; + long l; + bool b; + if (!double.TryParse(invokeRequest.Payload, out d) && !long.TryParse(invokeRequest.Payload, out l) && + !bool.TryParse(invokeRequest.Payload, out b)) + { + invokeRequest.Payload = "\"" + invokeRequest.Payload + "\""; + } + } } } diff --git a/test/Amazon.Lambda.Tools.Test/Amazon.Lambda.Tools.Test.csproj b/test/Amazon.Lambda.Tools.Test/Amazon.Lambda.Tools.Test.csproj index 80b0d159..949d8051 100644 --- a/test/Amazon.Lambda.Tools.Test/Amazon.Lambda.Tools.Test.csproj +++ b/test/Amazon.Lambda.Tools.Test/Amazon.Lambda.Tools.Test.csproj @@ -74,6 +74,7 @@ + diff --git a/test/Amazon.Lambda.Tools.Test/DeployTest.cs b/test/Amazon.Lambda.Tools.Test/DeployTest.cs index 762528eb..a37b0f70 100644 --- a/test/Amazon.Lambda.Tools.Test/DeployTest.cs +++ b/test/Amazon.Lambda.Tools.Test/DeployTest.cs @@ -310,7 +310,50 @@ public async Task RunDeployCommand() } } } - + + [Fact] + public async Task RunDeployAndInvokeWithIntegerPayloadCommand() + { + var assembly = this.GetType().GetTypeInfo().Assembly; + var toolLogger = new TestToolLogger(_testOutputHelper); + + var fullPath = Path.GetFullPath(Path.GetDirectoryName(assembly.Location) + "../../../../../../testapps/TestIntegerFunction"); + var command = new DeployFunctionCommand(toolLogger, fullPath, new string[0]); + command.FunctionName = "test-function-intpayload-" + DateTime.Now.Ticks; + command.Handler = "TestIntegerFunction::TestIntegerFunction.Function::FunctionHandler"; + command.Timeout = 10; + command.MemorySize = 512; + command.Role = await TestHelper.GetTestRoleArnAsync(); + command.Configuration = "Release"; + command.Runtime = "dotnet6"; + command.DisableInteractive = true; + + var created = await command.ExecuteAsync(); + try + { + Assert.True(created); + + await LambdaUtilities.WaitTillFunctionAvailableAsync(new TestToolLogger(_testOutputHelper), command.LambdaClient, command.FunctionName); + + toolLogger.ClearBuffer(); + + var invokeCommand = new InvokeFunctionCommand(toolLogger, fullPath, new string[0]); + invokeCommand.FunctionName = command.FunctionName; + invokeCommand.Payload = "42"; + + await invokeCommand.ExecuteAsync(); + + Assert.Contains("\"Hello 42\"", toolLogger.Buffer); + } + finally + { + if (created) + { + await command.LambdaClient.DeleteFunctionAsync(command.FunctionName); + } + } + } + [Fact] public async Task TestPowerShellLambdaParallelTestCommand() { diff --git a/testapps/TestIntegerFunction/Function.cs b/testapps/TestIntegerFunction/Function.cs new file mode 100644 index 00000000..918f71f1 --- /dev/null +++ b/testapps/TestIntegerFunction/Function.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace TestIntegerFunction +{ + + public class Function + { + [Amazon.Lambda.Core.LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))] + public string FunctionHandler(int input) + { + return "Hello " + input; + } + } +} diff --git a/testapps/TestIntegerFunction/TestIntegerFunction.csproj b/testapps/TestIntegerFunction/TestIntegerFunction.csproj new file mode 100644 index 00000000..d42b3bd8 --- /dev/null +++ b/testapps/TestIntegerFunction/TestIntegerFunction.csproj @@ -0,0 +1,14 @@ + + + net6.0 + TestIntegerFunction + Library + TestIntegerFunction + false + false + false + + + + + \ No newline at end of file diff --git a/testapps/TestIntegerFunction/aws-lambda-tools-defaults.json b/testapps/TestIntegerFunction/aws-lambda-tools-defaults.json new file mode 100644 index 00000000..7c429a6a --- /dev/null +++ b/testapps/TestIntegerFunction/aws-lambda-tools-defaults.json @@ -0,0 +1,5 @@ +{ + "region": "us-east-2", + "disable-version-check": true, + "function-memory-size": 128 +} From 5a717b2801d33cc9a96494e19304cdecc9d05ec4 Mon Sep 17 00:00:00 2001 From: Philip Pittle Date: Fri, 1 Nov 2024 17:29:59 -0700 Subject: [PATCH 06/26] Add support for enabling SnapStart with deploy-function and update-function-config commands. --- .../Amazon.Lambda.Tools.csproj | 2 +- .../Commands/DeployFunctionCommand.cs | 13 ++++++++++++ .../Commands/GetFunctionConfigCommand.cs | 6 ++++++ .../Commands/UpdateFunctionConfigCommand.cs | 20 +++++++++++++++++++ .../LambdaDefinedCommandOptions.cs | 11 +++++++++- .../Amazon.Lambda.Tools.Test.csproj | 2 +- 6 files changed, 51 insertions(+), 3 deletions(-) diff --git a/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj b/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj index 8a248049..f16fbad0 100644 --- a/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj +++ b/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj @@ -37,7 +37,7 @@ - + diff --git a/src/Amazon.Lambda.Tools/Commands/DeployFunctionCommand.cs b/src/Amazon.Lambda.Tools/Commands/DeployFunctionCommand.cs index d346f28e..e5ec667c 100644 --- a/src/Amazon.Lambda.Tools/Commands/DeployFunctionCommand.cs +++ b/src/Amazon.Lambda.Tools/Commands/DeployFunctionCommand.cs @@ -85,6 +85,8 @@ public class DeployFunctionCommand : UpdateFunctionConfigCommand LambdaDefinedCommandOptions.ARGUMENT_LOG_APPLICATION_LEVEL, LambdaDefinedCommandOptions.ARGUMENT_LOG_SYSTEM_LEVEL, LambdaDefinedCommandOptions.ARGUMENT_LOG_GROUP, + + LambdaDefinedCommandOptions.ARGUMENT_SNAP_START_APPLY_ON }); public string Architecture { get; set; } @@ -181,6 +183,9 @@ protected override void ParseCommandArguments(CommandOptions values) this.ContainerImageForBuild = tuple.Item2.StringValue; if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_CODE_MOUNT_DIRECTORY.Switch)) != null) this.CodeMountDirectory = tuple.Item2.StringValue; + + if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_SNAP_START_APPLY_ON.Switch)) != null) + this.SnapStartApplyOn = tuple.Item2.StringValue; } @@ -424,6 +429,11 @@ protected override async Task PerformActionAsync() createRequest.TracingConfig = new TracingConfig { Mode = tracingMode }; } + var snapStartApplyOn = this.GetStringValueOrDefault(this.SnapStartApplyOn, LambdaDefinedCommandOptions.ARGUMENT_SNAP_START_APPLY_ON, false); + if (!string.IsNullOrEmpty(snapStartApplyOn)) + { + createRequest.SnapStart = new SnapStart {ApplyOn = Amazon.Lambda.SnapStartApplyOn.FindValue(snapStartApplyOn)}; + } try { @@ -639,6 +649,9 @@ protected override void SaveConfigFile(JsonData data) data.SetIfNotNull(LambdaDefinedCommandOptions.ARGUMENT_LOG_APPLICATION_LEVEL.ConfigFileKey, this.GetStringValueOrDefault(this.LogApplicationLevel, LambdaDefinedCommandOptions.ARGUMENT_LOG_APPLICATION_LEVEL, false)); data.SetIfNotNull(LambdaDefinedCommandOptions.ARGUMENT_LOG_SYSTEM_LEVEL.ConfigFileKey, this.GetStringValueOrDefault(this.LogSystemLevel, LambdaDefinedCommandOptions.ARGUMENT_LOG_SYSTEM_LEVEL, false)); data.SetIfNotNull(LambdaDefinedCommandOptions.ARGUMENT_LOG_GROUP.ConfigFileKey, this.GetStringValueOrDefault(this.LogGroup, LambdaDefinedCommandOptions.ARGUMENT_LOG_GROUP, false)); + + data.SetIfNotNull(LambdaDefinedCommandOptions.ARGUMENT_SNAP_START_APPLY_ON.ConfigFileKey, this.GetStringValueOrDefault(this.SnapStartApplyOn, LambdaDefinedCommandOptions.ARGUMENT_SNAP_START_APPLY_ON, false)); + } } } diff --git a/src/Amazon.Lambda.Tools/Commands/GetFunctionConfigCommand.cs b/src/Amazon.Lambda.Tools/Commands/GetFunctionConfigCommand.cs index 50aa7155..b76333f1 100644 --- a/src/Amazon.Lambda.Tools/Commands/GetFunctionConfigCommand.cs +++ b/src/Amazon.Lambda.Tools/Commands/GetFunctionConfigCommand.cs @@ -116,6 +116,12 @@ protected override async Task PerformActionAsync() this.Logger.WriteLine("Dead Letter Target:".PadRight(PAD_SIZE) + response.DeadLetterConfig.TargetArn); } + if (!string.IsNullOrEmpty(response.SnapStart?.ApplyOn?.Value)) + { + this.Logger.WriteLine("SnapStart"); + this.Logger.WriteLine(" Apply On:".PadRight(PAD_SIZE) + response.SnapStart.ApplyOn.Value); + this.Logger.WriteLine(" Optimization Status:".PadRight(PAD_SIZE) + response.SnapStart?.OptimizationStatus?.Value ?? ""); + } if (response.Environment?.Variables?.Count > 0) { diff --git a/src/Amazon.Lambda.Tools/Commands/UpdateFunctionConfigCommand.cs b/src/Amazon.Lambda.Tools/Commands/UpdateFunctionConfigCommand.cs index b884fe6a..161c2764 100644 --- a/src/Amazon.Lambda.Tools/Commands/UpdateFunctionConfigCommand.cs +++ b/src/Amazon.Lambda.Tools/Commands/UpdateFunctionConfigCommand.cs @@ -60,6 +60,8 @@ public class UpdateFunctionConfigCommand : LambdaBaseCommand LambdaDefinedCommandOptions.ARGUMENT_LOG_APPLICATION_LEVEL, LambdaDefinedCommandOptions.ARGUMENT_LOG_SYSTEM_LEVEL, LambdaDefinedCommandOptions.ARGUMENT_LOG_GROUP, + + LambdaDefinedCommandOptions.ARGUMENT_SNAP_START_APPLY_ON }); public string FunctionName { get; set; } @@ -97,6 +99,7 @@ public class UpdateFunctionConfigCommand : LambdaBaseCommand public string LogApplicationLevel { get; set; } public string LogSystemLevel { get; set; } public string LogGroup { get; set; } + public string SnapStartApplyOn { get; set; } public UpdateFunctionConfigCommand(IToolLogger logger, string workingDirectory, string[] args) @@ -181,6 +184,9 @@ protected override void ParseCommandArguments(CommandOptions values) this.LogSystemLevel = tuple.Item2.StringValue; if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_LOG_GROUP.Switch)) != null) this.LogGroup = tuple.Item2.StringValue; + + if ((tuple = values.FindCommandOption(LambdaDefinedCommandOptions.ARGUMENT_SNAP_START_APPLY_ON.Switch)) != null) + this.SnapStartApplyOn = tuple.Item2.StringValue; } @@ -703,6 +709,20 @@ private UpdateFunctionConfigurationRequest CreateConfigurationRequestIfDifferent } } + var snapStartApplyOn = this.GetStringValueOrDefault(this.SnapStartApplyOn, LambdaDefinedCommandOptions.ARGUMENT_SNAP_START_APPLY_ON, false); + if (!string.IsNullOrEmpty(snapStartApplyOn)) + { + if (null == request.SnapStart) + request.SnapStart = new SnapStart(); + + if (!string.Equals(existingConfiguration?.SnapStart?.ApplyOn?.Value, snapStartApplyOn, StringComparison.Ordinal)) + { + request.SnapStart.ApplyOn = snapStartApplyOn; + different = true; + } + } + + if (!different) return null; diff --git a/src/Amazon.Lambda.Tools/LambdaDefinedCommandOptions.cs b/src/Amazon.Lambda.Tools/LambdaDefinedCommandOptions.cs index fbf40ed7..7df2b81b 100644 --- a/src/Amazon.Lambda.Tools/LambdaDefinedCommandOptions.cs +++ b/src/Amazon.Lambda.Tools/LambdaDefinedCommandOptions.cs @@ -4,7 +4,7 @@ namespace Amazon.Lambda.Tools { /// /// This class defines all the possible options across all the commands. The individual commands will then - /// references the options that are appropiate. + /// references the options that are appropriate. /// public static class LambdaDefinedCommandOptions { @@ -522,5 +522,14 @@ public static class LambdaDefinedCommandOptions ValueType = CommandOption.CommandOptionValueType.StringValue, Description = $"The name of the Amazon CloudWatch log group the function sends logs to. Default is /aws/lambda/." }; + public static readonly CommandOption ARGUMENT_SNAP_START_APPLY_ON = + new CommandOption + { + Name = "SnapStart Apply On", + Switch = "--snap-start-apply-on", + ShortSwitch = "-sa", + ValueType = CommandOption.CommandOptionValueType.StringValue, + Description = "Configure when a snapshot of the initialized execution environment should be taken. Valid values are: PublishedVersions, None. Default is None.", + }; } } diff --git a/test/Amazon.Lambda.Tools.Test/Amazon.Lambda.Tools.Test.csproj b/test/Amazon.Lambda.Tools.Test/Amazon.Lambda.Tools.Test.csproj index 80b0d159..108e14fc 100644 --- a/test/Amazon.Lambda.Tools.Test/Amazon.Lambda.Tools.Test.csproj +++ b/test/Amazon.Lambda.Tools.Test/Amazon.Lambda.Tools.Test.csproj @@ -56,7 +56,7 @@ - + From e71762b3bbd9d06a699ba51a064b43de8be077ea Mon Sep 17 00:00:00 2001 From: aws-sdk-dotnet-automation Date: Fri, 1 Nov 2024 19:36:28 +0000 Subject: [PATCH 07/26] Release 2024-11-01 --- src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj b/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj index 8a248049..af606178 100644 --- a/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj +++ b/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj @@ -1,4 +1,4 @@ - + Amazon.Lambda.Tools adds commands to the dotnet cli to deploy AWS Lambda functions. @@ -15,7 +15,7 @@ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. AWS Lambda Tools for .NET CLI false - 5.11.0 + 5.11.1 @@ -49,7 +49,6 @@ - + \ No newline at end of file From 1b144c3bf6ace62794089d6eb4c723fa84ea8fe5 Mon Sep 17 00:00:00 2001 From: aws-sdk-dotnet-automation Date: Fri, 1 Nov 2024 19:36:29 +0000 Subject: [PATCH 08/26] Updated changelog --- .autover/autover.json | 38 +++++++++---------- .../8795398d-3505-4b1f-8d8f-eadf6d32d4db.json | 11 ------ CHANGELOG.md | 5 +++ 3 files changed, 24 insertions(+), 30 deletions(-) delete mode 100644 .autover/changes/8795398d-3505-4b1f-8d8f-eadf6d32d4db.json diff --git a/.autover/autover.json b/.autover/autover.json index 15f2b11e..8266c3de 100644 --- a/.autover/autover.json +++ b/.autover/autover.json @@ -1,20 +1,20 @@ { - "Projects": [ - { - "Name": "Amazon.ECS.Tools", - "Path": "src/Amazon.ECS.Tools/Amazon.ECS.Tools.csproj" - }, - { - "Name": "Amazon.ElasticBeanstalk.Tools", - "Path": "src/Amazon.ElasticBeanstalk.Tools/Amazon.ElasticBeanstalk.Tools.csproj" - }, - { - "Name": "Amazon.Lambda.Tools", - "Path": "src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj" - } - ], - "UseCommitsForChangelog": false, - "UseSameVersionForAllProjects": false, - "DefaultIncrementType": "Patch", - "ChangeFilesDetermineIncrementType": true - } \ No newline at end of file + "Projects": [ + { + "Name": "Amazon.ECS.Tools", + "Path": "src/Amazon.ECS.Tools/Amazon.ECS.Tools.csproj" + }, + { + "Name": "Amazon.ElasticBeanstalk.Tools", + "Path": "src/Amazon.ElasticBeanstalk.Tools/Amazon.ElasticBeanstalk.Tools.csproj" + }, + { + "Name": "Amazon.Lambda.Tools", + "Path": "src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj" + } + ], + "UseCommitsForChangelog": false, + "UseSameVersionForAllProjects": false, + "DefaultIncrementType": "Patch", + "ChangeFilesDetermineIncrementType": true +} \ No newline at end of file diff --git a/.autover/changes/8795398d-3505-4b1f-8d8f-eadf6d32d4db.json b/.autover/changes/8795398d-3505-4b1f-8d8f-eadf6d32d4db.json deleted file mode 100644 index dce52f7d..00000000 --- a/.autover/changes/8795398d-3505-4b1f-8d8f-eadf6d32d4db.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "Projects": [ - { - "Name": "Amazon.Lambda.Tools", - "Type": "Patch", - "ChangelogMessages": [ - "Fixed an issue where primitive values in payload for InvokeFunctionCommand were not working." - ] - } - ] -} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index fd047d80..4862c540 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## Release 2024-11-01 + +### Amazon.Lambda.Tools (5.11.1) +* Fixed an issue where primitive values in payload for InvokeFunctionCommand were not working. + ## Release 2024-10-09 ### Amazon.Lambda.Tools (5.11.0) From 71d4a6a4d8fcbafc325d610cef108c2e7ac89600 Mon Sep 17 00:00:00 2001 From: Norm Johanson Date: Wed, 6 Nov 2024 09:47:10 -0800 Subject: [PATCH 09/26] Fixed issue detecting if log parameters have changed since previous deployment. (#343) --- CHANGELOG.md | 1 + aws-extensions-for-dotnet-cli.sln | 2 +- .../Commands/UpdateFunctionConfigCommand.cs | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4862c540..d3f641ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Amazon.Lambda.Tools (5.11.1) * Fixed an issue where primitive values in payload for InvokeFunctionCommand were not working. +* Fixed issue detecting if log parameters have changed since previous deployment. ## Release 2024-10-09 diff --git a/aws-extensions-for-dotnet-cli.sln b/aws-extensions-for-dotnet-cli.sln index 58ba0fea..c3e5653e 100644 --- a/aws-extensions-for-dotnet-cli.sln +++ b/aws-extensions-for-dotnet-cli.sln @@ -25,8 +25,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Amazon.ECS.Tools.Test", "te EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{90827CB6-7488-4B53-904B-F045BCC754F3}" ProjectSection(SolutionItems) = preProject + CHANGELOG.md = CHANGELOG.md README.md = README.md - RELEASE.CHANGELOG.md = RELEASE.CHANGELOG.md EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Amazon.Lambda.Tools", "src\Amazon.Lambda.Tools\Amazon.Lambda.Tools.csproj", "{26CEBD54-FC5B-4437-A009-6643EE849413}" diff --git a/src/Amazon.Lambda.Tools/Commands/UpdateFunctionConfigCommand.cs b/src/Amazon.Lambda.Tools/Commands/UpdateFunctionConfigCommand.cs index b884fe6a..7e9525c5 100644 --- a/src/Amazon.Lambda.Tools/Commands/UpdateFunctionConfigCommand.cs +++ b/src/Amazon.Lambda.Tools/Commands/UpdateFunctionConfigCommand.cs @@ -651,7 +651,7 @@ private UpdateFunctionConfigurationRequest CreateConfigurationRequestIfDifferent request.LoggingConfig = new LoggingConfig(); } - if (!string.Equals(request.LoggingConfig.LogFormat, existingConfiguration.LoggingConfig?.LogFormat, StringComparison.Ordinal)) + if (!string.Equals(logFormat, existingConfiguration.LoggingConfig?.LogFormat, StringComparison.Ordinal)) { request.LoggingConfig.LogFormat = logFormat; different = true; @@ -666,7 +666,7 @@ private UpdateFunctionConfigurationRequest CreateConfigurationRequestIfDifferent request.LoggingConfig = new LoggingConfig(); } - if (!string.Equals(request.LoggingConfig.ApplicationLogLevel, existingConfiguration.LoggingConfig?.ApplicationLogLevel, StringComparison.Ordinal)) + if (!string.Equals(logApplicationLevel, existingConfiguration.LoggingConfig?.ApplicationLogLevel, StringComparison.Ordinal)) { request.LoggingConfig.ApplicationLogLevel = logApplicationLevel; different = true; @@ -681,7 +681,7 @@ private UpdateFunctionConfigurationRequest CreateConfigurationRequestIfDifferent request.LoggingConfig = new LoggingConfig(); } - if (!string.Equals(request.LoggingConfig.SystemLogLevel, existingConfiguration.LoggingConfig?.SystemLogLevel, StringComparison.Ordinal)) + if (!string.Equals(logSystemLevel, existingConfiguration.LoggingConfig?.SystemLogLevel, StringComparison.Ordinal)) { request.LoggingConfig.SystemLogLevel = logSystemLevel; different = true; @@ -696,7 +696,7 @@ private UpdateFunctionConfigurationRequest CreateConfigurationRequestIfDifferent request.LoggingConfig = new LoggingConfig(); } - if (!string.Equals(request.LoggingConfig.LogGroup, existingConfiguration.LoggingConfig?.LogGroup, StringComparison.Ordinal)) + if (!string.Equals(logGroup, existingConfiguration.LoggingConfig?.LogGroup, StringComparison.Ordinal)) { request.LoggingConfig.LogGroup = logGroup; different = true; From 642bfa27e0dafe2cb737e4160a1d4661bb1dcd13 Mon Sep 17 00:00:00 2001 From: Ashish Dhingra <67916761+ashishdhingra@users.noreply.github.com> Date: Wed, 6 Nov 2024 11:06:01 -0800 Subject: [PATCH 10/26] Fixed ApplySettingsTest.SetLoggingPropertiesForUpdateRequest test for Amazon.Lambda.Tools to expect correct type while invoking UpdateFunctionConfigurationAsync(). --- test/Amazon.Lambda.Tools.Test/ApplySettingsTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Amazon.Lambda.Tools.Test/ApplySettingsTest.cs b/test/Amazon.Lambda.Tools.Test/ApplySettingsTest.cs index 8cbe4ed7..0a557826 100644 --- a/test/Amazon.Lambda.Tools.Test/ApplySettingsTest.cs +++ b/test/Amazon.Lambda.Tools.Test/ApplySettingsTest.cs @@ -109,7 +109,7 @@ public async Task SetLoggingPropertiesForUpdateRequest() Assert.Equal("DEBUG", request.LoggingConfig.ApplicationLogLevel); Assert.Equal("WARN", request.LoggingConfig.SystemLogLevel); }) - .Returns((CreateFunctionRequest r, CancellationToken token) => + .Returns((UpdateFunctionConfigurationRequest r, CancellationToken token) => { return Task.FromResult(new UpdateFunctionConfigurationResponse()); }); From 403457e3b560c30ad1ba80bc991f5da8f4a0fc16 Mon Sep 17 00:00:00 2001 From: Phil Asmar Date: Fri, 8 Nov 2024 15:19:17 -0500 Subject: [PATCH 11/26] fix: fixed an issue causing lambda package to hang in CI/CD --- .../changes/e52deae1-471a-4119-b874-5ef0ccf690b3.json | 11 +++++++++++ src/Amazon.Lambda.Tools/LambdaDotNetCLIWrapper.cs | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .autover/changes/e52deae1-471a-4119-b874-5ef0ccf690b3.json diff --git a/.autover/changes/e52deae1-471a-4119-b874-5ef0ccf690b3.json b/.autover/changes/e52deae1-471a-4119-b874-5ef0ccf690b3.json new file mode 100644 index 00000000..c01ebc11 --- /dev/null +++ b/.autover/changes/e52deae1-471a-4119-b874-5ef0ccf690b3.json @@ -0,0 +1,11 @@ +{ + "Projects": [ + { + "Name": "Amazon.Lambda.Tools", + "Type": "Patch", + "ChangelogMessages": [ + "Fixed an issue causing 'lambda package' to hang when ran in CI/CD." + ] + } + ] +} \ No newline at end of file diff --git a/src/Amazon.Lambda.Tools/LambdaDotNetCLIWrapper.cs b/src/Amazon.Lambda.Tools/LambdaDotNetCLIWrapper.cs index fd25b56d..40f8dc61 100644 --- a/src/Amazon.Lambda.Tools/LambdaDotNetCLIWrapper.cs +++ b/src/Amazon.Lambda.Tools/LambdaDotNetCLIWrapper.cs @@ -217,7 +217,7 @@ public int Publish(LambdaToolsDefaults defaults, string projectLocation, string proc.EnableRaisingEvents = true; - proc.WaitForExit(); + proc.WaitForExit(int.MaxValue); exitCode = proc.ExitCode; } From 6f44e64fd4e88c75b625e6394582812103d5a896 Mon Sep 17 00:00:00 2001 From: aws-sdk-dotnet-automation Date: Fri, 8 Nov 2024 22:24:57 +0000 Subject: [PATCH 12/26] release_2024-11-08 --- src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj b/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj index af606178..2f0d3515 100644 --- a/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj +++ b/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj @@ -15,7 +15,7 @@ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. AWS Lambda Tools for .NET CLI false - 5.11.1 + 5.11.2 From 21a1becdcad49e95f8963f8731f80eeda22a049f Mon Sep 17 00:00:00 2001 From: aws-sdk-dotnet-automation Date: Fri, 8 Nov 2024 22:24:57 +0000 Subject: [PATCH 13/26] Updated changelog --- .../changes/e52deae1-471a-4119-b874-5ef0ccf690b3.json | 11 ----------- CHANGELOG.md | 5 +++++ 2 files changed, 5 insertions(+), 11 deletions(-) delete mode 100644 .autover/changes/e52deae1-471a-4119-b874-5ef0ccf690b3.json diff --git a/.autover/changes/e52deae1-471a-4119-b874-5ef0ccf690b3.json b/.autover/changes/e52deae1-471a-4119-b874-5ef0ccf690b3.json deleted file mode 100644 index c01ebc11..00000000 --- a/.autover/changes/e52deae1-471a-4119-b874-5ef0ccf690b3.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "Projects": [ - { - "Name": "Amazon.Lambda.Tools", - "Type": "Patch", - "ChangelogMessages": [ - "Fixed an issue causing 'lambda package' to hang when ran in CI/CD." - ] - } - ] -} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index d3f641ac..520b6a3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## Release 2024-11-08 + +### Amazon.Lambda.Tools (5.11.2) +* Fixed an issue causing 'lambda package' to hang when ran in CI/CD. + ## Release 2024-11-01 ### Amazon.Lambda.Tools (5.11.1) From 0be524676706e754daec5989f39c546b8870cc44 Mon Sep 17 00:00:00 2001 From: Norm Johanson Date: Mon, 18 Nov 2024 14:29:42 -0800 Subject: [PATCH 14/26] Version bump Amazon.Lambda.Tools to 5.12.0 --- CHANGELOG.md | 5 +++++ src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3f641ac..64ecb511 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## Release 2024-11-18 + +### Amazon.Lambda.Tools (5.12.0) +* Added `--snap-start-apply-on` switch to enable Lambda SnapStart + ## Release 2024-11-01 ### Amazon.Lambda.Tools (5.11.1) diff --git a/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj b/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj index 5ac5d9c5..c53fe76d 100644 --- a/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj +++ b/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj @@ -15,7 +15,7 @@ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. AWS Lambda Tools for .NET CLI false - 5.11.1 + 5.12.0 From 21166cb281aecc5c62fd3268cc3618ded47626fa Mon Sep 17 00:00:00 2001 From: Garrett Beatty Date: Wed, 20 Nov 2024 11:48:33 -0500 Subject: [PATCH 15/26] Update warning for ARM and AMD architectures on Amazon Linux (#347) --- .../5ce6e470-afe4-41e4-8945-ea5f9317d53d.json | 11 +++++ src/Amazon.Lambda.Tools/LambdaPackager.cs | 44 +++++++++++++++++-- 2 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 .autover/changes/5ce6e470-afe4-41e4-8945-ea5f9317d53d.json diff --git a/.autover/changes/5ce6e470-afe4-41e4-8945-ea5f9317d53d.json b/.autover/changes/5ce6e470-afe4-41e4-8945-ea5f9317d53d.json new file mode 100644 index 00000000..7010462e --- /dev/null +++ b/.autover/changes/5ce6e470-afe4-41e4-8945-ea5f9317d53d.json @@ -0,0 +1,11 @@ +{ + "Projects": [ + { + "Name": "Amazon.Lambda.Tools", + "Type": "Patch", + "ChangelogMessages": [ + "Updated message related to self-contained runtimes with lambda functions" + ] + } + ] +} \ No newline at end of file diff --git a/src/Amazon.Lambda.Tools/LambdaPackager.cs b/src/Amazon.Lambda.Tools/LambdaPackager.cs index fdb68f00..0580c4e6 100644 --- a/src/Amazon.Lambda.Tools/LambdaPackager.cs +++ b/src/Amazon.Lambda.Tools/LambdaPackager.cs @@ -41,7 +41,16 @@ public static class LambdaPackager private static bool IsAmazonLinux(IToolLogger logger) { #if !NETCOREAPP3_1_OR_GREATER - return false; + return false; +#else + return IsAmazonLinux2(logger) || IsAmazonLinux2023(logger); +#endif + } + + private static bool IsAmazonLinux2(IToolLogger logger) + { +#if !NETCOREAPP3_1_OR_GREATER + return false; #else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { @@ -55,6 +64,24 @@ private static bool IsAmazonLinux(IToolLogger logger) $"Linux distribution is Amazon Linux 2, NativeAOT container build is optional"); return true; } + } + } + + return false; +#endif + } + + private static bool IsAmazonLinux2023(IToolLogger logger) + { +#if !NETCOREAPP3_1_OR_GREATER + return false; +#else + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + if (File.Exists(LinuxOSReleaseFile)) + { + logger?.WriteLine($"Found {LinuxOSReleaseFile}"); + string readText = File.ReadAllText(LinuxOSReleaseFile); if (readText.Contains(AmazonLinuxNameInOSReleaseFile) && readText.Contains(AmazonLinux2023InOSReleaseFile)) { logger?.WriteLine( @@ -110,10 +137,19 @@ public static bool CreateApplicationBundle(LambdaToolsDefaults defaults, IToolLo LogDeprecationMessagesIfNecessary(logger, targetFramework); - if (string.Equals(architecture, LambdaConstants.ARCHITECTURE_ARM64) && msbuildParameters != null && msbuildParameters.Contains("--self-contained true")) + if (msbuildParameters != null && msbuildParameters.Contains("--self-contained true")) { - logger.WriteLine("WARNING: There is an issue with self contained ARM based .NET Lambda functions using custom runtimes that causes functions to fail to run. The following GitHub issue has further information and workaround."); - logger.WriteLine("https://github.com/aws/aws-lambda-dotnet/issues/920"); + if (string.Equals(architecture, LambdaConstants.ARCHITECTURE_ARM64) && IsAmazonLinux2(logger)) + { + logger.WriteLine("WARNING: There is an issue with self-contained ARM-based .NET Lambda functions using custom runtimes on Amazon Linux 2 that causes functions to fail to run."); + logger.WriteLine("For more information and workarounds, see: https://github.com/aws/aws-lambda-dotnet/issues/920"); + } + else if (IsAmazonLinux2023(logger)) + { + logger.WriteLine("WARNING: There is an issue with self-contained .NET Lambda functions using custom runtimes on Amazon Linux 2023 that causes functions to fail to run."); + logger.WriteLine("This applies to both AMD and ARM architectures."); + logger.WriteLine("For more information and workarounds, see: https://github.com/aws/aws-lambda-dotnet/issues/920"); + } } if (string.IsNullOrEmpty(configuration)) From b8b53d1b30fb634877d75445076bc660c3b1d0bb Mon Sep 17 00:00:00 2001 From: Garrett Beatty Date: Tue, 26 Nov 2024 11:54:29 -0500 Subject: [PATCH 16/26] Use MSBuild to find target framework (#348) --- .../8a5204e4-83ec-45ac-8c75-27512ae9cdf8.json | 12 ++ aws-extensions-for-dotnet-cli.sln | 7 + .../Utilities.cs | 180 ++++++++++++------ .../UtilitiesTests.cs | 1 + .../Directory.Build.props | 5 + .../TestFunctionBuildProps/Function.cs | 14 ++ .../TestFunctionBuildProps.csproj | 16 ++ .../aws-lambda-tools-defaults.json | 16 ++ 8 files changed, 188 insertions(+), 63 deletions(-) create mode 100644 .autover/changes/8a5204e4-83ec-45ac-8c75-27512ae9cdf8.json create mode 100644 testapps/TestFunctionBuildProps/Directory.Build.props create mode 100644 testapps/TestFunctionBuildProps/TestFunctionBuildProps/Function.cs create mode 100644 testapps/TestFunctionBuildProps/TestFunctionBuildProps/TestFunctionBuildProps.csproj create mode 100644 testapps/TestFunctionBuildProps/TestFunctionBuildProps/aws-lambda-tools-defaults.json diff --git a/.autover/changes/8a5204e4-83ec-45ac-8c75-27512ae9cdf8.json b/.autover/changes/8a5204e4-83ec-45ac-8c75-27512ae9cdf8.json new file mode 100644 index 00000000..7f8d57f5 --- /dev/null +++ b/.autover/changes/8a5204e4-83ec-45ac-8c75-27512ae9cdf8.json @@ -0,0 +1,12 @@ +{ + "Projects": [ + { + "Name": "Amazon.Lambda.Tools", + "Type": "Patch", + "ChangelogMessages": [ + "Update logic for finding project properties to use MSBuild instead of parsing the project file directly. See https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2022 for more details.", + "Fix 'SelfContained' property reading logic to actually read the value from the properties. Previously we were only checking that the value could be parsed and not reading the actual value." + ] + } + ] +} \ No newline at end of file diff --git a/aws-extensions-for-dotnet-cli.sln b/aws-extensions-for-dotnet-cli.sln index c3e5653e..28335904 100644 --- a/aws-extensions-for-dotnet-cli.sln +++ b/aws-extensions-for-dotnet-cli.sln @@ -67,6 +67,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestNativeAotNet8WebApp", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestIntegerFunction", "testapps\TestIntegerFunction\TestIntegerFunction.csproj", "{D7F1DFA4-066B-469C-B04C-DF032CF152C1}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestFunctionBuildProps", "testapps\TestFunctionBuildProps\TestFunctionBuildProps\TestFunctionBuildProps.csproj", "{AFA71B8E-F0AA-4704-8C4E-C11130F82B13}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -169,6 +171,10 @@ Global {D7F1DFA4-066B-469C-B04C-DF032CF152C1}.Debug|Any CPU.Build.0 = Debug|Any CPU {D7F1DFA4-066B-469C-B04C-DF032CF152C1}.Release|Any CPU.ActiveCfg = Release|Any CPU {D7F1DFA4-066B-469C-B04C-DF032CF152C1}.Release|Any CPU.Build.0 = Release|Any CPU + {AFA71B8E-F0AA-4704-8C4E-C11130F82B13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AFA71B8E-F0AA-4704-8C4E-C11130F82B13}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AFA71B8E-F0AA-4704-8C4E-C11130F82B13}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AFA71B8E-F0AA-4704-8C4E-C11130F82B13}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -200,6 +206,7 @@ Global {AD31D053-97C5-4262-B187-EC42BFD51A9F} = {BB3CF729-8213-4DDD-85AE-A5E7754F3944} {69FFA03C-D29F-40E0-9E7F-572D5E10AF77} = {BB3CF729-8213-4DDD-85AE-A5E7754F3944} {D7F1DFA4-066B-469C-B04C-DF032CF152C1} = {BB3CF729-8213-4DDD-85AE-A5E7754F3944} + {AFA71B8E-F0AA-4704-8C4E-C11130F82B13} = {BB3CF729-8213-4DDD-85AE-A5E7754F3944} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DBFC70D6-49A2-40A1-AB08-5D9504AB7112} diff --git a/src/Amazon.Common.DotNetCli.Tools/Utilities.cs b/src/Amazon.Common.DotNetCli.Tools/Utilities.cs index 6daa6c88..f067728e 100644 --- a/src/Amazon.Common.DotNetCli.Tools/Utilities.cs +++ b/src/Amazon.Common.DotNetCli.Tools/Utilities.cs @@ -18,6 +18,7 @@ using System.Text.RegularExpressions; using System.Collections; using System.Xml; +using System.Text.Json; namespace Amazon.Common.DotNetCli.Tools { @@ -205,72 +206,136 @@ public static string DeterminePublishLocation(string workingDirectory, string pr return path; } - public static string LookupTargetFrameworkFromProjectFile(string projectLocation) - { - var projectFile = FindProjectFileInDirectory(projectLocation); - var xdoc = XDocument.Load(projectFile); - - var element = xdoc.XPathSelectElement("//PropertyGroup/TargetFramework"); - return element?.Value; - } - - /// - /// Retrieve the `OutputType` property of a given project + // + /// Looks up specified properties from a project. /// - /// Path of the project - /// The value of the `OutputType` property - public static string LookupOutputTypeFromProjectFile(string projectLocation) + /// The location of the project file. + /// The names of the properties to look up. + /// A dictionary of property names and their values. + public static Dictionary LookupProjectProperties(string projectLocation, params string[] propertyNames) { - var process = new Process(); - var output = string.Empty; - var msbuildProcessFailed = false; - try + var projectFile = FindProjectFileInDirectory(projectLocation); + var properties = new Dictionary(); + var arguments = new List { - process.StartInfo = new ProcessStartInfo() + "msbuild", + projectFile, + "-nologo", + $"--getProperty:{string.Join(',', propertyNames)}" + }; + + var process = new Process + { + StartInfo = new ProcessStartInfo { FileName = "dotnet", - Arguments = $"msbuild {projectLocation} -getProperty:OutputType", + Arguments = string.Join(" ", arguments), RedirectStandardOutput = true, + RedirectStandardError = true, UseShellExecute = false, - WindowStyle = ProcessWindowStyle.Hidden - }; - + CreateNoWindow = true + } + }; + try + { process.Start(); - output = process.StandardOutput.ReadToEnd(); - var hasExited = process.WaitForExit(5000); + string output = process.StandardOutput.ReadToEnd().Trim(); + string error = process.StandardError.ReadToEnd(); + process.WaitForExit(5000); - // If it hasn't completed in the specified timeout, stop the process and give up - if (!hasExited) + if (process.ExitCode == 0) { - process.Kill(); - msbuildProcessFailed = true; + if (propertyNames.Length == 1) + { + // If only one property was requested, the output is the direct value + properties[propertyNames[0]] = output; + } + else + { + // Multiple properties were requested, so we expect JSON output + using JsonDocument doc = JsonDocument.Parse(output); + JsonElement root = doc.RootElement; + JsonElement propertiesElement = root.GetProperty("Properties"); + + foreach (var property in propertyNames) + { + if (propertiesElement.TryGetProperty(property, out JsonElement propertyValue)) + { + properties[property] = propertyValue.GetString(); + } + } + } } - - // If it has completed but unsuccessfully, give up - if (process.ExitCode != 0) + else { - msbuildProcessFailed = true; + // Fallback to XML parsing + properties = LookupProjectPropertiesFromXml(projectFile, propertyNames); } } catch (Exception) { - // swallow any exceptions related to `dotnet msbuild` - msbuildProcessFailed = true; + // Fallback to XML parsing + properties = LookupProjectPropertiesFromXml(projectFile, propertyNames); } - if (msbuildProcessFailed) + return properties; + } + + + private static Dictionary LookupProjectPropertiesFromXml(string projectFile, string[] propertyNames) + { + var properties = new Dictionary(); + try { - var projectFile = FindProjectFileInDirectory(projectLocation); var xdoc = XDocument.Load(projectFile); - var element = xdoc.XPathSelectElement("//PropertyGroup/OutputType"); - output = element?.Value; + foreach (var propertyName in propertyNames) + { + var element = xdoc.XPathSelectElement($"//PropertyGroup/{propertyName}"); + if (element != null && !string.IsNullOrWhiteSpace(element.Value)) + { + properties[propertyName] = element.Value; + } + } + } + catch (Exception) + { + } + return properties; + } + + /// + /// Looks up the target framework from a project file. + /// + /// The location of the project file. + /// The target framework of the project. + public static string LookupTargetFrameworkFromProjectFile(string projectLocation) + { + var properties = LookupProjectProperties(projectLocation, "TargetFramework", "TargetFrameworks"); + if (properties.TryGetValue("TargetFramework", out var targetFramework) && !string.IsNullOrEmpty(targetFramework)) + { + return targetFramework; } + if (properties.TryGetValue("TargetFrameworks", out var targetFrameworks) && !string.IsNullOrEmpty(targetFrameworks)) + { + var frameworks = targetFrameworks.Split(';'); + if (frameworks.Length > 1 ){ + return null; + } + return frameworks[0]; + } + return null; + } - return - string.IsNullOrEmpty(output) ? - null : - output.Trim(); + /// + /// Retrieve the `OutputType` property of a given project + /// + /// Path of the project + /// The value of the `OutputType` property + public static string LookupOutputTypeFromProjectFile(string projectLocation) + { + var properties = LookupProjectProperties(projectLocation, "OutputType"); + return properties.TryGetValue("OutputType", out var outputType) ? outputType.Trim() : null; } public static bool LookPublishAotFlag(string projectLocation, string msBuildParameters) @@ -288,20 +353,15 @@ public static bool LookPublishAotFlag(string projectLocation, string msBuildPara } } - // If the property wasn't provided in msBuildParameters, fall back to searching project file - var projectFile = FindProjectFileInDirectory(projectLocation); - - var xdoc = XDocument.Load(projectFile); - - var element = xdoc.XPathSelectElement("//PropertyGroup/PublishAot"); - - if (bool.TryParse(element?.Value, out bool result)) + var properties = LookupProjectProperties(projectLocation, "PublishAot"); + if (properties.TryGetValue("PublishAot", out var publishAot)) { - return result; + return bool.TryParse(publishAot, out var result) && result; } - return false; } + + public static bool HasExplicitSelfContainedFlag(string projectLocation, string msBuildParameters) { if (msBuildParameters != null && msBuildParameters.IndexOf("--self-contained", StringComparison.InvariantCultureIgnoreCase) != -1) @@ -309,22 +369,16 @@ public static bool HasExplicitSelfContainedFlag(string projectLocation, string m return true; } - // If the property wasn't provided in msBuildParameters, fall back to searching project file - var projectFile = FindProjectFileInDirectory(projectLocation); - - var xdoc = XDocument.Load(projectFile); - - var element = xdoc.XPathSelectElement("//PropertyGroup/SelfContained"); - - if (bool.TryParse(element?.Value, out _)) + var properties = LookupProjectProperties(projectLocation, "SelfContained"); + if (properties.TryGetValue("SelfContained", out var selfContained)) { - return true; + return bool.TryParse(selfContained, out var isSelfContained) && isSelfContained; } return false; } - public static string FindProjectFileInDirectory(string directory) + private static string FindProjectFileInDirectory(string directory) { if (File.Exists(directory)) return directory; diff --git a/test/Amazon.Common.DotNetCli.Tools.Test/UtilitiesTests.cs b/test/Amazon.Common.DotNetCli.Tools.Test/UtilitiesTests.cs index 320c4cb0..09f21616 100644 --- a/test/Amazon.Common.DotNetCli.Tools.Test/UtilitiesTests.cs +++ b/test/Amazon.Common.DotNetCli.Tools.Test/UtilitiesTests.cs @@ -13,6 +13,7 @@ public class UtilitiesTests [InlineData("../../../../../testapps/TestFunction", "net6.0")] [InlineData("../../../../../testapps/ServerlessWithYamlFunction", "net6.0")] [InlineData("../../../../../testapps/TestBeanstalkWebApp", "netcoreapp3.1")] + [InlineData("../../../../../testapps/TestFunctionBuildProps/TestFunctionBuildProps", "net6.0")] public void CheckFramework(string projectPath, string expectedFramework) { var assembly = this.GetType().GetTypeInfo().Assembly; diff --git a/testapps/TestFunctionBuildProps/Directory.Build.props b/testapps/TestFunctionBuildProps/Directory.Build.props new file mode 100644 index 00000000..81e7fd0f --- /dev/null +++ b/testapps/TestFunctionBuildProps/Directory.Build.props @@ -0,0 +1,5 @@ + + + net6.0 + + diff --git a/testapps/TestFunctionBuildProps/TestFunctionBuildProps/Function.cs b/testapps/TestFunctionBuildProps/TestFunctionBuildProps/Function.cs new file mode 100644 index 00000000..f4783136 --- /dev/null +++ b/testapps/TestFunctionBuildProps/TestFunctionBuildProps/Function.cs @@ -0,0 +1,14 @@ +using Amazon.Lambda.Core; + +// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class. +[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))] + +namespace TestFunctionBuildProps; + +public class Function +{ + public string FunctionHandler(string input, ILambdaContext context) + { + return input.ToUpper(); + } +} diff --git a/testapps/TestFunctionBuildProps/TestFunctionBuildProps/TestFunctionBuildProps.csproj b/testapps/TestFunctionBuildProps/TestFunctionBuildProps/TestFunctionBuildProps.csproj new file mode 100644 index 00000000..db9ca90e --- /dev/null +++ b/testapps/TestFunctionBuildProps/TestFunctionBuildProps/TestFunctionBuildProps.csproj @@ -0,0 +1,16 @@ + + + enable + enable + true + Lambda + + true + + true + + + + + + \ No newline at end of file diff --git a/testapps/TestFunctionBuildProps/TestFunctionBuildProps/aws-lambda-tools-defaults.json b/testapps/TestFunctionBuildProps/TestFunctionBuildProps/aws-lambda-tools-defaults.json new file mode 100644 index 00000000..a5932b1c --- /dev/null +++ b/testapps/TestFunctionBuildProps/TestFunctionBuildProps/aws-lambda-tools-defaults.json @@ -0,0 +1,16 @@ +{ + "Information": [ + "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", + "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", + "dotnet lambda help", + "All the command line options for the Lambda command can be specified in this file." + ], + "profile": "default", + "region": "us-west-2", + "configuration": "Release", + "function-architecture": "x86_64", + "function-runtime": "dotnet8", + "function-memory-size": 512, + "function-timeout": 30, + "function-handler": "TestFunctionBuildProps::TestFunctionBuildProps.Function::FunctionHandler" +} \ No newline at end of file From 71b82fc664b0321020bc816af4d6dd3c66c8d838 Mon Sep 17 00:00:00 2001 From: aws-sdk-dotnet-automation <43080735+aws-sdk-dotnet-automation@users.noreply.github.com> Date: Tue, 26 Nov 2024 20:31:26 -0500 Subject: [PATCH 17/26] Release 2024-11-26 (#350) * release_2024-11-26 * Updated changelog --- .../5ce6e470-afe4-41e4-8945-ea5f9317d53d.json | 11 ----------- .../8a5204e4-83ec-45ac-8c75-27512ae9cdf8.json | 12 ------------ CHANGELOG.md | 7 +++++++ src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj | 2 +- 4 files changed, 8 insertions(+), 24 deletions(-) delete mode 100644 .autover/changes/5ce6e470-afe4-41e4-8945-ea5f9317d53d.json delete mode 100644 .autover/changes/8a5204e4-83ec-45ac-8c75-27512ae9cdf8.json diff --git a/.autover/changes/5ce6e470-afe4-41e4-8945-ea5f9317d53d.json b/.autover/changes/5ce6e470-afe4-41e4-8945-ea5f9317d53d.json deleted file mode 100644 index 7010462e..00000000 --- a/.autover/changes/5ce6e470-afe4-41e4-8945-ea5f9317d53d.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "Projects": [ - { - "Name": "Amazon.Lambda.Tools", - "Type": "Patch", - "ChangelogMessages": [ - "Updated message related to self-contained runtimes with lambda functions" - ] - } - ] -} \ No newline at end of file diff --git a/.autover/changes/8a5204e4-83ec-45ac-8c75-27512ae9cdf8.json b/.autover/changes/8a5204e4-83ec-45ac-8c75-27512ae9cdf8.json deleted file mode 100644 index 7f8d57f5..00000000 --- a/.autover/changes/8a5204e4-83ec-45ac-8c75-27512ae9cdf8.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "Projects": [ - { - "Name": "Amazon.Lambda.Tools", - "Type": "Patch", - "ChangelogMessages": [ - "Update logic for finding project properties to use MSBuild instead of parsing the project file directly. See https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2022 for more details.", - "Fix 'SelfContained' property reading logic to actually read the value from the properties. Previously we were only checking that the value could be parsed and not reading the actual value." - ] - } - ] -} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ba60c1f..a67173d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## Release 2024-11-26 + +### Amazon.Lambda.Tools (5.12.1) +* Updated message related to self-contained runtimes with lambda functions +* Update logic for finding project properties to use MSBuild instead of parsing the project file directly. See https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2022 for more details. +* Fix 'SelfContained' property reading logic to actually read the value from the properties. Previously we were only checking that the value could be parsed and not reading the actual value. + ## Release 2024-11-18 ### Amazon.Lambda.Tools (5.12.0) diff --git a/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj b/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj index c53fe76d..fa6e7fd2 100644 --- a/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj +++ b/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj @@ -15,7 +15,7 @@ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. AWS Lambda Tools for .NET CLI false - 5.12.0 + 5.12.1 From 8b8b49db143f63606a630c04f9c7087a3cf9aa39 Mon Sep 17 00:00:00 2001 From: Phil Asmar Date: Thu, 5 Dec 2024 09:07:24 -0500 Subject: [PATCH 18/26] chore: add workflow to check if change file is included in a PR --- .github/workflows/change-file-in-pr.yml | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/change-file-in-pr.yml diff --git a/.github/workflows/change-file-in-pr.yml b/.github/workflows/change-file-in-pr.yml new file mode 100644 index 00000000..fac4d083 --- /dev/null +++ b/.github/workflows/change-file-in-pr.yml @@ -0,0 +1,30 @@ +name: Change File Included in PR + +on: + pull_request: + types: [opened, synchronize, reopened, labeled] + +jobs: + check-files-in-directory: + if: ${{ !contains(github.event.pull_request.labels.*.name, 'Release Not Needed') && !contains(github.event.pull_request.labels.*.name, 'Release PR') }} + name: Change File Included in PR + runs-on: ubuntu-latest + + steps: + - name: Checkout PR code + uses: actions/checkout@v3 + + - name: Get List of Changed Files + id: changed-files + uses: tj-actions/changed-files@4edd678ac3f81e2dc578756871e4d00c19191daf #v45 + + - name: Check for Change File(s) in .autover/changes/ + run: | + DIRECTORY=".autover/changes/" + if echo "${{ steps.changed-files.outputs.all_changed_files }}" | grep -q "$DIRECTORY"; then + echo "✅ One or more change files in '$DIRECTORY' are included in this PR." + else + echo "❌ No change files in '$DIRECTORY' are included in this PR." + echo "Refer to the 'Adding a change file to your contribution branch' section of https://github.com/aws/aws-extensions-for-dotnet-cli/blob/master/CONTRIBUTING.md" + exit 1 + fi From 5c1e25806cddd152cf9610bf2ec599794bd3177a Mon Sep 17 00:00:00 2001 From: Norm Johanson Date: Mon, 16 Dec 2024 09:29:17 -0800 Subject: [PATCH 19/26] Include user specified MSBuild parameters when evaluating MSBuild properties (#352) --- .../79b678d7-6533-4e17-ae69-100730e43027.json | 11 +++++++++ .../Utilities.cs | 24 ++++++++++++------- .../Commands/DeployEnvironmentCommand.cs | 2 +- .../Commands/PackageCommand.cs | 2 +- .../Commands/DeployFunctionCommand.cs | 4 ++-- .../Commands/PackageCommand.cs | 4 ++-- src/Amazon.Lambda.Tools/LambdaPackager.cs | 2 +- src/Amazon.Lambda.Tools/LambdaUtilities.cs | 8 +++---- .../TemplateProcessorManager.cs | 2 +- .../UtilitiesTests.cs | 18 ++++++++++++-- .../UtilitiesTests.cs | 4 ++-- 11 files changed, 57 insertions(+), 24 deletions(-) create mode 100644 .autover/changes/79b678d7-6533-4e17-ae69-100730e43027.json diff --git a/.autover/changes/79b678d7-6533-4e17-ae69-100730e43027.json b/.autover/changes/79b678d7-6533-4e17-ae69-100730e43027.json new file mode 100644 index 00000000..03cc7fe4 --- /dev/null +++ b/.autover/changes/79b678d7-6533-4e17-ae69-100730e43027.json @@ -0,0 +1,11 @@ +{ + "Projects": [ + { + "Name": "Amazon.Lambda.Tools", + "Type": "Patch", + "ChangelogMessages": [ + "Include user specified MSBuild parameters when evaluating MSBuild properties" + ] + } + ] +} \ No newline at end of file diff --git a/src/Amazon.Common.DotNetCli.Tools/Utilities.cs b/src/Amazon.Common.DotNetCli.Tools/Utilities.cs index f067728e..acc264b4 100644 --- a/src/Amazon.Common.DotNetCli.Tools/Utilities.cs +++ b/src/Amazon.Common.DotNetCli.Tools/Utilities.cs @@ -211,9 +211,10 @@ public static string DeterminePublishLocation(string workingDirectory, string pr /// Looks up specified properties from a project. /// /// The location of the project file. + /// Additional MSBuild parameters passed by the user from the commandline /// The names of the properties to look up. /// A dictionary of property names and their values. - public static Dictionary LookupProjectProperties(string projectLocation, params string[] propertyNames) + public static Dictionary LookupProjectProperties(string projectLocation, string msBuildParameters, params string[] propertyNames) { var projectFile = FindProjectFileInDirectory(projectLocation); var properties = new Dictionary(); @@ -225,6 +226,11 @@ public static Dictionary LookupProjectProperties(string projectL $"--getProperty:{string.Join(',', propertyNames)}" }; + if (!string.IsNullOrEmpty(msBuildParameters)) + { + arguments.Add(msBuildParameters); + } + var process = new Process { StartInfo = new ProcessStartInfo @@ -302,16 +308,17 @@ private static Dictionary LookupProjectPropertiesFromXml(string { } return properties; - } + } /// /// Looks up the target framework from a project file. /// /// The location of the project file. + /// Additonal MSBuild paramteres passed by the user from the commandline /// The target framework of the project. - public static string LookupTargetFrameworkFromProjectFile(string projectLocation) + public static string LookupTargetFrameworkFromProjectFile(string projectLocation, string msBuildParameters) { - var properties = LookupProjectProperties(projectLocation, "TargetFramework", "TargetFrameworks"); + var properties = LookupProjectProperties(projectLocation, msBuildParameters, "TargetFramework", "TargetFrameworks"); if (properties.TryGetValue("TargetFramework", out var targetFramework) && !string.IsNullOrEmpty(targetFramework)) { return targetFramework; @@ -331,10 +338,11 @@ public static string LookupTargetFrameworkFromProjectFile(string projectLocation /// Retrieve the `OutputType` property of a given project /// /// Path of the project + /// Additonal MSBuild paramteres passed by the user from the commandline /// The value of the `OutputType` property - public static string LookupOutputTypeFromProjectFile(string projectLocation) + public static string LookupOutputTypeFromProjectFile(string projectLocation, string msBuildParameters) { - var properties = LookupProjectProperties(projectLocation, "OutputType"); + var properties = LookupProjectProperties(projectLocation, msBuildParameters, "OutputType"); return properties.TryGetValue("OutputType", out var outputType) ? outputType.Trim() : null; } @@ -353,7 +361,7 @@ public static bool LookPublishAotFlag(string projectLocation, string msBuildPara } } - var properties = LookupProjectProperties(projectLocation, "PublishAot"); + var properties = LookupProjectProperties(projectLocation, msBuildParameters, "PublishAot"); if (properties.TryGetValue("PublishAot", out var publishAot)) { return bool.TryParse(publishAot, out var result) && result; @@ -369,7 +377,7 @@ public static bool HasExplicitSelfContainedFlag(string projectLocation, string m return true; } - var properties = LookupProjectProperties(projectLocation, "SelfContained"); + var properties = LookupProjectProperties(projectLocation, msBuildParameters, "SelfContained"); if (properties.TryGetValue("SelfContained", out var selfContained)) { return bool.TryParse(selfContained, out var isSelfContained) && isSelfContained; diff --git a/src/Amazon.ElasticBeanstalk.Tools/Commands/DeployEnvironmentCommand.cs b/src/Amazon.ElasticBeanstalk.Tools/Commands/DeployEnvironmentCommand.cs index a7f6b38b..07505f13 100644 --- a/src/Amazon.ElasticBeanstalk.Tools/Commands/DeployEnvironmentCommand.cs +++ b/src/Amazon.ElasticBeanstalk.Tools/Commands/DeployEnvironmentCommand.cs @@ -138,7 +138,7 @@ protected override async Task PerformActionAsync() if (string.IsNullOrEmpty(targetFramework)) { - targetFramework = Utilities.LookupTargetFrameworkFromProjectFile(projectLocation); + targetFramework = Utilities.LookupTargetFrameworkFromProjectFile(projectLocation, null); if (string.IsNullOrEmpty(targetFramework)) { targetFramework = this.GetStringValueOrDefault(this.DeployEnvironmentOptions.TargetFramework, CommonDefinedCommandOptions.ARGUMENT_FRAMEWORK, true); diff --git a/src/Amazon.ElasticBeanstalk.Tools/Commands/PackageCommand.cs b/src/Amazon.ElasticBeanstalk.Tools/Commands/PackageCommand.cs index 47b2357c..917d6ccc 100644 --- a/src/Amazon.ElasticBeanstalk.Tools/Commands/PackageCommand.cs +++ b/src/Amazon.ElasticBeanstalk.Tools/Commands/PackageCommand.cs @@ -64,7 +64,7 @@ protected override Task PerformActionAsync() if (string.IsNullOrEmpty(targetFramework)) { - targetFramework = Utilities.LookupTargetFrameworkFromProjectFile(projectLocation); + targetFramework = Utilities.LookupTargetFrameworkFromProjectFile(projectLocation, null); if (string.IsNullOrEmpty(targetFramework)) { targetFramework = this.GetStringValueOrDefault(this.DeployEnvironmentOptions.TargetFramework, CommonDefinedCommandOptions.ARGUMENT_FRAMEWORK, true); diff --git a/src/Amazon.Lambda.Tools/Commands/DeployFunctionCommand.cs b/src/Amazon.Lambda.Tools/Commands/DeployFunctionCommand.cs index e5ec667c..34e4805d 100644 --- a/src/Amazon.Lambda.Tools/Commands/DeployFunctionCommand.cs +++ b/src/Amazon.Lambda.Tools/Commands/DeployFunctionCommand.cs @@ -227,10 +227,11 @@ protected override async Task PerformActionAsync() // Release will be the default configuration if nothing set. string configuration = this.GetStringValueOrDefault(this.Configuration, CommonDefinedCommandOptions.ARGUMENT_CONFIGURATION, false); + string msbuildParameters = this.GetStringValueOrDefault(this.MSBuildParameters, CommonDefinedCommandOptions.ARGUMENT_MSBUILD_PARAMETERS, false); var targetFramework = this.GetStringValueOrDefault(this.TargetFramework, CommonDefinedCommandOptions.ARGUMENT_FRAMEWORK, false); if (string.IsNullOrEmpty(targetFramework)) { - targetFramework = Utilities.LookupTargetFrameworkFromProjectFile(projectLocation); + targetFramework = Utilities.LookupTargetFrameworkFromProjectFile(projectLocation, msbuildParameters); // If we still don't know what the target framework is ask the user what targetframework to use. // This is common when a project is using multi targeting. @@ -239,7 +240,6 @@ protected override async Task PerformActionAsync() targetFramework = this.GetStringValueOrDefault(this.TargetFramework, CommonDefinedCommandOptions.ARGUMENT_FRAMEWORK, true); } } - string msbuildParameters = this.GetStringValueOrDefault(this.MSBuildParameters, CommonDefinedCommandOptions.ARGUMENT_MSBUILD_PARAMETERS, false); bool isNativeAot = Utilities.LookPublishAotFlag(projectLocation, this.MSBuildParameters); diff --git a/src/Amazon.Lambda.Tools/Commands/PackageCommand.cs b/src/Amazon.Lambda.Tools/Commands/PackageCommand.cs index f6aae61e..518a603e 100644 --- a/src/Amazon.Lambda.Tools/Commands/PackageCommand.cs +++ b/src/Amazon.Lambda.Tools/Commands/PackageCommand.cs @@ -206,10 +206,11 @@ protected override async Task PerformActionAsync() // Release will be the default configuration if nothing set. var configuration = this.GetStringValueOrDefault(this.Configuration, CommonDefinedCommandOptions.ARGUMENT_CONFIGURATION, false); + var msbuildParameters = this.GetStringValueOrDefault(this.MSBuildParameters, CommonDefinedCommandOptions.ARGUMENT_MSBUILD_PARAMETERS, false); var targetFramework = this.GetStringValueOrDefault(this.TargetFramework, CommonDefinedCommandOptions.ARGUMENT_FRAMEWORK, false); if (string.IsNullOrEmpty(targetFramework)) { - targetFramework = Utilities.LookupTargetFrameworkFromProjectFile(projectLocation); + targetFramework = Utilities.LookupTargetFrameworkFromProjectFile(projectLocation, msbuildParameters); // If we still don't know what the target framework is ask the user what targetframework to use. // This is common when a project is using multi targeting. @@ -221,7 +222,6 @@ protected override async Task PerformActionAsync() bool isNativeAot = Utilities.LookPublishAotFlag(projectLocation, this.MSBuildParameters); - var msbuildParameters = this.GetStringValueOrDefault(this.MSBuildParameters, CommonDefinedCommandOptions.ARGUMENT_MSBUILD_PARAMETERS, false); var architecture = this.GetStringValueOrDefault(this.Architecture, LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_ARCHITECTURE, false); var disableVersionCheck = this.GetBoolValueOrDefault(this.DisableVersionCheck, LambdaDefinedCommandOptions.ARGUMENT_DISABLE_VERSION_CHECK, false).GetValueOrDefault(); diff --git a/src/Amazon.Lambda.Tools/LambdaPackager.cs b/src/Amazon.Lambda.Tools/LambdaPackager.cs index 0580c4e6..ae0382e4 100644 --- a/src/Amazon.Lambda.Tools/LambdaPackager.cs +++ b/src/Amazon.Lambda.Tools/LambdaPackager.cs @@ -114,7 +114,7 @@ public static bool CreateApplicationBundle(LambdaToolsDefaults defaults, IToolLo bool? useContainerForBuild, string containerImageForBuild, string codeMountDirectory, out string publishLocation, ref string zipArchivePath) { - LambdaUtilities.ValidateTargetFramework(projectLocation, targetFramework, isNativeAot); + LambdaUtilities.ValidateTargetFramework(projectLocation, msbuildParameters, targetFramework, isNativeAot); LambdaUtilities.ValidateNativeAotArchitecture(architecture, isNativeAot); diff --git a/src/Amazon.Lambda.Tools/LambdaUtilities.cs b/src/Amazon.Lambda.Tools/LambdaUtilities.cs index 0cdd189e..7d706c68 100644 --- a/src/Amazon.Lambda.Tools/LambdaUtilities.cs +++ b/src/Amazon.Lambda.Tools/LambdaUtilities.cs @@ -64,13 +64,13 @@ public static class LambdaUtilities {Amazon.Lambda.Runtime.Dotnetcore10.Value, TargetFrameworkMonikers.netcoreapp10} }; - public static string DetermineTargetFrameworkFromLambdaRuntime(string lambdaRuntime, string projectLocation) + public static string DetermineTargetFrameworkFromLambdaRuntime(string lambdaRuntime, string projectLocation, string msbuildParameters) { string framework; if (_lambdaRuntimeToDotnetFramework.TryGetValue(lambdaRuntime, out framework)) return framework; - framework = Utilities.LookupTargetFrameworkFromProjectFile(projectLocation); + framework = Utilities.LookupTargetFrameworkFromProjectFile(projectLocation, msbuildParameters); return framework; } @@ -83,9 +83,9 @@ public static string DetermineLambdaRuntimeFromTargetFramework(string targetFram return kvp.Key; } - public static void ValidateTargetFramework(string projectLocation, string targetFramework, bool isNativeAot) + public static void ValidateTargetFramework(string projectLocation, string msbuildParameters, string targetFramework, bool isNativeAot) { - var outputType = Utilities.LookupOutputTypeFromProjectFile(projectLocation); + var outputType = Utilities.LookupOutputTypeFromProjectFile(projectLocation, msbuildParameters); var ouputTypeIsExe = outputType != null && outputType.ToLower().Equals("exe"); if (isNativeAot && !ouputTypeIsExe) diff --git a/src/Amazon.Lambda.Tools/TemplateProcessor/TemplateProcessorManager.cs b/src/Amazon.Lambda.Tools/TemplateProcessor/TemplateProcessorManager.cs index f0faea40..03b53a7a 100644 --- a/src/Amazon.Lambda.Tools/TemplateProcessor/TemplateProcessorManager.cs +++ b/src/Amazon.Lambda.Tools/TemplateProcessor/TemplateProcessorManager.cs @@ -251,7 +251,7 @@ private async Task PackageDotnetProjectAsync(IUpdateResou var outputPackage = GenerateOutputZipFilename(field); command.OutputPackageFileName = outputPackage; command.TargetFramework = - LambdaUtilities.DetermineTargetFrameworkFromLambdaRuntime(field.Resource.LambdaRuntime, location); + LambdaUtilities.DetermineTargetFrameworkFromLambdaRuntime(field.Resource.LambdaRuntime, location, null); command.Architecture = field.Resource.LambdaArchitecture; command.LayerVersionArns = field.Resource.LambdaLayers; diff --git a/test/Amazon.Common.DotNetCli.Tools.Test/UtilitiesTests.cs b/test/Amazon.Common.DotNetCli.Tools.Test/UtilitiesTests.cs index 09f21616..c2a14d04 100644 --- a/test/Amazon.Common.DotNetCli.Tools.Test/UtilitiesTests.cs +++ b/test/Amazon.Common.DotNetCli.Tools.Test/UtilitiesTests.cs @@ -18,7 +18,7 @@ public void CheckFramework(string projectPath, string expectedFramework) { var assembly = this.GetType().GetTypeInfo().Assembly; var fullPath = Path.GetFullPath(Path.GetDirectoryName(assembly.Location) + projectPath); - var determinedFramework = Utilities.LookupTargetFrameworkFromProjectFile(projectPath); + var determinedFramework = Utilities.LookupTargetFrameworkFromProjectFile(projectPath, null); Assert.Equal(expectedFramework, determinedFramework); } @@ -80,7 +80,7 @@ public void TestLookForPublishAotFlag(string projectLocation, string msBuildPara [InlineData("../../../../../testapps/TestNativeAotSingleProject", "Exe")] public void TestLookupOutputTypeFromProjectFile(string projectLocation, string expected) { - var result = Utilities.LookupOutputTypeFromProjectFile(projectLocation); + var result = Utilities.LookupOutputTypeFromProjectFile(projectLocation, null); Assert.Equal(expected, result); } @@ -100,5 +100,19 @@ public void TestHasExplicitSelfContainedFlag(string projectLocation, string msBu Assert.Equal(expected, result); } + + [Theory] + [InlineData("TargetFramework", "", "net6.0")] + [InlineData("TargetFramework", "/p:NonExistence=net20.0", "net6.0")] + [InlineData("TargetFramework", "/p:TargetFramework=net20.0", "net20.0")] + [InlineData("TargetFramework", "/p:TargetFramework=net20.0 /p:OutputType=FutureDevice", "net20.0")] + [InlineData("OutputType", "/p:TargetFramework=net20.0 /p:OutputType=FutureDevice", "FutureDevice")] + public void TestPropertyEvaluationWithMSBuildParameters(string property, string msbuildparameters, string expectedValue) + { + var projectLocation = "../../../../../testapps/TestFunction"; + + var value = Utilities.LookupProjectProperties(projectLocation, msbuildparameters, property)[property]; + Assert.Equal(expectedValue, value); + } } } \ No newline at end of file diff --git a/test/Amazon.Lambda.Tools.Test/UtilitiesTests.cs b/test/Amazon.Lambda.Tools.Test/UtilitiesTests.cs index 22b22e24..a67328fc 100644 --- a/test/Amazon.Lambda.Tools.Test/UtilitiesTests.cs +++ b/test/Amazon.Lambda.Tools.Test/UtilitiesTests.cs @@ -216,12 +216,12 @@ public void TestValidateTargetFramework(string projectLocation, string targetFra { if (shouldThrow) { - Assert.Throws(() => LambdaUtilities.ValidateTargetFramework(projectLocation, targetFramework, isNativeAot)); + Assert.Throws(() => LambdaUtilities.ValidateTargetFramework(projectLocation, null, targetFramework, isNativeAot)); } else { // If this throws an exception, the test will fail, hench no assert is necessary - LambdaUtilities.ValidateTargetFramework(projectLocation, targetFramework, isNativeAot); + LambdaUtilities.ValidateTargetFramework(projectLocation, null, targetFramework, isNativeAot); } } From 832851c7775fcba5ac39c4151a54716ec2d7ceaa Mon Sep 17 00:00:00 2001 From: aws-sdk-dotnet-automation <43080735+aws-sdk-dotnet-automation@users.noreply.github.com> Date: Mon, 16 Dec 2024 13:23:56 -0500 Subject: [PATCH 20/26] Release 2024-12-16 (#354) --- .../changes/79b678d7-6533-4e17-ae69-100730e43027.json | 11 ----------- CHANGELOG.md | 5 +++++ src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj | 2 +- 3 files changed, 6 insertions(+), 12 deletions(-) delete mode 100644 .autover/changes/79b678d7-6533-4e17-ae69-100730e43027.json diff --git a/.autover/changes/79b678d7-6533-4e17-ae69-100730e43027.json b/.autover/changes/79b678d7-6533-4e17-ae69-100730e43027.json deleted file mode 100644 index 03cc7fe4..00000000 --- a/.autover/changes/79b678d7-6533-4e17-ae69-100730e43027.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "Projects": [ - { - "Name": "Amazon.Lambda.Tools", - "Type": "Patch", - "ChangelogMessages": [ - "Include user specified MSBuild parameters when evaluating MSBuild properties" - ] - } - ] -} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index a67173d6..4fa4c6fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## Release 2024-12-16 + +### Amazon.Lambda.Tools (5.12.2) +* Include user specified MSBuild parameters when evaluating MSBuild properties + ## Release 2024-11-26 ### Amazon.Lambda.Tools (5.12.1) diff --git a/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj b/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj index fa6e7fd2..35827f24 100644 --- a/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj +++ b/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj @@ -15,7 +15,7 @@ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. AWS Lambda Tools for .NET CLI false - 5.12.1 + 5.12.2 From 2c711df14779910d51197d5eb48028235e9be33b Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Thu, 19 Dec 2024 18:20:03 +0000 Subject: [PATCH 21/26] Fix MSBuild property evaluation (#355) Fix MSBuild parameters specified in `aws-lambda-tools-defaults.json` not being used with `Utilities.LookPublishAotFlag()`. Resolves #351. --- src/Amazon.Lambda.Tools/Commands/PackageCommand.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Amazon.Lambda.Tools/Commands/PackageCommand.cs b/src/Amazon.Lambda.Tools/Commands/PackageCommand.cs index 518a603e..3999e699 100644 --- a/src/Amazon.Lambda.Tools/Commands/PackageCommand.cs +++ b/src/Amazon.Lambda.Tools/Commands/PackageCommand.cs @@ -220,7 +220,7 @@ protected override async Task PerformActionAsync() } } - bool isNativeAot = Utilities.LookPublishAotFlag(projectLocation, this.MSBuildParameters); + bool isNativeAot = Utilities.LookPublishAotFlag(projectLocation, msbuildParameters); var architecture = this.GetStringValueOrDefault(this.Architecture, LambdaDefinedCommandOptions.ARGUMENT_FUNCTION_ARCHITECTURE, false); var disableVersionCheck = this.GetBoolValueOrDefault(this.DisableVersionCheck, LambdaDefinedCommandOptions.ARGUMENT_DISABLE_VERSION_CHECK, false).GetValueOrDefault(); From 75bf1a6f356a4d378eb12a749d22e1674ec639be Mon Sep 17 00:00:00 2001 From: Norm Johanson Date: Thu, 19 Dec 2024 10:30:22 -0800 Subject: [PATCH 22/26] Add change file for PR https://github.com/aws/aws-extensions-for-dotnet-cli/pull/355 (#356) --- .../changes/d421abba-4276-4562-b94a-486d22d5c90d.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .autover/changes/d421abba-4276-4562-b94a-486d22d5c90d.json diff --git a/.autover/changes/d421abba-4276-4562-b94a-486d22d5c90d.json b/.autover/changes/d421abba-4276-4562-b94a-486d22d5c90d.json new file mode 100644 index 00000000..8dc76c6c --- /dev/null +++ b/.autover/changes/d421abba-4276-4562-b94a-486d22d5c90d.json @@ -0,0 +1,11 @@ +{ + "Projects": [ + { + "Name": "Amazon.Lambda.Tools", + "Type": "Patch", + "ChangelogMessages": [ + "Fixed issue when evaluating MSBuild properties like 'PublishAot' to include settings made in the aws-lambda-tools-defaults.json" + ] + } + ] +} \ No newline at end of file From fa1385e31a89ace8f8bf819ac5892953464e2592 Mon Sep 17 00:00:00 2001 From: aws-sdk-dotnet-automation <43080735+aws-sdk-dotnet-automation@users.noreply.github.com> Date: Thu, 19 Dec 2024 13:57:45 -0500 Subject: [PATCH 23/26] Release 2024-12-19 (#357) --- .../changes/d421abba-4276-4562-b94a-486d22d5c90d.json | 11 ----------- CHANGELOG.md | 5 +++++ src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj | 2 +- 3 files changed, 6 insertions(+), 12 deletions(-) delete mode 100644 .autover/changes/d421abba-4276-4562-b94a-486d22d5c90d.json diff --git a/.autover/changes/d421abba-4276-4562-b94a-486d22d5c90d.json b/.autover/changes/d421abba-4276-4562-b94a-486d22d5c90d.json deleted file mode 100644 index 8dc76c6c..00000000 --- a/.autover/changes/d421abba-4276-4562-b94a-486d22d5c90d.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "Projects": [ - { - "Name": "Amazon.Lambda.Tools", - "Type": "Patch", - "ChangelogMessages": [ - "Fixed issue when evaluating MSBuild properties like 'PublishAot' to include settings made in the aws-lambda-tools-defaults.json" - ] - } - ] -} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fa4c6fe..e3f0d557 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## Release 2024-12-19 + +### Amazon.Lambda.Tools (5.12.3) +* Fixed issue when evaluating MSBuild properties like 'PublishAot' to include settings made in the aws-lambda-tools-defaults.json + ## Release 2024-12-16 ### Amazon.Lambda.Tools (5.12.2) diff --git a/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj b/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj index 35827f24..af0ff690 100644 --- a/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj +++ b/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj @@ -15,7 +15,7 @@ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. AWS Lambda Tools for .NET CLI false - 5.12.2 + 5.12.3 From b17ea627d2dc5a2ad51c70bd1e8c5ad47a7361e1 Mon Sep 17 00:00:00 2001 From: Ashish Dhingra <67916761+ashishdhingra@users.noreply.github.com> Date: Wed, 8 Jan 2025 12:56:08 -0800 Subject: [PATCH 24/26] Added logic to handle extraneous double-quotes around value for --msbuild-parameters that could be passed in .NET argument for certain execution environments. --- .../fd1edd27-5324-4679-b0af-e2530bcc918f.json | 11 ++++++ .../Options/CommandLineParser.cs | 8 +++++ .../CommandLineParserTest.cs | 13 +++++++ .../OptionParseTests.cs | 34 +++++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 .autover/changes/fd1edd27-5324-4679-b0af-e2530bcc918f.json diff --git a/.autover/changes/fd1edd27-5324-4679-b0af-e2530bcc918f.json b/.autover/changes/fd1edd27-5324-4679-b0af-e2530bcc918f.json new file mode 100644 index 00000000..9b755925 --- /dev/null +++ b/.autover/changes/fd1edd27-5324-4679-b0af-e2530bcc918f.json @@ -0,0 +1,11 @@ +{ + "Projects": [ + { + "Name": "Amazon.Lambda.Tools", + "Type": "Patch", + "ChangelogMessages": [ + "Added logic to handle extraneous double-quotes around value for --msbuild-parameters that could be passed in .NET argument for certain execution environments." + ] + } + ] +} \ No newline at end of file diff --git a/src/Amazon.Common.DotNetCli.Tools/Options/CommandLineParser.cs b/src/Amazon.Common.DotNetCli.Tools/Options/CommandLineParser.cs index 97ce1dd4..ea1735e7 100644 --- a/src/Amazon.Common.DotNetCli.Tools/Options/CommandLineParser.cs +++ b/src/Amazon.Common.DotNetCli.Tools/Options/CommandLineParser.cs @@ -60,6 +60,14 @@ public static CommandOptions ParseArguments( value.BoolValue = bv; break; } + + // --msbuild-parameters is a special case where multiple parameters separated by space character are enclosed in double quotes. In certain environments (like JavaScript action runner), the leading and trailing double quotes characters are also passed to .NET command arguments. + if (option == CommonDefinedCommandOptions.ARGUMENT_MSBUILD_PARAMETERS && !string.IsNullOrEmpty(value.StringValue) + && (value.StringValue.Trim().StartsWith('\"') && value.StringValue.Trim().EndsWith('\"'))) + { + value.StringValue = value.StringValue.Trim().Trim('\"'); + } + i++; } diff --git a/test/Amazon.Lambda.Tools.Test/CommandLineParserTest.cs b/test/Amazon.Lambda.Tools.Test/CommandLineParserTest.cs index c94f770b..2503700a 100644 --- a/test/Amazon.Lambda.Tools.Test/CommandLineParserTest.cs +++ b/test/Amazon.Lambda.Tools.Test/CommandLineParserTest.cs @@ -93,5 +93,18 @@ public void BuildLambdaDeployCommandWithAllArguments() Assert.Equal(55, command.Timeout); Assert.Equal("netcore9.9", command.Runtime); } + + [Fact] + public void BuildLambdaDeployCommandWithMSBuildParamAndSwitchDoubleQuotedValue() + { + var arguments = new List(); + arguments.AddRange(new string[] { "--region", "us-west-2" }); + arguments.AddRange(new string[] { "--msbuild-parameters", "\"--no-restore --no-build\"" }); + arguments.Add("/p:Foo=bar;Version=1.2.3"); + + var command = new DeployFunctionCommand(new ConsoleToolLogger(), ".", arguments.ToArray()); + Assert.Equal("us-west-2", command.Region); + Assert.Equal("--no-restore --no-build /p:Foo=bar;Version=1.2.3", command.MSBuildParameters); + } } } diff --git a/test/Amazon.Lambda.Tools.Test/OptionParseTests.cs b/test/Amazon.Lambda.Tools.Test/OptionParseTests.cs index 0a496950..185606c8 100644 --- a/test/Amazon.Lambda.Tools.Test/OptionParseTests.cs +++ b/test/Amazon.Lambda.Tools.Test/OptionParseTests.cs @@ -81,5 +81,39 @@ public void ParseMSBuildParameters() Assert.NotNull(param); Assert.Equal("us-west-2", param.Item2.StringValue); } + + [Fact] + public void ParseMSBuildSwitchDoubleQuotedValue() + { + var values = CommandLineParser.ParseArguments(DeployFunctionCommand.DeployCommandOptions, + new[] { "myfunc", "--region", "us-west-2", "--msbuild-parameters", "\"--no-restore --no-build\"" }); + + Assert.Equal("myfunc", values.Arguments[0]); + + var msbuildparametersParam = values.FindCommandOption("--msbuild-parameters"); + Assert.NotNull(msbuildparametersParam); + Assert.Equal("--no-restore --no-build", msbuildparametersParam.Item2.StringValue); + + var param = values.FindCommandOption("--region"); + Assert.NotNull(param); + Assert.Equal("us-west-2", param.Item2.StringValue); + } + + [Fact] + public void ParseMSBuildSwitchNotDoubleQuotedValue() + { + var values = CommandLineParser.ParseArguments(DeployFunctionCommand.DeployCommandOptions, + new[] { "myfunc", "--region", "us-west-2", "--msbuild-parameters", "--no-restore --no-build" }); + + Assert.Equal("myfunc", values.Arguments[0]); + + var msbuildparametersParam = values.FindCommandOption("--msbuild-parameters"); + Assert.NotNull(msbuildparametersParam); + Assert.Equal("--no-restore --no-build", msbuildparametersParam.Item2.StringValue); + + var param = values.FindCommandOption("--region"); + Assert.NotNull(param); + Assert.Equal("us-west-2", param.Item2.StringValue); + } } } From 42720d41a2942799f9c28a470357b174807a053e Mon Sep 17 00:00:00 2001 From: aws-sdk-dotnet-automation Date: Fri, 10 Jan 2025 21:24:54 +0000 Subject: [PATCH 25/26] release_2025-01-10 --- src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj b/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj index af0ff690..075f0928 100644 --- a/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj +++ b/src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj @@ -15,7 +15,7 @@ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. AWS Lambda Tools for .NET CLI false - 5.12.3 + 5.12.4 From b2735be679eeea008d709fc7a57d2fabde66085a Mon Sep 17 00:00:00 2001 From: aws-sdk-dotnet-automation Date: Fri, 10 Jan 2025 21:24:54 +0000 Subject: [PATCH 26/26] Updated changelog --- .../changes/fd1edd27-5324-4679-b0af-e2530bcc918f.json | 11 ----------- CHANGELOG.md | 5 +++++ 2 files changed, 5 insertions(+), 11 deletions(-) delete mode 100644 .autover/changes/fd1edd27-5324-4679-b0af-e2530bcc918f.json diff --git a/.autover/changes/fd1edd27-5324-4679-b0af-e2530bcc918f.json b/.autover/changes/fd1edd27-5324-4679-b0af-e2530bcc918f.json deleted file mode 100644 index 9b755925..00000000 --- a/.autover/changes/fd1edd27-5324-4679-b0af-e2530bcc918f.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "Projects": [ - { - "Name": "Amazon.Lambda.Tools", - "Type": "Patch", - "ChangelogMessages": [ - "Added logic to handle extraneous double-quotes around value for --msbuild-parameters that could be passed in .NET argument for certain execution environments." - ] - } - ] -} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index e3f0d557..68f94f68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## Release 2025-01-13 + +### Amazon.Lambda.Tools (5.12.4) +* Added logic to handle extraneous double-quotes around value for --msbuild-parameters that could be passed in .NET argument for certain execution environments. + ## Release 2024-12-19 ### Amazon.Lambda.Tools (5.12.3)