Skip to content

Instantly share code, notes, and snippets.

@l1x
Last active December 2, 2019 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save l1x/28ddb502afb54d3451662700ff6a1623 to your computer and use it in GitHub Desktop.
Save l1x/28ddb502afb54d3451662700ff6a1623 to your computer and use it in GitHub Desktop.
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