Skip to content

Commit

Permalink
Add scheduled airtable update
Browse files Browse the repository at this point in the history
  • Loading branch information
trbarrett committed Jun 12, 2020
1 parent 7085cc9 commit 2c40dd1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/BigHack.Fumble.Api.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Compile Include="TypeExtensions.fs" />
Expand Down
9 changes: 9 additions & 0 deletions src/LambdaFunctions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -34,3 +35,11 @@ let updateFromAirtable (gatewayRequest : APIGatewayProxyRequest)
"UpdateCards"
(fun ctx () -> Workflow.updateFromAirtable ctx)
ResponseDto.mapEmptyResultToDto

[<LambdaSerializer(typeof<DefaultLambdaJsonSerializer>)>]
let scheduledAirtableUpdate (cloudwatchEvent : CloudWatchLogsEvent)
(lambdaContext : ILambdaContext) =
Ok ()
|> handleAsyncEvent lambdaContext
"ScheduledAirtableUpdate"
(fun ctx () -> Workflow.updateFromAirtable ctx)
1 change: 1 addition & 0 deletions src/paket.references
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FSharp.Core
FSharp.Data
Amazon.Lambda.APIGatewayEvents
Amazon.Lambda.CloudWatchLogsEvents
Amazon.Lambda.Core
Amazon.Lambda.Serialization.SystemTextJson
AWSSDK.Core
Expand Down

0 comments on commit 2c40dd1

Please sign in to comment.