Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3849 from slang25/master
F# .NET Core Template
- Loading branch information
Showing
18 changed files
with
601 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace AwsDotnetFsharp | ||
open Amazon.Lambda.Core | ||
|
||
[<assembly:LambdaSerializer(typeof<Amazon.Lambda.Serialization.Json.JsonSerializer>)>] | ||
do () | ||
|
||
type Request = { Key1 : string; Key2 : string; Key3 : string } | ||
type Response = { Message : string; Request : Request } | ||
|
||
module Handler = | ||
open System | ||
open System.IO | ||
open System.Text | ||
|
||
let hello(request:Request) = | ||
{ Message="Go Serverless v1.0! Your function executed successfully!" | ||
Request=request } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!-- | ||
title: Hello World F# Example | ||
menuText: Hello World F# Example | ||
description: Create a F# Hello World Lambda function | ||
layout: Doc | ||
--> | ||
|
||
# Hello World F# Example | ||
|
||
## Prerequisites | ||
|
||
* Make sure `serverless` is installed. [See installation guide](../../../guide/installation.md). | ||
* [.Net Core 1.0.1 SDK](https://www.microsoft.com/net/download/core) | ||
* 1.1 isn't currently supported by AWS Lambda | ||
* [NodeJS v4 or higher](https://nodejs.org/en/) | ||
* An AWS Account | ||
|
||
## Build and Package | ||
|
||
From the root of this directory, run `build.cmd`, or `build.sh` if on Linux / Mac. | ||
|
||
This will produce your deployment package at `bin/release/netcoreapp1.0/deploy-package.zip`. | ||
|
||
## Deployment and Invocation | ||
|
||
Once packaged, you can follow [these instructions](https://github.com/serverless/serverless#quick-start) to deploy and remotely invoke the function on AWS Lambda. | ||
|
||
In short the commands you will need to run are (from the root of this directory): | ||
|
||
``` | ||
serverless config credentials --provider aws --key {YourAwsAccessKey} --secret {YourAwsSecret} | ||
serverless deploy -v | ||
serverless invoke -f hello -l | ||
serverless remove | ||
``` | ||
|
||
By default this template deploys to us-east-1, you can change that in "serverless.yml" under the `region: us-east-1` key. |
24 changes: 24 additions & 0 deletions
24
docs/providers/aws/examples/hello-world/fsharp/aws-fsharp.fsproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp1.0</TargetFramework> | ||
<AssemblyName>FsharpHandlers</AssemblyName> | ||
<PackageId>aws-fsharp</PackageId> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="Handler.fs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Amazon.Lambda.Core" Version="1.0.0" /> | ||
<PackageReference Include="Amazon.Lambda.Serialization.Json" Version="1.1.0" /> | ||
<PackageReference Include="FSharp.Core" Version="4.1.*" /> | ||
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<DotNetCliToolReference Include="Amazon.Lambda.Tools" Version="1.6.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
87 changes: 87 additions & 0 deletions
87
docs/providers/aws/examples/hello-world/fsharp/serverless.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Welcome to Serverless! | ||
# | ||
# This file is the main config file for your service. | ||
# It's very minimal at this point and uses default values. | ||
# You can always add more config options for more control. | ||
# We've included some commented out config examples here. | ||
# Just uncomment any of them to get that config option. | ||
# | ||
# For full config options, check the docs: | ||
# docs.serverless.com | ||
# | ||
# Happy Coding! | ||
|
||
service: aws-fsharp # NOTE: update this with your service name | ||
|
||
# You can pin your service to only deploy with a specific Serverless version | ||
# Check out our docs for more details | ||
# frameworkVersion: "=X.X.X" | ||
|
||
provider: | ||
name: aws | ||
runtime: dotnetcore1.0 | ||
|
||
# you can overwrite defaults here | ||
# stage: dev | ||
# region: us-east-1 | ||
|
||
# you can add statements to the Lambda function's IAM Role here | ||
# iamRoleStatements: | ||
# - Effect: "Allow" | ||
# Action: | ||
# - "s3:ListBucket" | ||
# Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] } | ||
# - Effect: "Allow" | ||
# Action: | ||
# - "s3:PutObject" | ||
# Resource: | ||
# Fn::Join: | ||
# - "" | ||
# - - "arn:aws:s3:::" | ||
# - "Ref" : "ServerlessDeploymentBucket" | ||
|
||
# you can define service wide environment variables here | ||
# environment: | ||
# variable1: value1 | ||
|
||
# you can add packaging information here | ||
package: | ||
artifact: bin/release/netcoreapp1.0/deploy-package.zip | ||
# exclude: | ||
# - exclude-me.js | ||
# - exclude-me-dir/** | ||
|
||
functions: | ||
hello: | ||
handler: FsharpHandlers::AwsDotnetFsharp.Handler::hello | ||
|
||
# The following are a few example events you can configure | ||
# NOTE: Please make sure to change your handler code to work with those events | ||
# Check the event documentation for details | ||
# events: | ||
# - http: | ||
# path: users/create | ||
# method: get | ||
# - s3: ${env:BUCKET} | ||
# - schedule: rate(10 minutes) | ||
# - sns: greeter-topic | ||
# - stream: arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000 | ||
# - alexaSkill | ||
# - iot: | ||
# sql: "SELECT * FROM 'some_topic'" | ||
|
||
# Define function environment variables here | ||
# environment: | ||
# variable2: value2 | ||
|
||
# you can add CloudFormation resource templates here | ||
#resources: | ||
# Resources: | ||
# NewResource: | ||
# Type: AWS::S3::Bucket | ||
# Properties: | ||
# BucketName: my-new-bucket | ||
# Outputs: | ||
# NewOutput: | ||
# Description: "Description for the output" | ||
# Value: "Some output value" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace AwsDotnetFsharp | ||
open Amazon.Lambda.Core | ||
|
||
[<assembly:LambdaSerializer(typeof<Amazon.Lambda.Serialization.Json.JsonSerializer>)>] | ||
do () | ||
|
||
type Request = { Key1 : string; Key2 : string; Key3 : string } | ||
type Response = { Message : string; Request : Request } | ||
|
||
module Handler = | ||
open System | ||
open System.IO | ||
open System.Text | ||
|
||
let hello(request:Request) = | ||
{ Message="Go Serverless v1.0! Your function executed successfully!" | ||
Request=request } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp1.0</TargetFramework> | ||
<AssemblyName>FsharpHandlers</AssemblyName> | ||
<PackageId>aws-fsharp</PackageId> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="Handler.fs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Amazon.Lambda.Core" Version="1.0.0" /> | ||
<PackageReference Include="Amazon.Lambda.Serialization.Json" Version="1.1.0" /> | ||
<PackageReference Include="FSharp.Core" Version="4.1.*" /> | ||
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<DotNetCliToolReference Include="Amazon.Lambda.Tools" Version="1.6.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dotnet restore | ||
dotnet lambda package --configuration release --framework netcoreapp1.0 --output-package bin/release/netcoreapp1.0/deploy-package.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
#install zip | ||
apt-get -qq update | ||
apt-get -qq -y install zip | ||
|
||
dotnet restore | ||
|
||
#create deployment package | ||
dotnet lambda package --configuration release --framework netcoreapp1.0 --output-package bin/release/netcoreapp1.0/deploy-package.zip |
Oops, something went wrong.