├── .gitignore ├── README.md ├── artillery.sh ├── csharp ├── .npmignore ├── AssemblyInfo.cs ├── Handler.cs ├── aws-csharp.csproj ├── build.ps1 ├── build.sh └── serverless.yml ├── csharp2 ├── AssemblyInfo.cs ├── Handler.cs ├── aws-csharp2.csproj ├── build.ps1 ├── build.sh └── serverless.yml ├── deploy.sh ├── fsharp ├── .gitignore ├── Handler.fs ├── aws-fsharp.fsproj ├── build.ps1 ├── build.sh └── serverless.yml ├── fsharp2 ├── Handler.fs ├── aws-fsharp2.fsproj ├── build.ps1 ├── build.sh └── serverless.yml ├── go ├── .gitignore ├── Makefile ├── main.go └── serverless.yml ├── java ├── .npmignore ├── hello.iml ├── pom.xml ├── serverless.yml └── src │ └── main │ ├── java │ └── com │ │ └── serverless │ │ ├── ApiGatewayResponse.java │ │ ├── Handler.java │ │ └── Response.java │ └── resources │ └── log4j.properties ├── nodejs4 ├── .npmignore ├── handler.js └── serverless.yml ├── nodejs6 ├── .npmignore ├── handler.js └── serverless.yml ├── python ├── .npmignore ├── handler.py └── serverless.yml └── python3 ├── .npmignore ├── handler.py └── serverless.yml /.gitignore: -------------------------------------------------------------------------------- 1 | .serverless/ 2 | 3 | */bin/** 4 | */obj/** 5 | 6 | .idea/ 7 | 8 | java/target/ 9 | apis.txt 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | see blog post for more detail : http://theburningmonk.com/2017/03/aws-lambda-comparing-platform-performances 2 | 3 | all the functions are run using the default memory allocation of 1024MB 4 | -------------------------------------------------------------------------------- /artillery.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # api.txt is a list of API urls 4 | for api in `cat apis.txt` 5 | do 6 | echo "testing $api" 7 | artillery quick --duration 3600 --rate 10 --num 1 $api & 8 | done -------------------------------------------------------------------------------- /csharp/.npmignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | 24 | # Visual Studio 2015 cache/options directory 25 | .vs/ 26 | # Uncomment if you have tasks that create the project's static files in wwwroot 27 | #wwwroot/ 28 | 29 | # MSTest test Results 30 | [Tt]est[Rr]esult*/ 31 | [Bb]uild[Ll]og.* 32 | 33 | # NUNIT 34 | *.VisualState.xml 35 | TestResult.xml 36 | 37 | # Build Results of an ATL Project 38 | [Dd]ebugPS/ 39 | [Rr]eleasePS/ 40 | dlldata.c 41 | 42 | # DNX 43 | project.lock.json 44 | artifacts/ 45 | 46 | *_i.c 47 | *_p.c 48 | *_i.h 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.tmp_proj 63 | *.log 64 | *.vspscc 65 | *.vssscc 66 | .builds 67 | *.pidb 68 | *.svclog 69 | *.scc 70 | 71 | # Chutzpah Test files 72 | _Chutzpah* 73 | 74 | # Visual C++ cache files 75 | ipch/ 76 | *.aps 77 | *.ncb 78 | *.opendb 79 | *.opensdf 80 | *.sdf 81 | *.cachefile 82 | 83 | # Visual Studio profiler 84 | *.psess 85 | *.vsp 86 | *.vspx 87 | *.sap 88 | 89 | # TFS 2012 Local Workspace 90 | $tf/ 91 | 92 | # Guidance Automation Toolkit 93 | *.gpState 94 | 95 | # ReSharper is a .NET coding add-in 96 | _ReSharper*/ 97 | *.[Rr]e[Ss]harper 98 | *.DotSettings.user 99 | 100 | # JustCode is a .NET coding add-in 101 | .JustCode 102 | 103 | # TeamCity is a build add-in 104 | _TeamCity* 105 | 106 | # DotCover is a Code Coverage Tool 107 | *.dotCover 108 | 109 | # NCrunch 110 | _NCrunch_* 111 | .*crunch*.local.xml 112 | nCrunchTemp_* 113 | 114 | # MightyMoose 115 | *.mm.* 116 | AutoTest.Net/ 117 | 118 | # Web workbench (sass) 119 | .sass-cache/ 120 | 121 | # Installshield output folder 122 | [Ee]xpress/ 123 | 124 | # DocProject is a documentation generator add-in 125 | DocProject/buildhelp/ 126 | DocProject/Help/*.HxT 127 | DocProject/Help/*.HxC 128 | DocProject/Help/*.hhc 129 | DocProject/Help/*.hhk 130 | DocProject/Help/*.hhp 131 | DocProject/Help/Html2 132 | DocProject/Help/html 133 | 134 | # Click-Once directory 135 | publish/ 136 | 137 | # Publish Web Output 138 | *.[Pp]ublish.xml 139 | *.azurePubxml 140 | # TODO: Comment the next line if you want to checkin your web deploy settings 141 | # but database connection strings (with potential passwords) will be unencrypted 142 | *.pubxml 143 | *.publishproj 144 | 145 | # NuGet Packages 146 | *.nupkg 147 | # The packages folder can be ignored because of Package Restore 148 | **/packages/* 149 | # except build/, which is used as an MSBuild target. 150 | !**/packages/build/ 151 | # Uncomment if necessary however generally it will be regenerated when needed 152 | #!**/packages/repositories.config 153 | # NuGet v3's project.json files produces more ignoreable files 154 | *.nuget.props 155 | *.nuget.targets 156 | 157 | # Microsoft Azure Build Output 158 | csx/ 159 | *.build.csdef 160 | 161 | # Microsoft Azure Emulator 162 | ecf/ 163 | rcf/ 164 | 165 | # Microsoft Azure ApplicationInsights config file 166 | ApplicationInsights.config 167 | 168 | # Windows Store app package directory 169 | AppPackages/ 170 | BundleArtifacts/ 171 | 172 | # Visual Studio cache files 173 | # files ending in .cache can be ignored 174 | *.[Cc]ache 175 | # but keep track of directories ending in .cache 176 | !*.[Cc]ache/ 177 | 178 | # Others 179 | ClientBin/ 180 | ~$* 181 | *~ 182 | *.dbmdl 183 | *.dbproj.schemaview 184 | *.pfx 185 | *.publishsettings 186 | node_modules/ 187 | orleans.codegen.cs 188 | 189 | # RIA/Silverlight projects 190 | Generated_Code/ 191 | 192 | # Backup & report files from converting an old project file 193 | # to a newer Visual Studio version. Backup files are not needed, 194 | # because we have git ;-) 195 | _UpgradeReport_Files/ 196 | Backup*/ 197 | UpgradeLog*.XML 198 | UpgradeLog*.htm 199 | 200 | # SQL Server files 201 | *.mdf 202 | *.ldf 203 | 204 | # Business Intelligence projects 205 | *.rdl.data 206 | *.bim.layout 207 | *.bim_*.settings 208 | 209 | # Microsoft Fakes 210 | FakesAssemblies/ 211 | 212 | # GhostDoc plugin setting file 213 | *.GhostDoc.xml 214 | 215 | # Node.js Tools for Visual Studio 216 | .ntvs_analysis.dat 217 | 218 | # Visual Studio 6 build log 219 | *.plg 220 | 221 | # Visual Studio 6 workspace options file 222 | *.opt 223 | 224 | # Visual Studio LightSwitch build output 225 | **/*.HTMLClient/GeneratedArtifacts 226 | **/*.DesktopClient/GeneratedArtifacts 227 | **/*.DesktopClient/ModelManifest.xml 228 | **/*.Server/GeneratedArtifacts 229 | **/*.Server/ModelManifest.xml 230 | _Pvt_Extensions 231 | 232 | # Paket dependency manager 233 | .paket/paket.exe 234 | 235 | # FAKE - F# Make 236 | .fake/ 237 | *.orig 238 | 239 | # macOS 240 | .DS_Store 241 | 242 | # JetBrains Rider C# IDE 243 | .idea* 244 | 245 | # Serverless directories 246 | .serverless 247 | -------------------------------------------------------------------------------- /csharp/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using Amazon.Lambda.Core; 2 | 3 | [assembly:LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))] 4 | -------------------------------------------------------------------------------- /csharp/Handler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AwsDotnetCsharp 4 | { 5 | public class Handler 6 | { 7 | public Response Hello(Request request) 8 | { 9 | return new Response { 10 | statusCode = 200, 11 | body = "hello" 12 | }; 13 | } 14 | } 15 | 16 | public class Response 17 | { 18 | public int statusCode { get; set;} 19 | public string body {get; set;} 20 | } 21 | 22 | public class Request 23 | { 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /csharp/aws-csharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp1.0 5 | true 6 | CsharpHandlers 7 | aws-csharp 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /csharp/build.ps1: -------------------------------------------------------------------------------- 1 | dotnet restore 2 | dotnet lambda package --configuration release --framework netcoreapp1.0 --output-package bin/release/netcoreapp1.0/publish/deploy-package.zip 3 | -------------------------------------------------------------------------------- /csharp/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | dotnet restore 4 | dotnet lambda package --configuration release --framework netcoreapp1.0 --output-package bin/release/netcoreapp1.0/publish/deploy-package.zip 5 | -------------------------------------------------------------------------------- /csharp/serverless.yml: -------------------------------------------------------------------------------- 1 | # Welcome to Serverless! 2 | # 3 | # This file is the main config file for your service. 4 | # It's very minimal at this point and uses default values. 5 | # You can always add more config options for more control. 6 | # We've included some commented out config examples here. 7 | # Just uncomment any of them to get that config option. 8 | # 9 | # For full config options, check the docs: 10 | # docs.serverless.com 11 | # 12 | # Happy Coding! 13 | 14 | service: aws-csharp # NOTE: update this with your service name 15 | 16 | # You can pin your service to only deploy with a specific Serverless version 17 | # Check out our docs for more details 18 | # frameworkVersion: "=X.X.X" 19 | 20 | provider: 21 | name: aws 22 | runtime: dotnetcore1.0 23 | 24 | # you can overwrite defaults here 25 | # stage: dev 26 | # region: us-east-1 27 | 28 | # you can add statements to the Lambda function's IAM Role here 29 | # iamRoleStatements: 30 | # - Effect: "Allow" 31 | # Action: 32 | # - "s3:ListBucket" 33 | # Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] } 34 | # - Effect: "Allow" 35 | # Action: 36 | # - "s3:PutObject" 37 | # Resource: 38 | # Fn::Join: 39 | # - "" 40 | # - - "arn:aws:s3:::" 41 | # - "Ref" : "ServerlessDeploymentBucket" 42 | 43 | # you can define service wide environment variables here 44 | # environment: 45 | # variable1: value1 46 | 47 | # you can add packaging information here 48 | package: 49 | artifact: bin/release/netcoreapp1.0/publish/deploy-package.zip 50 | # exclude: 51 | # - exclude-me.js 52 | # - exclude-me-dir/** 53 | 54 | functions: 55 | hello: 56 | handler: CsharpHandlers::AwsDotnetCsharp.Handler::Hello 57 | 58 | # The following are a few example events you can configure 59 | # NOTE: Please make sure to change your handler code to work with those events 60 | # Check the event documentation for details 61 | events: 62 | - http: 63 | path: / 64 | method: get 65 | # - s3: ${env:BUCKET} 66 | # - schedule: rate(10 minutes) 67 | # - sns: greeter-topic 68 | # - stream: arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000 69 | # - iot: 70 | # sql: "SELECT * FROM 'some_topic'" 71 | 72 | # Define function environment variables here 73 | # environment: 74 | # variable2: value2 75 | 76 | # you can add CloudFormation resource templates here 77 | #resources: 78 | # Resources: 79 | # NewResource: 80 | # Type: AWS::S3::Bucket 81 | # Properties: 82 | # BucketName: my-new-bucket 83 | # Outputs: 84 | # NewOutput: 85 | # Description: "Description for the output" 86 | # Value: "Some output value" 87 | -------------------------------------------------------------------------------- /csharp2/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using Amazon.Lambda.Core; 2 | 3 | [assembly:LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))] 4 | -------------------------------------------------------------------------------- /csharp2/Handler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AwsDotnetCsharp 4 | { 5 | public class Handler 6 | { 7 | public Response Hello(Request request) 8 | { 9 | return new Response { 10 | statusCode = 200, 11 | body = "hello" 12 | }; 13 | } 14 | } 15 | 16 | public class Response 17 | { 18 | public int statusCode { get; set;} 19 | public string body {get; set;} 20 | } 21 | 22 | public class Request 23 | { 24 | } 25 | } -------------------------------------------------------------------------------- /csharp2/aws-csharp2.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp2.0 5 | true 6 | CsharpHandlers 7 | aws-csharp2 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /csharp2/build.ps1: -------------------------------------------------------------------------------- 1 | dotnet restore 2 | dotnet lambda package --configuration release --framework netcoreapp2.0 --output-package bin/release/netcoreapp2.0/publish/deploy-package.zip 3 | -------------------------------------------------------------------------------- /csharp2/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | dotnet restore 4 | dotnet lambda package --configuration release --framework netcoreapp2.0 --output-package bin/release/netcoreapp2.0/publish/deploy-package.zip 5 | -------------------------------------------------------------------------------- /csharp2/serverless.yml: -------------------------------------------------------------------------------- 1 | # Welcome to Serverless! 2 | # 3 | # This file is the main config file for your service. 4 | # It's very minimal at this point and uses default values. 5 | # You can always add more config options for more control. 6 | # We've included some commented out config examples here. 7 | # Just uncomment any of them to get that config option. 8 | # 9 | # For full config options, check the docs: 10 | # docs.serverless.com 11 | # 12 | # Happy Coding! 13 | 14 | service: aws-csharp2 15 | 16 | # You can pin your service to only deploy with a specific Serverless version 17 | # Check out our docs for more details 18 | # frameworkVersion: "=X.X.X" 19 | 20 | provider: 21 | name: aws 22 | runtime: dotnetcore2.0 23 | 24 | # you can overwrite defaults here 25 | # stage: dev 26 | region: ap-southeast-2 27 | 28 | # you can add statements to the Lambda function's IAM Role here 29 | # iamRoleStatements: 30 | # - Effect: "Allow" 31 | # Action: 32 | # - "s3:ListBucket" 33 | # Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] } 34 | # - Effect: "Allow" 35 | # Action: 36 | # - "s3:PutObject" 37 | # Resource: 38 | # Fn::Join: 39 | # - "" 40 | # - - "arn:aws:s3:::" 41 | # - "Ref" : "ServerlessDeploymentBucket" 42 | # - "/*" 43 | 44 | # you can define service wide environment variables here 45 | # environment: 46 | # variable1: value1 47 | 48 | # you can add packaging information here 49 | package: 50 | artifact: bin/release/netcoreapp2.0/publish/deploy-package.zip 51 | # exclude: 52 | # - exclude-me.js 53 | # - exclude-me-dir/** 54 | 55 | functions: 56 | hello: 57 | handler: CsharpHandlers::AwsDotnetCsharp.Handler::Hello 58 | 59 | # The following are a few example events you can configure 60 | # NOTE: Please make sure to change your handler code to work with those events 61 | # Check the event documentation for details 62 | events: 63 | - http: 64 | path: / 65 | method: get 66 | # - s3: ${env:BUCKET} 67 | # - schedule: rate(10 minutes) 68 | # - sns: greeter-topic 69 | # - stream: arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000 70 | # - alexaSkill 71 | # - alexaSmartHome: amzn1.ask.skill.xx-xx-xx-xx 72 | # - iot: 73 | # sql: "SELECT * FROM 'some_topic'" 74 | # - cloudwatchEvent: 75 | # event: 76 | # source: 77 | # - "aws.ec2" 78 | # detail-type: 79 | # - "EC2 Instance State-change Notification" 80 | # detail: 81 | # state: 82 | # - pending 83 | # - cloudwatchLog: '/aws/lambda/hello' 84 | # - cognitoUserPool: 85 | # pool: MyUserPool 86 | # trigger: PreSignUp 87 | 88 | # Define function environment variables here 89 | # environment: 90 | # variable2: value2 91 | 92 | # you can add CloudFormation resource templates here 93 | #resources: 94 | # Resources: 95 | # NewResource: 96 | # Type: AWS::S3::Bucket 97 | # Properties: 98 | # BucketName: my-new-bucket 99 | # Outputs: 100 | # NewOutput: 101 | # Description: "Description for the output" 102 | # Value: "Some output value" 103 | -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | declare -a folders=("csharp" "csharp2" "fsharp" "fsharp2" "go" "java" "python" "python3" "nodejs4" "nodejs6") 3 | 4 | export AWS_PROFILE=personal 5 | 6 | for i in `seq 1 10`; 7 | do 8 | for folder in "${folders[@]}" 9 | do 10 | cd $folder 11 | pwd 12 | 13 | sls deploy --region ap-southeast-2 14 | 15 | cd .. 16 | done 17 | 18 | done -------------------------------------------------------------------------------- /fsharp/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | 24 | # Visual Studio 2015 cache/options directory 25 | .vs/ 26 | # Uncomment if you have tasks that create the project's static files in wwwroot 27 | #wwwroot/ 28 | 29 | # MSTest test Results 30 | [Tt]est[Rr]esult*/ 31 | [Bb]uild[Ll]og.* 32 | 33 | # NUNIT 34 | *.VisualState.xml 35 | TestResult.xml 36 | 37 | # Build Results of an ATL Project 38 | [Dd]ebugPS/ 39 | [Rr]eleasePS/ 40 | dlldata.c 41 | 42 | # DNX 43 | project.lock.json 44 | artifacts/ 45 | 46 | *_i.c 47 | *_p.c 48 | *_i.h 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.tmp_proj 63 | *.log 64 | *.vspscc 65 | *.vssscc 66 | .builds 67 | *.pidb 68 | *.svclog 69 | *.scc 70 | 71 | # Chutzpah Test files 72 | _Chutzpah* 73 | 74 | # Visual C++ cache files 75 | ipch/ 76 | *.aps 77 | *.ncb 78 | *.opendb 79 | *.opensdf 80 | *.sdf 81 | *.cachefile 82 | 83 | # Visual Studio profiler 84 | *.psess 85 | *.vsp 86 | *.vspx 87 | *.sap 88 | 89 | # TFS 2012 Local Workspace 90 | $tf/ 91 | 92 | # Guidance Automation Toolkit 93 | *.gpState 94 | 95 | # ReSharper is a .NET coding add-in 96 | _ReSharper*/ 97 | *.[Rr]e[Ss]harper 98 | *.DotSettings.user 99 | 100 | # JustCode is a .NET coding add-in 101 | .JustCode 102 | 103 | # TeamCity is a build add-in 104 | _TeamCity* 105 | 106 | # DotCover is a Code Coverage Tool 107 | *.dotCover 108 | 109 | # NCrunch 110 | _NCrunch_* 111 | .*crunch*.local.xml 112 | nCrunchTemp_* 113 | 114 | # MightyMoose 115 | *.mm.* 116 | AutoTest.Net/ 117 | 118 | # Web workbench (sass) 119 | .sass-cache/ 120 | 121 | # Installshield output folder 122 | [Ee]xpress/ 123 | 124 | # DocProject is a documentation generator add-in 125 | DocProject/buildhelp/ 126 | DocProject/Help/*.HxT 127 | DocProject/Help/*.HxC 128 | DocProject/Help/*.hhc 129 | DocProject/Help/*.hhk 130 | DocProject/Help/*.hhp 131 | DocProject/Help/Html2 132 | DocProject/Help/html 133 | 134 | # Click-Once directory 135 | publish/ 136 | 137 | # Publish Web Output 138 | *.[Pp]ublish.xml 139 | *.azurePubxml 140 | # TODO: Comment the next line if you want to checkin your web deploy settings 141 | # but database connection strings (with potential passwords) will be unencrypted 142 | *.pubxml 143 | *.publishproj 144 | 145 | # NuGet Packages 146 | *.nupkg 147 | # The packages folder can be ignored because of Package Restore 148 | **/packages/* 149 | # except build/, which is used as an MSBuild target. 150 | !**/packages/build/ 151 | # Uncomment if necessary however generally it will be regenerated when needed 152 | #!**/packages/repositories.config 153 | # NuGet v3's project.json files produces more ignoreable files 154 | *.nuget.props 155 | *.nuget.targets 156 | 157 | # Microsoft Azure Build Output 158 | csx/ 159 | *.build.csdef 160 | 161 | # Microsoft Azure Emulator 162 | ecf/ 163 | rcf/ 164 | 165 | # Microsoft Azure ApplicationInsights config file 166 | ApplicationInsights.config 167 | 168 | # Windows Store app package directory 169 | AppPackages/ 170 | BundleArtifacts/ 171 | 172 | # Visual Studio cache files 173 | # files ending in .cache can be ignored 174 | *.[Cc]ache 175 | # but keep track of directories ending in .cache 176 | !*.[Cc]ache/ 177 | 178 | # Others 179 | ClientBin/ 180 | ~$* 181 | *~ 182 | *.dbmdl 183 | *.dbproj.schemaview 184 | *.pfx 185 | *.publishsettings 186 | node_modules/ 187 | orleans.codegen.cs 188 | 189 | # RIA/Silverlight projects 190 | Generated_Code/ 191 | 192 | # Backup & report files from converting an old project file 193 | # to a newer Visual Studio version. Backup files are not needed, 194 | # because we have git ;-) 195 | _UpgradeReport_Files/ 196 | Backup*/ 197 | UpgradeLog*.XML 198 | UpgradeLog*.htm 199 | 200 | # SQL Server files 201 | *.mdf 202 | *.ldf 203 | 204 | # Business Intelligence projects 205 | *.rdl.data 206 | *.bim.layout 207 | *.bim_*.settings 208 | 209 | # Microsoft Fakes 210 | FakesAssemblies/ 211 | 212 | # GhostDoc plugin setting file 213 | *.GhostDoc.xml 214 | 215 | # Node.js Tools for Visual Studio 216 | .ntvs_analysis.dat 217 | 218 | # Visual Studio 6 build log 219 | *.plg 220 | 221 | # Visual Studio 6 workspace options file 222 | *.opt 223 | 224 | # Visual Studio LightSwitch build output 225 | **/*.HTMLClient/GeneratedArtifacts 226 | **/*.DesktopClient/GeneratedArtifacts 227 | **/*.DesktopClient/ModelManifest.xml 228 | **/*.Server/GeneratedArtifacts 229 | **/*.Server/ModelManifest.xml 230 | _Pvt_Extensions 231 | 232 | # Paket dependency manager 233 | .paket/paket.exe 234 | 235 | # FAKE - F# Make 236 | .fake/ 237 | *.orig 238 | 239 | # macOS 240 | .DS_Store 241 | 242 | # JetBrains Rider C# IDE 243 | .idea* 244 | 245 | # Serverless directories 246 | .serverless 247 | -------------------------------------------------------------------------------- /fsharp/Handler.fs: -------------------------------------------------------------------------------- 1 | namespace AwsDotnetFsharp 2 | 3 | open Amazon.Lambda.Core 4 | 5 | [)>] 6 | do () 7 | 8 | module Handler = 9 | open System 10 | open System.IO 11 | open System.Text 12 | 13 | type Response = { statusCode : int; body : string } 14 | 15 | let hello(): Response = { 16 | statusCode = 200 17 | body = "hello" 18 | } -------------------------------------------------------------------------------- /fsharp/aws-fsharp.fsproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp1.0 5 | true 6 | FsharpHandlers 7 | aws-fsharp 8 | 1.0.4 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /fsharp/build.ps1: -------------------------------------------------------------------------------- 1 | dotnet restore 2 | dotnet lambda package --configuration release --framework netcoreapp1.0 --output-package bin/release/netcoreapp1.0/publish/deploy-package.zip 3 | -------------------------------------------------------------------------------- /fsharp/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | dotnet restore 4 | dotnet lambda package --configuration release --framework netcoreapp1.0 --output-package bin/release/netcoreapp1.0/publish/deploy-package.zip -------------------------------------------------------------------------------- /fsharp/serverless.yml: -------------------------------------------------------------------------------- 1 | # Welcome to Serverless! 2 | # 3 | # This file is the main config file for your service. 4 | # It's very minimal at this point and uses default values. 5 | # You can always add more config options for more control. 6 | # We've included some commented out config examples here. 7 | # Just uncomment any of them to get that config option. 8 | # 9 | # For full config options, check the docs: 10 | # docs.serverless.com 11 | # 12 | # Happy Coding! 13 | 14 | service: aws-fsharp # NOTE: update this with your service name 15 | 16 | # You can pin your service to only deploy with a specific Serverless version 17 | # Check out our docs for more details 18 | # frameworkVersion: "=X.X.X" 19 | 20 | provider: 21 | name: aws 22 | runtime: dotnetcore1.0 23 | 24 | # you can overwrite defaults here 25 | # stage: dev 26 | # region: us-east-1 27 | 28 | # you can add statements to the Lambda function's IAM Role here 29 | # iamRoleStatements: 30 | # - Effect: "Allow" 31 | # Action: 32 | # - "s3:ListBucket" 33 | # Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] } 34 | # - Effect: "Allow" 35 | # Action: 36 | # - "s3:PutObject" 37 | # Resource: 38 | # Fn::Join: 39 | # - "" 40 | # - - "arn:aws:s3:::" 41 | # - "Ref" : "ServerlessDeploymentBucket" 42 | # - "/*" 43 | 44 | # you can define service wide environment variables here 45 | # environment: 46 | # variable1: value1 47 | 48 | # you can add packaging information here 49 | package: 50 | artifact: bin/release/netcoreapp1.0/publish/deploy-package.zip 51 | # exclude: 52 | # - exclude-me.js 53 | # - exclude-me-dir/** 54 | 55 | functions: 56 | hello: 57 | handler: FsharpHandlers::AwsDotnetFsharp.Handler::hello 58 | events: 59 | - http: 60 | path: / 61 | method: get 62 | 63 | # The following are a few example events you can configure 64 | # NOTE: Please make sure to change your handler code to work with those events 65 | # Check the event documentation for details 66 | # events: 67 | # - http: 68 | # path: users/create 69 | # method: get 70 | # - s3: ${env:BUCKET} 71 | # - schedule: rate(10 minutes) 72 | # - sns: greeter-topic 73 | # - stream: arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000 74 | # - iot: 75 | # sql: "SELECT * FROM 'some_topic'" 76 | # - cloudwatchEvent: 77 | # event: 78 | # source: 79 | # - "aws.ec2" 80 | # detail-type: 81 | # - "EC2 Instance State-change Notification" 82 | # detail: 83 | # state: 84 | # - pending 85 | 86 | # Define function environment variables here 87 | # environment: 88 | # variable2: value2 89 | 90 | # you can add CloudFormation resource templates here 91 | #resources: 92 | # Resources: 93 | # NewResource: 94 | # Type: AWS::S3::Bucket 95 | # Properties: 96 | # BucketName: my-new-bucket 97 | # Outputs: 98 | # NewOutput: 99 | # Description: "Description for the output" 100 | # Value: "Some output value" 101 | -------------------------------------------------------------------------------- /fsharp2/Handler.fs: -------------------------------------------------------------------------------- 1 | namespace AwsDotnetFsharp 2 | 3 | open Amazon.Lambda.Core 4 | 5 | [)>] 6 | do () 7 | 8 | module Handler = 9 | open System 10 | open System.IO 11 | open System.Text 12 | 13 | type Response = { statusCode : int; body : string } 14 | 15 | let hello(): Response = { 16 | statusCode = 200 17 | body = "hello" 18 | } -------------------------------------------------------------------------------- /fsharp2/aws-fsharp2.fsproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.0 5 | FsharpHandlers 6 | aws-fsharp2 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /fsharp2/build.ps1: -------------------------------------------------------------------------------- 1 | dotnet restore 2 | dotnet lambda package --configuration release --framework netcoreapp2.0 --output-package bin/release/netcoreapp2.0/publish/deploy-package.zip 3 | -------------------------------------------------------------------------------- /fsharp2/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | dotnet restore 4 | dotnet lambda package --configuration release --framework netcoreapp1.0 --output-package bin/release/netcoreapp2.0/publish/deploy-package.zip--configuration release --framework netcoreapp2.0 --output-package bin/release/netcoreapp2.0/publish/deploy-package.zip -------------------------------------------------------------------------------- /fsharp2/serverless.yml: -------------------------------------------------------------------------------- 1 | # Welcome to Serverless! 2 | # 3 | # This file is the main config file for your service. 4 | # It's very minimal at this point and uses default values. 5 | # You can always add more config options for more control. 6 | # We've included some commented out config examples here. 7 | # Just uncomment any of them to get that config option. 8 | # 9 | # For full config options, check the docs: 10 | # docs.serverless.com 11 | # 12 | # Happy Coding! 13 | 14 | service: aws-fsharp2 15 | 16 | # You can pin your service to only deploy with a specific Serverless version 17 | # Check out our docs for more details 18 | # frameworkVersion: "=X.X.X" 19 | 20 | provider: 21 | name: aws 22 | runtime: dotnetcore2.0 23 | 24 | # you can overwrite defaults here 25 | # stage: dev 26 | # region: us-east-1 27 | 28 | # you can add statements to the Lambda function's IAM Role here 29 | # iamRoleStatements: 30 | # - Effect: "Allow" 31 | # Action: 32 | # - "s3:ListBucket" 33 | # Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] } 34 | # - Effect: "Allow" 35 | # Action: 36 | # - "s3:PutObject" 37 | # Resource: 38 | # Fn::Join: 39 | # - "" 40 | # - - "arn:aws:s3:::" 41 | # - "Ref" : "ServerlessDeploymentBucket" 42 | # - "/*" 43 | 44 | # you can define service wide environment variables here 45 | # environment: 46 | # variable1: value1 47 | 48 | # you can add packaging information here 49 | package: 50 | artifact: bin/release/netcoreapp2.0/publish/deploy-package.zip 51 | # exclude: 52 | # - exclude-me.js 53 | # - exclude-me-dir/** 54 | 55 | functions: 56 | hello: 57 | handler: FsharpHandlers::AwsDotnetFsharp.Handler::hello 58 | 59 | # The following are a few example events you can configure 60 | # NOTE: Please make sure to change your handler code to work with those events 61 | # Check the event documentation for details 62 | events: 63 | - http: 64 | path: / 65 | method: get 66 | # - s3: ${env:BUCKET} 67 | # - schedule: rate(10 minutes) 68 | # - sns: greeter-topic 69 | # - stream: arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000 70 | # - alexaSkill 71 | # - alexaSmartHome: amzn1.ask.skill.xx-xx-xx-xx 72 | # - iot: 73 | # sql: "SELECT * FROM 'some_topic'" 74 | # - cloudwatchEvent: 75 | # event: 76 | # source: 77 | # - "aws.ec2" 78 | # detail-type: 79 | # - "EC2 Instance State-change Notification" 80 | # detail: 81 | # state: 82 | # - pending 83 | # - cloudwatchLog: '/aws/lambda/hello' 84 | # - cognitoUserPool: 85 | # pool: MyUserPool 86 | # trigger: PreSignUp 87 | 88 | # Define function environment variables here 89 | # environment: 90 | # variable2: value2 91 | 92 | # you can add CloudFormation resource templates here 93 | #resources: 94 | # Resources: 95 | # NewResource: 96 | # Type: AWS::S3::Bucket 97 | # Properties: 98 | # BucketName: my-new-bucket 99 | # Outputs: 100 | # NewOutput: 101 | # Description: "Description for the output" 102 | # Value: "Some output value" 103 | -------------------------------------------------------------------------------- /go/.gitignore: -------------------------------------------------------------------------------- 1 | .serverless 2 | 3 | bin/ -------------------------------------------------------------------------------- /go/Makefile: -------------------------------------------------------------------------------- 1 | build: 2 | go get github.com/aws/aws-lambda-go/lambda 3 | go get github.com/aws/aws-lambda-go/events 4 | env GOOS=linux go build -o bin/main -------------------------------------------------------------------------------- /go/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/aws/aws-lambda-go/events" 7 | "github.com/aws/aws-lambda-go/lambda" 8 | ) 9 | 10 | func Handler(ctx context.Context, request *events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) { 11 | return events.APIGatewayProxyResponse{Body: "hello", StatusCode: 200}, nil 12 | } 13 | 14 | func main() { 15 | lambda.Start(Handler) 16 | } 17 | -------------------------------------------------------------------------------- /go/serverless.yml: -------------------------------------------------------------------------------- 1 | # Welcome to Serverless! 2 | # 3 | # This file is the main config file for your service. 4 | # It's very minimal at this point and uses default values. 5 | # You can always add more config options for more control. 6 | # We've included some commented out config examples here. 7 | # Just uncomment any of them to get that config option. 8 | # 9 | # For full config options, check the docs: 10 | # docs.serverless.com 11 | # 12 | # Happy Coding! 13 | 14 | service: aws-go 15 | 16 | # You can pin your service to only deploy with a specific Serverless version 17 | # Check out our docs for more details 18 | # frameworkVersion: "=X.X.X" 19 | 20 | provider: 21 | name: aws 22 | runtime: go1.x 23 | 24 | # you can overwrite defaults here 25 | # stage: dev 26 | # region: us-east-1 27 | 28 | # you can add statements to the Lambda function's IAM Role here 29 | # iamRoleStatements: 30 | # - Effect: "Allow" 31 | # Action: 32 | # - "s3:ListBucket" 33 | # Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] } 34 | # - Effect: "Allow" 35 | # Action: 36 | # - "s3:PutObject" 37 | # Resource: 38 | # Fn::Join: 39 | # - "" 40 | # - - "arn:aws:s3:::" 41 | # - "Ref" : "ServerlessDeploymentBucket" 42 | # - "/*" 43 | 44 | # you can define service wide environment variables here 45 | # environment: 46 | # variable1: value1 47 | 48 | package: 49 | exclude: 50 | - ./** 51 | include: 52 | - ./bin/** 53 | 54 | functions: 55 | hello: 56 | handler: bin/main 57 | events: 58 | - http: 59 | path: / 60 | method: get 61 | 62 | # The following are a few example events you can configure 63 | # NOTE: Please make sure to change your handler code to work with those events 64 | # Check the event documentation for details 65 | # events: 66 | # events: 67 | # - http: 68 | # path: users/create 69 | # method: get 70 | # - s3: ${env:BUCKET} 71 | # - schedule: rate(10 minutes) 72 | # - sns: greeter-topic 73 | # - stream: arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000 74 | # - alexaSkill 75 | # - alexaSmartHome: amzn1.ask.skill.xx-xx-xx-xx 76 | # - iot: 77 | # sql: "SELECT * FROM 'some_topic'" 78 | # - cloudwatchEvent: 79 | # event: 80 | # source: 81 | # - "aws.ec2" 82 | # detail-type: 83 | # - "EC2 Instance State-change Notification" 84 | # detail: 85 | # state: 86 | # - pending 87 | # - cloudwatchLog: '/aws/lambda/hello' 88 | # - cognitoUserPool: 89 | # pool: MyUserPool 90 | # trigger: PreSignUp 91 | 92 | # Define function environment variables here 93 | # environment: 94 | # variable2: value2 95 | 96 | # you can add CloudFormation resource templates here 97 | #resources: 98 | # Resources: 99 | # NewResource: 100 | # Type: AWS::S3::Bucket 101 | # Properties: 102 | # BucketName: my-new-bucket 103 | # Outputs: 104 | # NewOutput: 105 | # Description: "Description for the output" 106 | # Value: "Some output value" 107 | -------------------------------------------------------------------------------- /java/.npmignore: -------------------------------------------------------------------------------- 1 | *.class 2 | target 3 | /bin/ 4 | /.settings/ 5 | .project 6 | .classpath 7 | 8 | # Package Files 9 | *.jar 10 | *.war 11 | *.ear 12 | 13 | # Serverless directories 14 | .serverless -------------------------------------------------------------------------------- /java/hello.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /java/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.serverless 5 | hello 6 | jar 7 | dev 8 | hello 9 | 10 | 11 | 1.8 12 | 1.8 13 | UTF-8 14 | 15 | 16 | 17 | 18 | com.amazonaws 19 | aws-lambda-java-core 20 | 1.1.0 21 | 22 | 23 | com.amazonaws 24 | aws-lambda-java-log4j 25 | 1.0.0 26 | 27 | 28 | com.fasterxml.jackson.core 29 | jackson-core 30 | 2.8.5 31 | 32 | 33 | com.fasterxml.jackson.core 34 | jackson-databind 35 | 2.9.10.1 36 | 37 | 38 | com.fasterxml.jackson.core 39 | jackson-annotations 40 | 2.8.5 41 | 42 | 43 | 44 | 45 | 46 | 55 | 56 | org.apache.maven.plugins 57 | maven-shade-plugin 58 | 2.3 59 | 60 | false 61 | 62 | 63 | 64 | package 65 | 66 | shade 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /java/serverless.yml: -------------------------------------------------------------------------------- 1 | # Welcome to Serverless! 2 | # 3 | # This file is the main config file for your service. 4 | # It's very minimal at this point and uses default values. 5 | # You can always add more config options for more control. 6 | # We've included some commented out config examples here. 7 | # Just uncomment any of them to get that config option. 8 | # 9 | # For full config options, check the docs: 10 | # docs.serverless.com 11 | # 12 | # Happy Coding! 13 | 14 | service: aws-java-maven # NOTE: update this with your service name 15 | 16 | # You can pin your service to only deploy with a specific Serverless version 17 | # Check out our docs for more details 18 | # frameworkVersion: "=X.X.X" 19 | 20 | provider: 21 | name: aws 22 | runtime: java8 23 | 24 | # you can overwrite defaults here 25 | # stage: dev 26 | # region: us-east-1 27 | 28 | # you can add statements to the Lambda function's IAM Role here 29 | # iamRoleStatements: 30 | # - Effect: "Allow" 31 | # Action: 32 | # - "s3:ListBucket" 33 | # Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] } 34 | # - Effect: "Allow" 35 | # Action: 36 | # - "s3:PutObject" 37 | # Resource: 38 | # Fn::Join: 39 | # - "" 40 | # - - "arn:aws:s3:::" 41 | # - "Ref" : "ServerlessDeploymentBucket" 42 | 43 | # you can define service wide environment variables here 44 | # environment: 45 | # variable1: value1 46 | 47 | # you can add packaging information here 48 | package: 49 | artifact: target/hello-dev.jar 50 | 51 | functions: 52 | hello: 53 | handler: com.serverless.Handler 54 | 55 | # The following are a few example events you can configure 56 | # NOTE: Please make sure to change your handler code to work with those events 57 | # Check the event documentation for details 58 | events: 59 | - http: 60 | path: / 61 | method: get 62 | # - s3: ${env:BUCKET} 63 | # - schedule: rate(10 minutes) 64 | # - sns: greeter-topic 65 | # - stream: arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000 66 | # - alexaSkill 67 | # - iot: 68 | # sql: "SELECT * FROM 'some_topic'" 69 | 70 | # Define function environment variables here 71 | # environment: 72 | # variable2: value2 73 | 74 | # you can add CloudFormation resource templates here 75 | #resources: 76 | # Resources: 77 | # NewResource: 78 | # Type: AWS::S3::Bucket 79 | # Properties: 80 | # BucketName: my-new-bucket 81 | # Outputs: 82 | # NewOutput: 83 | # Description: "Description for the output" 84 | # Value: "Some output value" 85 | -------------------------------------------------------------------------------- /java/src/main/java/com/serverless/ApiGatewayResponse.java: -------------------------------------------------------------------------------- 1 | package com.serverless; 2 | 3 | import java.nio.charset.StandardCharsets; 4 | import java.util.Base64; 5 | import java.util.Collections; 6 | import java.util.Map; 7 | 8 | import org.apache.log4j.Logger; 9 | 10 | import com.fasterxml.jackson.core.JsonProcessingException; 11 | import com.fasterxml.jackson.databind.ObjectMapper; 12 | 13 | public class ApiGatewayResponse { 14 | 15 | private final int statusCode; 16 | private final String body; 17 | private final Map headers; 18 | private final boolean isBase64Encoded; 19 | 20 | public ApiGatewayResponse(int statusCode, String body, Map headers, boolean isBase64Encoded) { 21 | this.statusCode = statusCode; 22 | this.body = body; 23 | this.headers = headers; 24 | this.isBase64Encoded = isBase64Encoded; 25 | } 26 | 27 | public int getStatusCode() { 28 | return statusCode; 29 | } 30 | 31 | public String getBody() { 32 | return body; 33 | } 34 | 35 | public Map getHeaders() { 36 | return headers; 37 | } 38 | 39 | // API Gateway expects the property to be called "isBase64Encoded" => isIs 40 | public boolean isIsBase64Encoded() { 41 | return isBase64Encoded; 42 | } 43 | 44 | public static Builder builder() { 45 | return new Builder(); 46 | } 47 | 48 | public static class Builder { 49 | 50 | private static final Logger LOG = Logger.getLogger(ApiGatewayResponse.Builder.class); 51 | 52 | private static final ObjectMapper objectMapper = new ObjectMapper(); 53 | 54 | private int statusCode = 200; 55 | private Map headers = Collections.emptyMap(); 56 | private String rawBody; 57 | private Object objectBody; 58 | private byte[] binaryBody; 59 | private boolean base64Encoded; 60 | 61 | public Builder setStatusCode(int statusCode) { 62 | this.statusCode = statusCode; 63 | return this; 64 | } 65 | 66 | public Builder setHeaders(Map headers) { 67 | this.headers = headers; 68 | return this; 69 | } 70 | 71 | /** 72 | * Builds the {@link ApiGatewayResponse} using the passed raw body string. 73 | */ 74 | public Builder setRawBody(String rawBody) { 75 | this.rawBody = rawBody; 76 | return this; 77 | } 78 | 79 | /** 80 | * Builds the {@link ApiGatewayResponse} using the passed object body 81 | * converted to JSON. 82 | */ 83 | public Builder setObjectBody(Object objectBody) { 84 | this.objectBody = objectBody; 85 | return this; 86 | } 87 | 88 | /** 89 | * Builds the {@link ApiGatewayResponse} using the passed binary body 90 | * encoded as base64. {@link #setBase64Encoded(boolean) 91 | * setBase64Encoded(true)} will be in invoked automatically. 92 | */ 93 | public Builder setBinaryBody(byte[] binaryBody) { 94 | this.binaryBody = binaryBody; 95 | setBase64Encoded(true); 96 | return this; 97 | } 98 | 99 | /** 100 | * A binary or rather a base64encoded responses requires 101 | *
    102 | *
  1. "Binary Media Types" to be configured in API Gateway 103 | *
  2. a request with an "Accept" header set to one of the "Binary Media 104 | * Types" 105 | *
