Last active
December 5, 2016 17:38
-
-
Save johnjelinek/70006aee9615248d30c43d13691f12ca to your computer and use it in GitHub Desktop.
C# Lambda
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
AWSTemplateFormatVersion: '2010-09-09' | |
Description: Create a Serverless stack with CloudFormation using Serverless Application Model | |
Transform: AWS::Serverless-2016-10-31 | |
Resources: | |
CSharpHelloWorld: | |
Type: AWS::Serverless::Function | |
Description: Use a lambda function to print Hello World | |
Properties: | |
Handler: csharplambda::CSharpFunction.HelloWorld::Handler | |
Runtime: dotnetcore1.0 | |
CodeUri: ./bin/Debug/netcoreapp1.0/publish | |
MemorySize: 128 | |
Timeout: 5 | |
Events: | |
HelloResource: | |
Type: Api | |
Properties: | |
Path: /hello | |
Method: get |
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
using Amazon.Lambda.Core; | |
using Newtonsoft.Json; | |
namespace CSharpFunction | |
{ | |
public class Headers | |
{ | |
[JsonProperty("Content-Type")] | |
public string ContentType { get; set; } | |
} | |
public class Response | |
{ | |
[JsonProperty("headers")] | |
public Headers Headers { get; set; } | |
[JsonProperty("statusCode")] | |
public int StatusCode { get; set; } | |
[JsonProperty("body")] | |
public string Body { get; set; } | |
} | |
public class HelloWorld | |
{ | |
[LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))] | |
public Response Handler() | |
{ | |
return new Response | |
{ | |
Headers = new Headers | |
{ | |
ContentType = "text/plain" | |
}, | |
StatusCode = 200, | |
Body = "Hello World" | |
}; | |
} | |
} | |
} |
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
{ | |
"version": "1.0.0-*", | |
"dependencies": {}, | |
"frameworks": { | |
"netcoreapp1.0": { | |
"dependencies": { | |
"Microsoft.NETCore.App": { | |
"type": "platform", | |
"version": "1.0.1" | |
}, | |
"Amazon.Lambda.Serialization.Json": "1.0.1", | |
"Newtonsoft.Json": "9.0.1" | |
}, | |
"imports": "dnxcore50" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment