-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LambdaHostingExtensions.cs
33 lines (25 loc) · 1.18 KB
/
LambdaHostingExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using Aspirant.Hosting;
using Kralizek.Aspire.Hosting;
// ReSharper disable CheckNamespace
namespace Aspire.Hosting;
public static class LambdaHostingExtensions
{
public static IResourceBuilder<LambdaResource> AddLambdaLocalHosting(this IDistributedApplicationBuilder builder, string name)
{
var resource = new LambdaResource(name);
return builder.AddWebApplication<LambdaResource, LambdaResourceLifecycleHook>(resource, excludeFromManifest: true);
}
public static IResourceBuilder<LambdaResource> AddAnnotationFunction(this IResourceBuilder<LambdaResource> builder, Type functionClass, string functionName)
{
if (functionClass.GetMethod(functionName) is { } method)
{
builder.Resource.Functions.Add(functionName, new Function(functionName, functionClass, method));
}
return builder;
}
public static IResourceBuilder<TResource> WithReference<TResource>(this IResourceBuilder<TResource> builder, IResourceBuilder<LambdaResource> lambda) where TResource : IResourceWithEnvironment
{
builder.WithEnvironment("AWS_ENDPOINT_URL_Lambda", lambda.GetEndpoint("http"));
return builder;
}
}