-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2f28a9
commit 9ee96ed
Showing
10 changed files
with
156 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM public.ecr.aws/lambda/dotnet:6 | ||
|
||
# Set the image's internal work directory | ||
WORKDIR /var/task | ||
|
||
# Copy function code | ||
COPY "bin/Release/lambda-publish" . | ||
|
||
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) | ||
CMD [ "SampleLambda::SampleLambda.HelloWorldHandler::Handle" ] |
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 @@ | ||
using Amazon.Lambda.Core; | ||
using HeadlessChromium.Puppeteer.Lambda.Dotnet; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace SampleLambda | ||
{ | ||
public class HelloWorldHandler | ||
{ | ||
[LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))] | ||
public async Task<byte[]> Handle(ILambdaContext context) | ||
{ | ||
var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); | ||
var browserLauncher = new HeadlessChromiumPuppeteerLauncher(loggerFactory); | ||
|
||
await using (var browser = await browserLauncher.LaunchAsync()) | ||
await using (var page = await browser.NewPageAsync()) | ||
{ | ||
await page.GoToAsync("https://www.google.com"); | ||
await page.ScreenshotAsync("./google.png"); | ||
} | ||
|
||
return await File.ReadAllBytesAsync("./google.png"); | ||
} | ||
} | ||
} |
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,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="aws-lambda-tools-defaults.json" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="aws-lambda-tools-defaults.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" /> | ||
<PackageReference Include="Amazon.Lambda.Serialization.Json" Version="2.1.1" /> | ||
<PackageReference Include="HeadlessChromium.Puppeteer.Lambda.Dotnet" Version="1.1.0-dev" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" /> | ||
<PackageReference Include="PuppeteerSharp" Version="13.0.1" /> | ||
</ItemGroup> | ||
|
||
</Project> |
10 changes: 10 additions & 0 deletions
10
sample/SampleLambda-dotnet6/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,10 @@ | ||
{ | ||
"configuration": "Release", | ||
"framework": "net6.0", | ||
"function-runtime": "dotnet6", | ||
"function-memory-size": 1536, | ||
"function-timeout": 60, | ||
"function-handler": "SampleLambda::SampleLambda.HelloWorldHandler::Handle", | ||
"package-type": "image", | ||
"docker-host-build-output-dir": "./bin/Release/lambda-publish" | ||
} |
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<packageSources> | ||
<add key="MyLocalSharedSource" value="..\..\artifacts\" /> | ||
</packageSources> | ||
</configuration> |
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,10 @@ | ||
FROM public.ecr.aws/lambda/dotnet:8-preview | ||
|
||
# Set the image's internal work directory | ||
WORKDIR /var/task | ||
|
||
# Copy function code | ||
COPY "bin/Release/lambda-publish" . | ||
|
||
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) | ||
CMD [ "SampleLambda::SampleLambda.HelloWorldHandler::Handle" ] |
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 @@ | ||
using Amazon.Lambda.Core; | ||
using HeadlessChromium.Puppeteer.Lambda.Dotnet; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace SampleLambda | ||
{ | ||
public class HelloWorldHandler | ||
{ | ||
[LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))] | ||
public async Task<byte[]> Handle(ILambdaContext context) | ||
{ | ||
var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); | ||
var browserLauncher = new HeadlessChromiumPuppeteerLauncher(loggerFactory); | ||
|
||
await using (var browser = await browserLauncher.LaunchAsync()) | ||
await using (var page = await browser.NewPageAsync()) | ||
{ | ||
await page.GoToAsync("https://www.google.com"); | ||
await page.ScreenshotAsync("./google.png"); | ||
} | ||
|
||
return await File.ReadAllBytesAsync("./google.png"); | ||
} | ||
} | ||
} |
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,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="aws-lambda-tools-defaults.json" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="aws-lambda-tools-defaults.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" /> | ||
<PackageReference Include="Amazon.Lambda.Serialization.Json" Version="2.1.1" /> | ||
<PackageReference Include="HeadlessChromium.Puppeteer.Lambda.Dotnet" Version="1.1.0-dev" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" /> | ||
<PackageReference Include="PuppeteerSharp" Version="13.0.1" /> | ||
</ItemGroup> | ||
|
||
</Project> |
10 changes: 10 additions & 0 deletions
10
sample/SampleLambda-dotnet8/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,10 @@ | ||
{ | ||
"configuration": "Release", | ||
"framework": "net8.0", | ||
"function-runtime": "dotnet8", | ||
"function-memory-size": 1536, | ||
"function-timeout": 60, | ||
"function-handler": "SampleLambda::SampleLambda.HelloWorldHandler::Handle", | ||
"package-type": "image", | ||
"docker-host-build-output-dir": "./bin/Release/lambda-publish" | ||
} |
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<packageSources> | ||
<add key="MyLocalSharedSource" value="..\..\artifacts\" /> | ||
</packageSources> | ||
</configuration> |