106 | */ 107 | public Builder setBase64Encoded(boolean base64Encoded) { 108 | this.base64Encoded = base64Encoded; 109 | return this; 110 | } 111 | 112 | public ApiGatewayResponse build() { 113 | String body = null; 114 | if (rawBody != null) { 115 | body = rawBody; 116 | } else if (objectBody != null) { 117 | try { 118 | body = objectMapper.writeValueAsString(objectBody); 119 | } catch (JsonProcessingException e) { 120 | LOG.error("failed to serialize object", e); 121 | throw new RuntimeException(e); 122 | } 123 | } else if (binaryBody != null) { 124 | body = new String(Base64.getEncoder().encode(binaryBody), StandardCharsets.UTF_8); 125 | } 126 | return new ApiGatewayResponse(statusCode, body, headers, base64Encoded); 127 | } 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /java/src/main/java/com/serverless/Handler.java: -------------------------------------------------------------------------------- 1 | package com.serverless; 2 | 3 | import java.util.Map; 4 | 5 | import com.amazonaws.services.lambda.runtime.Context; 6 | import com.amazonaws.services.lambda.runtime.RequestHandler; 7 | 8 | public class Handler implements RequestHandler, ApiGatewayResponse> { 9 | 10 | @Override 11 | public ApiGatewayResponse handleRequest(Map input, Context context) { 12 | return ApiGatewayResponse.builder() 13 | .setStatusCode(200) 14 | .setObjectBody("hello") 15 | .build(); 16 | } 17 | } -------------------------------------------------------------------------------- /java/src/main/java/com/serverless/Response.java: -------------------------------------------------------------------------------- 1 | package com.serverless; 2 | 3 | public class Response { 4 | 5 | private final String body; 6 | private final Integer status; 7 | 8 | public Response(String body, Integer status) { 9 | this.body = body; 10 | this.status = status; 11 | } 12 | 13 | public String getBody() { 14 | return this.body; 15 | } 16 | 17 | public Integer getInput() { 18 | return this.status; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /java/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log = . 2 | log4j.rootLogger = DEBUG, LAMBDA 3 | 4 | log4j.appender.LAMBDA=com.amazonaws.services.lambda.runtime.log4j.LambdaAppender 5 | log4j.appender.LAMBDA.layout=org.apache.log4j.PatternLayout 6 | log4j.appender.LAMBDA.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss} <%X{AWSRequestId}> %-5p %c:%L - %m%n 7 | -------------------------------------------------------------------------------- /nodejs4/.npmignore: -------------------------------------------------------------------------------- 1 | # package directories 2 | node_modules 3 | jspm_packages 4 | 5 | # Serverless directories 6 | .serverless -------------------------------------------------------------------------------- /nodejs4/handler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports.hello = (event, context, callback) => { 4 | const response = { 5 | statusCode: 200, 6 | body: "hello" 7 | }; 8 | 9 | callback(null, response); 10 | 11 | // Use this code if you don't use the http event with the LAMBDA-PROXY integration 12 | // callback(null, { message: 'Go Serverless v1.0! Your function executed successfully!', event }); 13 | }; 14 | -------------------------------------------------------------------------------- /nodejs4/serverless.yml: -------------------------------------------------------------------------------- 1 | # Welcome to Serverless! 2 | # 3 | # This file is the main config file for your service. 4 | # It's very minimal at this point and uses default values. 5 | # You can always add more config options for more control. 6 | # We've included some commented out config examples here. 7 | # Just uncomment any of them to get that config option. 8 | # 9 | # For full config options, check the docs: 10 | # docs.serverless.com 11 | # 12 | # Happy Coding! 13 | 14 | service: aws-nodejs4 # NOTE: update this with your service name 15 | 16 | # You can pin your service to only deploy with a specific Serverless version 17 | # Check out our docs for more details 18 | # frameworkVersion: "=X.X.X" 19 | 20 | provider: 21 | name: aws 22 | runtime: nodejs4.3 23 | 24 | # you can overwrite defaults here 25 | # stage: dev 26 | # region: us-east-1 27 | 28 | # you can add statements to the Lambda function's IAM Role here 29 | # iamRoleStatements: 30 | # - Effect: "Allow" 31 | # Action: 32 | # - "s3:ListBucket" 33 | # Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] } 34 | # - Effect: "Allow" 35 | # Action: 36 | # - "s3:PutObject" 37 | # Resource: 38 | # Fn::Join: 39 | # - "" 40 | # - - "arn:aws:s3:::" 41 | # - "Ref" : "ServerlessDeploymentBucket" 42 | 43 | # you can define service wide environment variables here 44 | # environment: 45 | # variable1: value1 46 | 47 | # you can add packaging information here 48 | #package: 49 | # include: 50 | # - include-me.js 51 | # - include-me-dir/** 52 | # exclude: 53 | # - exclude-me.js 54 | # - exclude-me-dir/** 55 | 56 | functions: 57 | hello: 58 | handler: handler.hello 59 | 60 | # The following are a few example events you can configure 61 | # NOTE: Please make sure to change your handler code to work with those events 62 | # Check the event documentation for details 63 | events: 64 | - http: 65 | path: / 66 | method: get 67 | # - s3: ${env:BUCKET} 68 | # - schedule: rate(10 minutes) 69 | # - sns: greeter-topic 70 | # - stream: arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000 71 | # - alexaSkill 72 | # - iot: 73 | # sql: "SELECT * FROM 'some_topic'" 74 | 75 | # Define function environment variables here 76 | # environment: 77 | # variable2: value2 78 | 79 | # you can add CloudFormation resource templates here 80 | #resources: 81 | # Resources: 82 | # NewResource: 83 | # Type: AWS::S3::Bucket 84 | # Properties: 85 | # BucketName: my-new-bucket 86 | # Outputs: 87 | # NewOutput: 88 | # Description: "Description for the output" 89 | # Value: "Some output value" 90 | -------------------------------------------------------------------------------- /nodejs6/.npmignore: -------------------------------------------------------------------------------- 1 | # package directories 2 | node_modules 3 | jspm_packages 4 | 5 | # Serverless directories 6 | .serverless -------------------------------------------------------------------------------- /nodejs6/handler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports.hello = (event, context, callback) => { 4 | const response = { 5 | statusCode: 200, 6 | body: "hello" 7 | }; 8 | 9 | callback(null, response); 10 | 11 | // Use this code if you don't use the http event with the LAMBDA-PROXY integration 12 | // callback(null, { message: 'Go Serverless v1.0! Your function executed successfully!', event }); 13 | }; 14 | -------------------------------------------------------------------------------- /nodejs6/serverless.yml: -------------------------------------------------------------------------------- 1 | # Welcome to Serverless! 2 | # 3 | # This file is the main config file for your service. 4 | # It's very minimal at this point and uses default values. 5 | # You can always add more config options for more control. 6 | # We've included some commented out config examples here. 7 | # Just uncomment any of them to get that config option. 8 | # 9 | # For full config options, check the docs: 10 | # docs.serverless.com 11 | # 12 | # Happy Coding! 13 | 14 | service: aws-nodejs6 # NOTE: update this with your service name 15 | 16 | # You can pin your service to only deploy with a specific Serverless version 17 | # Check out our docs for more details 18 | # frameworkVersion: "=X.X.X" 19 | 20 | provider: 21 | name: aws 22 | runtime: nodejs6.10 23 | 24 | # you can overwrite defaults here 25 | # stage: dev 26 | # region: us-east-1 27 | 28 | # you can add statements to the Lambda function's IAM Role here 29 | # iamRoleStatements: 30 | # - Effect: "Allow" 31 | # Action: 32 | # - "s3:ListBucket" 33 | # Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] } 34 | # - Effect: "Allow" 35 | # Action: 36 | # - "s3:PutObject" 37 | # Resource: 38 | # Fn::Join: 39 | # - "" 40 | # - - "arn:aws:s3:::" 41 | # - "Ref" : "ServerlessDeploymentBucket" 42 | 43 | # you can define service wide environment variables here 44 | # environment: 45 | # variable1: value1 46 | 47 | # you can add packaging information here 48 | #package: 49 | # include: 50 | # - include-me.js 51 | # - include-me-dir/** 52 | # exclude: 53 | # - exclude-me.js 54 | # - exclude-me-dir/** 55 | 56 | functions: 57 | hello: 58 | handler: handler.hello 59 | 60 | # The following are a few example events you can configure 61 | # NOTE: Please make sure to change your handler code to work with those events 62 | # Check the event documentation for details 63 | events: 64 | - http: 65 | path: / 66 | method: get 67 | # - s3: ${env:BUCKET} 68 | # - schedule: rate(10 minutes) 69 | # - sns: greeter-topic 70 | # - stream: arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000 71 | # - alexaSkill 72 | # - iot: 73 | # sql: "SELECT * FROM 'some_topic'" 74 | 75 | # Define function environment variables here 76 | # environment: 77 | # variable2: value2 78 | 79 | # you can add CloudFormation resource templates here 80 | #resources: 81 | # Resources: 82 | # NewResource: 83 | # Type: AWS::S3::Bucket 84 | # Properties: 85 | # BucketName: my-new-bucket 86 | # Outputs: 87 | # NewOutput: 88 | # Description: "Description for the output" 89 | # Value: "Some output value" 90 | -------------------------------------------------------------------------------- /python/.npmignore: -------------------------------------------------------------------------------- 1 | # Distribution / packaging 2 | .Python 3 | env/ 4 | build/ 5 | develop-eggs/ 6 | dist/ 7 | downloads/ 8 | eggs/ 9 | .eggs/ 10 | lib/ 11 | lib64/ 12 | parts/ 13 | sdist/ 14 | var/ 15 | *.egg-info/ 16 | .installed.cfg 17 | *.egg 18 | 19 | # Serverless directories 20 | .serverless -------------------------------------------------------------------------------- /python/handler.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | def hello(event, context): 4 | return { 5 | "statusCode": 200, 6 | "body": "hello" 7 | } 8 | -------------------------------------------------------------------------------- /python/serverless.yml: -------------------------------------------------------------------------------- 1 | # Welcome to Serverless! 2 | # 3 | # This file is the main config file for your service. 4 | # It's very minimal at this point and uses default values. 5 | # You can always add more config options for more control. 6 | # We've included some commented out config examples here. 7 | # Just uncomment any of them to get that config option. 8 | # 9 | # For full config options, check the docs: 10 | # docs.serverless.com 11 | # 12 | # Happy Coding! 13 | 14 | service: aws-python # NOTE: update this with your service name 15 | 16 | # You can pin your service to only deploy with a specific Serverless version 17 | # Check out our docs for more details 18 | # frameworkVersion: "=X.X.X" 19 | 20 | provider: 21 | name: aws 22 | runtime: python2.7 23 | 24 | # you can overwrite defaults here 25 | # stage: dev 26 | # region: us-east-1 27 | 28 | # you can add statements to the Lambda function's IAM Role here 29 | # iamRoleStatements: 30 | # - Effect: "Allow" 31 | # Action: 32 | # - "s3:ListBucket" 33 | # Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] } 34 | # - Effect: "Allow" 35 | # Action: 36 | # - "s3:PutObject" 37 | # Resource: 38 | # Fn::Join: 39 | # - "" 40 | # - - "arn:aws:s3:::" 41 | # - "Ref" : "ServerlessDeploymentBucket" 42 | 43 | # you can define service wide environment variables here 44 | # environment: 45 | # variable1: value1 46 | 47 | # you can add packaging information here 48 | #package: 49 | # include: 50 | # - include-me.py 51 | # - include-me-dir/** 52 | # exclude: 53 | # - exclude-me.py 54 | # - exclude-me-dir/** 55 | 56 | functions: 57 | hello: 58 | handler: handler.hello 59 | 60 | # The following are a few example events you can configure 61 | # NOTE: Please make sure to change your handler code to work with those events 62 | # Check the event documentation for details 63 | events: 64 | - http: 65 | path: / 66 | method: get 67 | # - s3: ${env:BUCKET} 68 | # - schedule: rate(10 minutes) 69 | # - sns: greeter-topic 70 | # - stream: arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000 71 | # - alexaSkill 72 | # - iot: 73 | # sql: "SELECT * FROM 'some_topic'" 74 | 75 | # Define function environment variables here 76 | # environment: 77 | # variable2: value2 78 | 79 | # you can add CloudFormation resource templates here 80 | #resources: 81 | # Resources: 82 | # NewResource: 83 | # Type: AWS::S3::Bucket 84 | # Properties: 85 | # BucketName: my-new-bucket 86 | # Outputs: 87 | # NewOutput: 88 | # Description: "Description for the output" 89 | # Value: "Some output value" 90 | -------------------------------------------------------------------------------- /python3/.npmignore: -------------------------------------------------------------------------------- 1 | # Distribution / packaging 2 | .Python 3 | env/ 4 | build/ 5 | develop-eggs/ 6 | dist/ 7 | downloads/ 8 | eggs/ 9 | .eggs/ 10 | lib/ 11 | lib64/ 12 | parts/ 13 | sdist/ 14 | var/ 15 | *.egg-info/ 16 | .installed.cfg 17 | *.egg 18 | 19 | # Serverless directories 20 | .serverless -------------------------------------------------------------------------------- /python3/handler.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | def hello(event, context): 4 | return { 5 | "statusCode": 200, 6 | "body": "hello" 7 | } 8 | -------------------------------------------------------------------------------- /python3/serverless.yml: -------------------------------------------------------------------------------- 1 | # Welcome to Serverless! 2 | # 3 | # This file is the main config file for your service. 4 | # It's very minimal at this point and uses default values. 5 | # You can always add more config options for more control. 6 | # We've included some commented out config examples here. 7 | # Just uncomment any of them to get that config option. 8 | # 9 | # For full config options, check the docs: 10 | # docs.serverless.com 11 | # 12 | # Happy Coding! 13 | 14 | service: aws-python3 # NOTE: update this with your service name 15 | 16 | # You can pin your service to only deploy with a specific Serverless version 17 | # Check out our docs for more details 18 | # frameworkVersion: "=X.X.X" 19 | 20 | provider: 21 | name: aws 22 | runtime: python3.6 23 | 24 | # you can overwrite defaults here 25 | # stage: dev 26 | # region: us-east-1 27 | 28 | # you can add statements to the Lambda function's IAM Role here 29 | # iamRoleStatements: 30 | # - Effect: "Allow" 31 | # Action: 32 | # - "s3:ListBucket" 33 | # Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] } 34 | # - Effect: "Allow" 35 | # Action: 36 | # - "s3:PutObject" 37 | # Resource: 38 | # Fn::Join: 39 | # - "" 40 | # - - "arn:aws:s3:::" 41 | # - "Ref" : "ServerlessDeploymentBucket" 42 | 43 | # you can define service wide environment variables here 44 | # environment: 45 | # variable1: value1 46 | 47 | # you can add packaging information here 48 | #package: 49 | # include: 50 | # - include-me.py 51 | # - include-me-dir/** 52 | # exclude: 53 | # - exclude-me.py 54 | # - exclude-me-dir/** 55 | 56 | functions: 57 | hello: 58 | handler: handler.hello 59 | 60 | # The following are a few example events you can configure 61 | # NOTE: Please make sure to change your handler code to work with those events 62 | # Check the event documentation for details 63 | events: 64 | - http: 65 | path: / 66 | method: get 67 | # - s3: ${env:BUCKET} 68 | # - schedule: rate(10 minutes) 69 | # - sns: greeter-topic 70 | # - stream: arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000 71 | # - alexaSkill 72 | # - iot: 73 | # sql: "SELECT * FROM 'some_topic'" 74 | 75 | # Define function environment variables here 76 | # environment: 77 | # variable2: value2 78 | 79 | # you can add CloudFormation resource templates here 80 | #resources: 81 | # Resources: 82 | # NewResource: 83 | # Type: AWS::S3::Bucket 84 | # Properties: 85 | # BucketName: my-new-bucket 86 | # Outputs: 87 | # NewOutput: 88 | # Description: "Description for the output" 89 | # Value: "Some output value" 90 | --------------------------------------------------------------------------------