/// <summary> /// /// </summary> /// <param name="name">Should be function root Namespace, also used for s3 key plus '.zip.</param> /// <param name="handler"></param> /// <returns></returns> internal Function CreateAirQualityLambda(string name, string handler, List <KeyValuePair <string, string> > envVars) { var properties = new FunctionProps(); properties.Runtime = Runtime.DOTNET_CORE_3_1; properties.Timeout = Duration.Seconds(20); // ensures max 20 sec duration // ensures unique Function names - use substring because of 64 character name limit var functionName = $"{name}-{Guid.NewGuid().ToString().Substring(0,12)}"; properties.FunctionName = functionName; // Add Environment variables properties.Environment = new Dictionary <string, string>(); envVars.ForEach(properties.Environment.Add); // this is dirty but works, pick up from default configs now // relative path within project should be \src\AirQualityCdk\bin\Debug\netcoreapp3.1\AirQualityCdk.dll properties.Code = Code.FromBucket( Bucket.FromBucketName(this, $"code-{functionName}", Constants.DefaultLambdasBucketName), $"{name}.zip"); // Look into picking up from asset in the future //Code.FromAsset(System.Environment.GetEnvironmentVariable("AirQualityhandlerPath")); properties.Handler = handler; properties.Role = LambdaAirRole(); // pass in unique function name singleton return(new Function(this, name, properties)); }
internal Function AirQualityNetLambda(string name, string handler = "AirQuality.Aws.Lambdas.WaqiGetCity") { var properties = new FunctionProps(); properties.Runtime = Runtime.DOTNET_CORE_3_1; properties.FunctionName = name; // this is dirty but works, pick up frm environment frm now // relative path within project should be \src\AirQualityCdk\bin\Debug\netcoreapp3.1\AirQualityCdk.dll properties.Code = Code.FromBucket(Bucket.FromBucketArn(this, $"code-{name}", "arn:aws:s3:us-west-2:811709609797:dotnet-apps"), @"lambdas/AirQualityCdk.zip"); // Look into picking up from asset in the future //Code.FromAsset(System.Environment.GetEnvironmentVariable("AirQualityhandlerPath")); properties.Handler = handler; properties.Role = LambdaAirRole(name); return(new Function(this, name, properties)); }