Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Installing the environment for AWS Lambda and F# (Fsharp)

Installing .NET SDK

brew tap isen-ng/dotnet-sdk-versions
brew cask install dotnet-sdk-2.2.400

Creating Serverless Service

I think it is a good option to have separate dev and prod services in separate folders so we cannot accidentally deploy to prod, that is a problem when relying on environment variables.

sls create --template aws-fsharp --path unicorn-dev --name unicorn
sls create --template aws-fsharp --path unicorn-prod --name unicorn

Configuring The Service

Our service can write to Kinesis, but only to the developer stream.

service:
  name: unicorn-dev
app: unicorn-dev
org: lambdainsight
provider:
  name: aws
  runtime: dotnetcore2.1
  stage: dev
  region: eu-west-1
  profile: unicorn-developer
  apiKeys:
    - unicorn-dev-key-v1
  usagePlan:
    quota:
      limit: 1000
      offset: 0
      period: DAY
    throttle:
      burstLimit: 20
      rateLimit: 5

iamRoleStatements:
  - Effect: "Allow"
    Action:
      - "kinesis:PutRecord"
    Resource: arn:aws:kinesis:eu-west-1:651831719661:stream/unicorn-dev

package:
  artifact: bin/release/netcoreapp2.1/deploy-package.zip
exclude:
   - serverless.yml

functions:
  unicorn:
    handler: FsharpHandlers::UnicornFsharp.Handler::unicorn
    events:
      - http:
          path: /echo
          method: get
          private: false
          cors: true
      - http:
          path: /unicorn
          method: get
          private: false
          cors: true
      - http:
          path: /unicorn
          method: post
          private: false
          cors: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.