-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add dotnet7 build method (#428)
* # This is a combination of 2 commits. # This is the 1st commit message: Add dotnet7 build method for provided * Added 'BuildMethod: dotnet7' using 'Runtime:provided' * 'Runtime:provided' is only for the provided runtime and not the dotnet runtime Testing with sample SAM template: ( See BuildMethod and Runtime below ) ... HelloWorldFunction: Type: AWS::Serverless::Function Metadata: BuildMethod: dotnet7 Properties: CodeUri: ./src/HelloWorld/ Handler: HelloWorld::HelloWorld.Function::FunctionHandler Runtime: provided Architectures: - x86_64 ... # This is the commit message #2: Add dotnet7 build method for provided * Added 'BuildMethod: dotnet7' using 'Runtime:provided' * 'Runtime:provided' is only for the provided runtime and not the dotnet runtime Testing with sample SAM template: ( See BuildMethod and Runtime below ) ... HelloWorldFunction: Type: AWS::Serverless::Function Metadata: BuildMethod: dotnet7 Properties: CodeUri: ./src/HelloWorld/ Handler: HelloWorld::HelloWorld.Function::FunctionHandler Runtime: provided Architectures: - x86_64 ... * run black reformat Co-authored-by: Samiullah Mohammed <[email protected]> Co-authored-by: Wing Fung Lau <[email protected]> Co-authored-by: Mehmet Nuri Deveci <[email protected]>
- Loading branch information
1 parent
4580762
commit c13391d
Showing
9 changed files
with
156 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
tests/integration/testdata/buildcmd/Dotnet7/HelloWorld.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> | ||
<PublishAot>true</PublishAot> | ||
<StripSymbols>true</StripSymbols> | ||
<OutputType>exe</OutputType> | ||
<AssemblyName>bootstrap</AssemblyName> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.5.0" /> | ||
<PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.8.2" /> | ||
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" /> | ||
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<RdXmlFile Include="rd.xml" /> | ||
</ItemGroup> | ||
|
||
</Project> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Amazon.Lambda.APIGatewayEvents; | ||
using Amazon.Lambda.Core; | ||
using Amazon.Lambda.RuntimeSupport; | ||
using Amazon.Lambda.Serialization.SystemTextJson; | ||
using System.Text.Json.Serialization; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.Net.Http; | ||
using System.Net.Http.Headers; | ||
|
||
namespace HelloWorld; | ||
|
||
public class Function | ||
{ | ||
/// <summary> | ||
/// The main entry point for the custom runtime. | ||
/// </summary> | ||
/// <param name="args"></param> | ||
private static async Task Main(string[] args) | ||
{ | ||
Func<APIGatewayHttpApiV2ProxyRequest, ILambdaContext, string> handler = FunctionHandler; | ||
await LambdaBootstrapBuilder.Create(handler, new SourceGeneratorLambdaJsonSerializer<MyCustomJsonSerializerContext>()) | ||
.Build() | ||
.RunAsync(); | ||
} | ||
|
||
public static string FunctionHandler(APIGatewayHttpApiV2ProxyRequest apigProxyEvent, ILambdaContext context) | ||
{ | ||
return "{'message': 'Hello World'}"; | ||
} | ||
} | ||
|
||
[JsonSerializable(typeof(APIGatewayHttpApiV2ProxyRequest))] | ||
public partial class MyCustomJsonSerializerContext : JsonSerializerContext | ||
{ | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/integration/testdata/buildcmd/Dotnet7/aws-lambda-tools-defaults.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"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":"", | ||
"region" : "", | ||
"configuration": "Release", | ||
"function-runtime":"provided", | ||
"function-memory-size" : 256, | ||
"function-timeout" : 30, | ||
"function-handler" : "HelloWorld::HelloWorld.Function::FunctionHandler" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata"> | ||
<Application> | ||
<Assembly Name="bootstrap" Dynamic="Required All"> | ||
</Assembly> | ||
</Application> | ||
</Directives> |
38 changes: 38 additions & 0 deletions
38
tests/integration/testdata/buildcmd/template_build_method_dotnet_7.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
iAWSTemplateFormatVersion : '2010-09-09' | ||
Transform: AWS::Serverless-2016-10-31 | ||
|
||
Parameteres: | ||
Runtime: | ||
Type: String | ||
CodeUri: | ||
Type: String | ||
Handler: | ||
Type: String | ||
|
||
Resources: | ||
|
||
Function: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
Handler: !Ref Handler | ||
Runtime: !Ref Runtime | ||
CodeUri: !Ref CodeUri | ||
Timeout: 600 | ||
Metadata: | ||
BuildMethod: dotnet7 | ||
|
||
OtherRelativePathResource: | ||
Type: AWS::ApiGateway::RestApi | ||
Properties: | ||
BodyS3Location: SomeRelativePath | ||
|
||
GlueResource: | ||
Type: AWS::Glue::Job | ||
Properties: | ||
Command: | ||
ScriptLocation: SomeRelativePath | ||
|
||
ExampleNestedStack: | ||
Type: AWS::CloudFormation::Stack | ||
Properties: | ||
TemplateURL: https://s3.amazonaws.com/examplebucket/exampletemplate.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters