Skip to content

Commit 540bfe1

Browse files
authored
feat: lambda dotnet 8 support (#14026)
* feat: lambda dotnet 8 support * chore: update tests * chore: one more test * chore: lint * chore: test pin node version * chore: test with skip prompts for node install * chore: move -y flag * chore: switch to nodejs-lts with version * chore: revert changes to build windows * chore: remove ls of restricted dir * chore: remove use of /Users/aluja in windows * chore: try with /root * chore: remove unneeded jq install * chore: update /Users/aluja to be actual value * chore: remove duplicate code for loading aws profile * chore: fix test
1 parent b8b6498 commit 540bfe1

File tree

23 files changed

+53
-60
lines changed

23 files changed

+53
-60
lines changed

codebuild_specs/run_e2e_tests_windows.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ env:
2525
phases:
2626
build:
2727
commands:
28-
- choco install -fy jq
2928
- git config --global core.longpaths true
3029
- bash ./codebuild_specs/scripts-windows/load-e2e-cache.sh
3130
- bash ./codebuild_specs/scripts-windows/rename-packaged-cli.sh

codebuild_specs/scripts-windows/shared-scripts-windows.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ function _loadTestAccountCredentials {
9898
function _lsOut {
9999
ls ..
100100
ls ~
101-
ls $HOME
102-
ls $HOME/..
103-
ls $HOME/../..
104101
}
105102
function _build {
106103
echo Windows Build
@@ -120,8 +117,8 @@ function _install_packaged_cli_win {
120117
echo Move to CLI Binary to already existing PATH
121118
# This is a Hack to make sure the Amplify CLI is in the PATH
122119

123-
cp $CODEBUILD_SRC_DIR/out/amplify.exe $HOME/AppData/Local/Microsoft/WindowsApps
124-
ls $HOME/AppData/Local/Microsoft/WindowsApps
120+
cp $CODEBUILD_SRC_DIR/out/amplify.exe C:/Users/ContainerAdministrator/AppData/Local/Microsoft/WindowsApps
121+
ls C:/Users/ContainerAdministrator/AppData/Local/Microsoft/WindowsApps
125122

126123
# reset working directory
127124
cd $CODEBUILD_SRC_DIR

packages/amplify-dotnet-function-runtime-provider/amplify-plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
},
1212
"runtimes": [
1313
{
14-
"name": ".NET 6",
15-
"value": "dotnet6"
14+
"name": ".NET 8",
15+
"value": "dotnet8"
1616
}
1717
]
1818
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export const currentSupportedVersion = '6.0';
2-
export const dotnet6 = 'dotnet6';
1+
// see https://aws.amazon.com/blogs/compute/introducing-the-net-8-runtime-for-aws-lambda
2+
// https://docs.aws.amazon.com/lambda/latest/dg/lambda-csharp.html
3+
export const currentSupportedVersion = '8.0';
4+
export const dotnet8 = 'dotnet8';
35
export const handlerMethodName = 'LambdaHandler';
46
export const executableName = 'dotnet';

packages/amplify-dotnet-function-runtime-provider/src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FunctionRuntimeContributorFactory } from '@aws-amplify/amplify-function-plugin-interface';
2-
import { dotnet6 } from './constants';
2+
import { dotnet8 } from './constants';
33
import { detectDotNet } from './utils/detect';
44
import { build } from './utils/build';
55
import { packageAssemblies } from './utils/package';
@@ -10,14 +10,14 @@ export const functionRuntimeContributorFactory: FunctionRuntimeContributorFactor
1010
checkDependencies: detectDotNet,
1111
contribute: async (contributionRequest) => {
1212
switch (contributionRequest.selection) {
13-
case dotnet6:
13+
case dotnet8:
1414
return {
1515
runtime: {
16-
name: '.NET 6',
17-
value: dotnet6,
18-
cloudTemplateValue: dotnet6,
16+
name: '.NET 8',
17+
value: dotnet8,
18+
cloudTemplateValue: dotnet8,
1919
defaultHandler: `${contributionRequest.contributionContext.resourceName}::${contributionRequest.contributionContext.resourceName}.${contributionRequest.contributionContext.functionName}::LambdaHandler`,
20-
layerExecutablePath: dotnet6,
20+
layerExecutablePath: dotnet8,
2121
},
2222
};
2323
default:

packages/amplify-dotnet-function-runtime-provider/src/utils/detect.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const detectDotNet = async (): Promise<CheckDependenciesResult> => {
2121
if (sdkResult.exitCode !== 0) {
2222
throw new Error(`${executableName} failed SDK detection, exit code was ${sdkResult.exitCode}`);
2323
}
24-
const requiredSdkRegex = /^6\.0/m;
24+
const requiredSdkRegex = /^8\.0/m;
2525
const sdkInstalled = installedSdks && installedSdks.match(requiredSdkRegex);
2626

2727
const toolResult = execa.sync(executableName, ['tool', 'list', '--global']);
@@ -37,13 +37,13 @@ export const detectDotNet = async (): Promise<CheckDependenciesResult> => {
3737
if (installedToolList.match(/^amazon\.lambda\.tools/m)) {
3838
toolInstalled = true;
3939
}
40-
const requiredTestToolVersionRegex = /^amazon\.lambda\.testtool-6\.0/m;
40+
const requiredTestToolVersionRegex = /^amazon\.lambda\.testtool-8\.0/m;
4141
if (installedToolList.match(requiredTestToolVersionRegex)) {
4242
testToolInstalled = true;
4343
}
4444
}
4545

46-
// Verify that a dotnet 6 SDK and the dotnet Lambda tools is installed locally
46+
// Verify that a dotnet 8 SDK and the dotnet Lambda tools is installed locally
4747
if (sdkInstalled && toolInstalled && testToolInstalled) {
4848
return {
4949
hasRequiredDependencies: true,
@@ -54,15 +54,15 @@ export const detectDotNet = async (): Promise<CheckDependenciesResult> => {
5454
errorMessage: 'Unable to detect required dependencies:\n',
5555
};
5656
if (!sdkInstalled) {
57-
result.errorMessage += '- The .NET 6 SDK must be installed. It can be installed from https://dotnet.microsoft.com/download\n';
57+
result.errorMessage += '- The .NET 8 SDK must be installed. It can be installed from https://dotnet.microsoft.com/download\n';
5858
}
5959
if (!toolInstalled) {
6060
result.errorMessage +=
6161
'- The Amazon.Lambda.Tools global tool must be installed. Please install by running "dotnet tool install -g Amazon.Lambda.Tools".\n';
6262
}
6363
if (!testToolInstalled) {
6464
result.errorMessage +=
65-
'- The Amazon.Lambda.TestTool-6.0 global tool must be installed. Please install by running "dotnet tool install -g Amazon.Lambda.TestTool-6.0".\n';
65+
'- The Amazon.Lambda.TestTool-8.0 global tool must be installed. Please install by running "dotnet tool install -g Amazon.Lambda.TestTool-8.0".\n';
6666
}
6767
return result;
6868
}

packages/amplify-dotnet-function-runtime-provider/src/utils/invoke.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const invoke = async (request: InvocationRequest): Promise<string> => {
1414
tempDir = fs.mkdtempSync(path.join(request.srcRoot, 'amplify'));
1515
eventFile = path.join(tempDir, 'event.json');
1616
fs.writeFileSync(eventFile, request.event);
17-
const lambdaTestTool = 'lambda-test-tool-6.0';
17+
const lambdaTestTool = 'lambda-test-tool-8.0';
1818
const execPromise = execa(
1919
executableName,
2020
[lambdaTestTool, '--no-ui', '--function-handler', request.handler, '--payload', eventFile, '--pause-exit', 'false'],

packages/amplify-dotnet-function-runtime-provider/src/utils/package.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const packageAssemblies = async (request: PackageRequest, context: any):
1414
}
1515

1616
const packageHash = (await context.amplify.hashDir(distPath, [])) as string;
17-
const framework = 'net6.0';
17+
const framework = 'net8.0';
1818
try {
1919
const result = execa.sync(
2020
executableName,

packages/amplify-dotnet-function-template-provider/amplify-plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"conditions": {
88
"provider": "awscloudformation",
99
"services": ["Lambda"],
10-
"runtime": ["dotnet6"]
10+
"runtime": ["dotnet8"]
1111
},
1212
"templates": [
1313
{

packages/amplify-dotnet-function-template-provider/resources/lambda/Crud/Function.csproj.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net6.0</TargetFramework>
3+
<TargetFramework>net8.0</TargetFramework>
44
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
55
<AWSProjectType>Lambda</AWSProjectType>
66
</PropertyGroup>

0 commit comments

Comments
 (0)