1- using System ;
2- using System . Collections . Generic ;
1+ using System ;
32using System . Diagnostics ;
4- using System . IO ;
5- using System . Linq ;
63using System . Threading . Tasks ;
74
85using Amazon . Lambda . Core ;
9- using Amazon . Lambda . S3Events ;
106using Amazon . S3 ;
11- using Amazon . S3 . Util ;
127
138// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
149[ assembly: LambdaSerializer ( typeof ( Amazon . Lambda . Serialization . Json . JsonSerializer ) ) ]
@@ -41,35 +36,27 @@ public static string Bash(this string cmd)
4136
4237 public class Function
4338 {
44- IAmazonS3 S3Client { get ; set ; }
39+ IAmazonS3 S3Client { get ; }
4540
4641 /// <summary>
4742 /// Default constructor. This constructor is used by Lambda to construct the instance. When invoked in a Lambda environment
4843 /// the AWS credentials will come from the IAM role associated with the function and the AWS region will be set to the
4944 /// region the Lambda function is executed in.
5045 /// </summary>
51- public Function ( )
52- {
53- S3Client = new AmazonS3Client ( ) ;
54- }
46+ public Function ( ) => S3Client = new AmazonS3Client ( ) ;
5547
5648 /// <summary>
5749 /// Constructs an instance with a preconfigured S3 client. This can be used for testing the outside of the Lambda environment.
5850 /// </summary>
5951 /// <param name="s3Client"></param>
60- public Function ( IAmazonS3 s3Client )
61- {
62- this . S3Client = s3Client ;
63- }
64-
52+ public Function ( IAmazonS3 s3Client ) => S3Client = s3Client ;
53+
6554 /// <summary>
66- /// This method is called for every Lambda invocation. This method takes in an S3 event object and can be used
67- /// to respond to S3 notifications.
55+ /// Lambda function to dump the container directories /var/lang
56+ /// and /var/runtime and upload the resulting archive to S3
6857 /// </summary>
69- /// <param name="evnt"></param>
70- /// <param name="context"></param>
7158 /// <returns></returns>
72- public async Task < string > FunctionHandler ( Stream stream )
59+ public async Task < string > FunctionHandler ( )
7360 {
7461 var environment = Environment . GetEnvironmentVariables ( ) ;
7562 foreach ( var env in environment . Keys ) {
@@ -79,7 +66,7 @@ public async Task<string> FunctionHandler(Stream stream)
7966 string filename = "dotnet2.tgz" ;
8067 string cmd = $ "tar -cpzf /tmp/{ filename } --numeric-owner --ignore-failed-read /var/runtime /var/lang";
8168
82- var output = cmd . Bash ( ) ;
69+ cmd . Bash ( ) ;
8370
8471 Console . WriteLine ( "Zipping done! Uploading..." ) ;
8572 await S3Client . PutObjectAsync ( new Amazon . S3 . Model . PutObjectRequest {
0 commit comments