diff --git a/paket.dependencies b/paket.dependencies index adcda8f..b1eee54 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -5,6 +5,7 @@ nuget FSharp.Core nuget FSharp.Data nuget Amazon.Lambda.APIGatewayEvents nuget Amazon.Lambda.Core +nuget Amazon.Lambda.CloudWatchLogsEvents nuget Amazon.Lambda.Serialization.SystemTextJson nuget AWSSDK.Core nuget AWSSDK.DynamoDBv2 diff --git a/paket.lock b/paket.lock index ce1c09f..d97558b 100644 --- a/paket.lock +++ b/paket.lock @@ -2,6 +2,7 @@ RESTRICTION: == netcoreapp3.1 NUGET remote: https://api.nuget.org/v3/index.json Amazon.Lambda.APIGatewayEvents (2.1) + Amazon.Lambda.CloudWatchLogsEvents (2.0) Amazon.Lambda.Core (1.1) Amazon.Lambda.Serialization.SystemTextJson (2.0.1) Amazon.Lambda.Core (>= 1.1) diff --git a/serverless.yml b/serverless.yml index 3ebcae5..ef0b5c2 100755 --- a/serverless.yml +++ b/serverless.yml @@ -72,6 +72,13 @@ functions: path: "/updateFromAirtable" cors: true + scheduledAirtableUpdate: + handler: BigHack.Fumble.Api::BigHack.Fumble.Api.LambdaFunctions::scheduledAirtableUpdate + events: + - cloudwatchEvent: + name: bighack-fumble-api-${self:provider.stage}-airtable-update + schedule: rate(1 minutes) + resources: Resources: CardsDynamoDBTable: diff --git a/src/BigHack.Fumble.Api.fsproj b/src/BigHack.Fumble.Api.fsproj index a977ca5..0fdbbba 100755 --- a/src/BigHack.Fumble.Api.fsproj +++ b/src/BigHack.Fumble.Api.fsproj @@ -3,6 +3,7 @@ netcoreapp3.1 true + true diff --git a/src/LambdaFunctions.fs b/src/LambdaFunctions.fs index 073ba3d..a77f922 100644 --- a/src/LambdaFunctions.fs +++ b/src/LambdaFunctions.fs @@ -3,6 +3,7 @@ module BigHack.Fumble.Api.LambdaFunctions open Amazon.Lambda.Core open Amazon.Lambda.APIGatewayEvents open Amazon.Lambda.Serialization.SystemTextJson +open Amazon.Lambda.CloudWatchLogsEvents open BigHack.Fumble.Api open BigHack.Fumble.Api.TypeExtensions @@ -34,3 +35,11 @@ let updateFromAirtable (gatewayRequest : APIGatewayProxyRequest) "UpdateCards" (fun ctx () -> Workflow.updateFromAirtable ctx) ResponseDto.mapEmptyResultToDto + +[)>] +let scheduledAirtableUpdate (cloudwatchEvent : CloudWatchLogsEvent) + (lambdaContext : ILambdaContext) = + Ok () + |> handleAsyncEvent lambdaContext + "ScheduledAirtableUpdate" + (fun ctx () -> Workflow.updateFromAirtable ctx) diff --git a/src/paket.references b/src/paket.references index e203185..da92db7 100644 --- a/src/paket.references +++ b/src/paket.references @@ -1,6 +1,7 @@ FSharp.Core FSharp.Data Amazon.Lambda.APIGatewayEvents +Amazon.Lambda.CloudWatchLogsEvents Amazon.Lambda.Core Amazon.Lambda.Serialization.SystemTextJson AWSSDK.Core