├── .gitattributes ├── .gitignore ├── AppServices ├── Caching │ └── ElastiCache.Demo │ │ ├── ElastiCache.Demo.sln │ │ └── ElastiCache.Demo │ │ ├── App.config │ │ ├── ElastiCache.Demo.csproj │ │ ├── Lib │ │ ├── Amazon.ElastiCacheCluster.XML │ │ ├── Amazon.ElastiCacheCluster.dll │ │ ├── Enyim.Caching.dll │ │ ├── Enyim.Caching.xml │ │ ├── License.txt │ │ ├── Notice.txt │ │ └── README.md │ │ ├── Program.cs │ │ └── Properties │ │ └── AssemblyInfo.cs └── SES │ ├── SESSender.sln │ └── SESSender │ ├── App.config │ ├── Program.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── SESSender.csproj │ └── packages.config ├── Compute ├── ElasticBeanstalk │ └── WebApiForElasticBeanstalk │ │ ├── WebApiForElasticBeanstalk.sln │ │ └── WebApiForElasticBeanstalk │ │ ├── Controllers │ │ └── ValuesController.cs │ │ ├── Program.cs │ │ ├── Startup.cs │ │ ├── WebApiForElasticBeanstalk.csproj │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ └── aws-beanstalk-tools-defaults.json ├── Lambda.ApiGateway.DemoApp │ ├── Lambda.ApiGateway.DemoApp.sln │ └── Lambda.ApiGateway.DemoApp │ │ ├── Function.cs │ │ ├── Lambda.ApiGateway.DemoApp.csproj │ │ ├── Readme.md │ │ ├── TimeProcessor.cs │ │ └── aws-lambda-tools-defaults.json ├── Lambda.SQS.DemoApp │ ├── Lambda.SQS.DemoApp.Tests │ │ ├── FunctionTest.cs │ │ └── Lambda.SQS.DemoApp.Tests.csproj │ ├── Lambda.SQS.DemoApp.sln │ ├── Lambda.SQS.DemoApp │ │ ├── Function.cs │ │ ├── Lambda.SQS.DemoApp.csproj │ │ ├── Readme.md │ │ └── aws-lambda-tools-defaults.json │ └── SQSPublisher │ │ ├── App.config │ │ ├── Program.cs │ │ └── SQSPublisher.csproj ├── SWF │ ├── Decider │ │ ├── App.config │ │ ├── Program.cs │ │ ├── SwfDecider.csproj │ │ ├── assemblyinfo.cs │ │ └── packages.config │ ├── Initiator │ │ ├── App.config │ │ ├── Program.cs │ │ ├── SwfInitiator.csproj │ │ ├── assemblyinfo.cs │ │ └── packages.config │ ├── Worker │ │ ├── App.config │ │ ├── Program.cs │ │ ├── SwfWorker.csproj │ │ ├── assemblyinfo.cs │ │ └── packages.config │ └── swf.sln ├── ServerlessFrameworkLambda │ ├── .gitignore │ ├── Handler.cs │ ├── TimeProcessor.cs │ ├── aws-csharp.csproj │ ├── build.cmd │ ├── build.sh │ └── serverless.yml └── SimpleStepFunction │ ├── InvokeStatemachine │ ├── InvokeStatemachine.csproj │ └── Program.cs │ ├── MoreRealWorldStepFunction │ ├── MoreRealWorldStepFunction.csproj │ ├── Readme.md │ ├── State.cs │ ├── StepFunctionTasks.cs │ ├── aws-lambda-tools-defaults.json │ ├── serverless.template │ └── state-machine.json │ ├── SimpleStepFunction.Tests │ ├── FunctionTest.cs │ └── SimpleStepFunction.Tests.csproj │ ├── SimpleStepFunction.sln │ └── SimpleStepFunction │ ├── Readme.md │ ├── SimpleStepFunction.csproj │ ├── State.cs │ ├── StepFunctionTasks.cs │ ├── aws-lambda-tools-defaults.json │ ├── serverless.template │ └── state-machine.json ├── Databases └── DynamoDB │ ├── DynamoDBDataModel.sln │ └── DynamoDBDataModel │ ├── App.config │ ├── DataModelSample.cs │ ├── DataModelSchema.cs │ ├── DynamoDBDataModel.csproj │ ├── Program.cs │ └── TableOperations.cs ├── Messaging ├── Kinesis │ ├── AWS_Kinesis.sln │ ├── DataStreamAPI │ │ ├── DataStreamConsumer │ │ │ ├── App.config │ │ │ ├── ConsumerApp.cs │ │ │ └── DataStreamConsumer.csproj │ │ └── DataStreamProducer │ │ │ ├── App.config │ │ │ ├── DataStreamProducer.csproj │ │ │ └── DataStreamProducerApp.cs │ └── KCL │ │ ├── Bootstrap │ │ ├── Bootstrap.cs │ │ ├── Bootstrap.csproj │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── ClientLibrary │ │ ├── ClientLibrary.cs │ │ ├── ClientLibrary.csproj │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── packages.config │ │ ├── SampleConsumer │ │ ├── SampleConsumer.cs │ │ ├── SampleConsumer.csproj │ │ ├── jars │ │ │ ├── amazon-kinesis-client-1.9.0.jar │ │ │ ├── aws-java-sdk-cloudwatch-1.11.273.jar │ │ │ ├── aws-java-sdk-core-1.11.273.jar │ │ │ ├── aws-java-sdk-dynamodb-1.11.273.jar │ │ │ ├── aws-java-sdk-kinesis-1.11.273.jar │ │ │ ├── aws-java-sdk-kms-1.11.273.jar │ │ │ ├── aws-java-sdk-s3-1.11.273.jar │ │ │ ├── commons-codec-1.9.jar │ │ │ ├── commons-lang-2.6.jar │ │ │ ├── commons-logging-1.1.3.jar │ │ │ ├── guava-18.0.jar │ │ │ ├── httpclient-4.5.2.jar │ │ │ ├── httpcore-4.4.4.jar │ │ │ ├── jackson-annotations-2.6.0.jar │ │ │ ├── jackson-core-2.6.6.jar │ │ │ ├── jackson-databind-2.6.6.jar │ │ │ ├── jackson-dataformat-cbor-2.6.6.jar │ │ │ ├── joda-time-2.8.1.jar │ │ │ └── protobuf-java-2.6.1.jar │ │ └── kcl.properties │ │ └── SampleProducer │ │ ├── SampleProducer.cs │ │ └── SampleProducer.csproj └── SQSSinglePublisherManyReceivers │ ├── SQSSinglePublisherManyReceivers.sln │ └── SQSSinglePublisherManyReceivers │ ├── App.config │ ├── Program.cs │ └── SQSSinglePublisherManyReceivers.csproj ├── README.md └── Storage ├── GlacierStorage ├── GlacierStorage.sln └── GlacierStorage │ ├── App.config │ ├── GlacierStorage.csproj │ └── Program.cs ├── S3BucketsAndKeys ├── S3BucketsAndKeys.sln └── S3BucketsAndKeys │ ├── App.config │ ├── Program.cs │ └── S3BucketsAndKeys.csproj ├── S3FileSystem ├── FileSystem.sln └── FileSystem │ ├── App.config │ ├── FileSystem.csproj │ └── Program.cs └── S3TrasferUtility ├── S3TrasferUtility.sln └── S3TrasferUtility ├── App.config ├── Program.cs └── S3TrasferUtility.csproj /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /AppServices/Caching/ElastiCache.Demo/ElastiCache.Demo.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ElastiCache.Demo", "ElastiCache.Demo\ElastiCache.Demo.csproj", "{9742279C-F626-4D91-9FAB-132001CCF4ED}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {9742279C-F626-4D91-9FAB-132001CCF4ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {9742279C-F626-4D91-9FAB-132001CCF4ED}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {9742279C-F626-4D91-9FAB-132001CCF4ED}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {9742279C-F626-4D91-9FAB-132001CCF4ED}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {DAB89047-1747-456E-A690-18E2D38E965E} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /AppServices/Caching/ElastiCache.Demo/ElastiCache.Demo/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 |
7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /AppServices/Caching/ElastiCache.Demo/ElastiCache.Demo/ElastiCache.Demo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {9742279C-F626-4D91-9FAB-132001CCF4ED} 8 | Exe 9 | ElastiCache.Demo 10 | ElastiCache.Demo 11 | v4.6.2 12 | 512 13 | true 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | Lib\Amazon.ElastiCacheCluster.dll 37 | 38 | 39 | False 40 | Lib\Enyim.Caching.dll 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | Designer 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /AppServices/Caching/ElastiCache.Demo/ElastiCache.Demo/Lib/Amazon.ElastiCacheCluster.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/AppServices/Caching/ElastiCache.Demo/ElastiCache.Demo/Lib/Amazon.ElastiCacheCluster.dll -------------------------------------------------------------------------------- /AppServices/Caching/ElastiCache.Demo/ElastiCache.Demo/Lib/Enyim.Caching.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/AppServices/Caching/ElastiCache.Demo/ElastiCache.Demo/Lib/Enyim.Caching.dll -------------------------------------------------------------------------------- /AppServices/Caching/ElastiCache.Demo/ElastiCache.Demo/Lib/License.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/AppServices/Caching/ElastiCache.Demo/ElastiCache.Demo/Lib/License.txt -------------------------------------------------------------------------------- /AppServices/Caching/ElastiCache.Demo/ElastiCache.Demo/Lib/README.md: -------------------------------------------------------------------------------- 1 | # Amazon ElastiCache Cluster Configuration for .NET 2 | 3 | Amazon ElastiCache Cluster Configuration is an enhanced .NET library that supports connecting to an Amazon ElastiCache cluster for Auto Discovery. This client library is an extension built upon Enyim and is released under the [Apache 2.0 License](http://aws.amazon.com/apache2.0/). 4 | 5 | ## Usage 6 | 7 | To use Amazon ElastiCache with Auto Discovery, the ElastiCacheClusterConfig object must be passed to the MemcachedClient object. An ElastiCacheClusterConfig can be created from the App.config if there is a clusterclient section or you can pass a different section. 8 | 9 | var client = new MemcachedClient(new ElastiCacheClusterConfig()); 10 | 11 | ElastiCacheClusterConfig can also be instantiated by providing it an AutoConfigSetup or simply provide the hostname and port like so: 12 | 13 | var client = new MemcachedClient(new ElastiCacheClusterConfig("hostname", 11211)); 14 | 15 | Once instantiation occurs in this way, MemcachedClient can be used the same way as the [Enyim Client](https://github.com/enyim/EnyimMemcached). The only difference is a background process polls the cluster and updates nodes when changes occur. 16 | 17 | ## App.config 18 | The ElastiCacheClusterConfig object can be configured from an application's App.config file. Here is a sample App.config that configures the Amazon ElastiCache configuration URL and the polling interval at which the client will check for changes to the cluster. 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | The rest of the app.config configuration items for Enyim can be found [here](https://github.com/enyim/EnyimMemcached/wiki/MemcachedClient-Configuration#appconfig). 34 | 35 | ## Enyim Client 36 | Because this binary is used as a configuration object for the Enyim MemcachedClient, usage beyond instantiation is all exactly the same so refer to [this wiki](https://github.com/enyim/EnyimMemcached/wiki) or [this google group](https://groups.google.com/forum/#!forum/enyim-memcached) on how to use the actual client. 37 | 38 | ## Requirements 39 | 40 | You'll need .NET Framework 3.5 or later to use the precompiled binaries. To build the client, you'll need Visual Studio 2010 or higher. 41 | -------------------------------------------------------------------------------- /AppServices/Caching/ElastiCache.Demo/ElastiCache.Demo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Amazon.ElastiCacheCluster; 7 | using Enyim.Caching; 8 | using Enyim.Caching.Configuration; 9 | using Enyim.Caching.Memcached; 10 | 11 | namespace ElastiCache.Demo 12 | { 13 | class Program 14 | { 15 | static void Main(string[] args) 16 | { 17 | // instantiate a new client. 18 | ElastiCacheClusterConfig config = new ElastiCacheClusterConfig(); 19 | MemcachedClient memClient = new MemcachedClient(config); 20 | 21 | // Store the data for 3600 seconds (1hour) in the cluster. 22 | // The client will decide which cache host will store this item. 23 | memClient.Store(StoreMode.Set,"mykey","This is the data value.", TimeSpan.FromMinutes(10)); 24 | 25 | var mykey = memClient.Get("mykey"); 26 | 27 | 28 | 29 | 30 | Console.ReadLine(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /AppServices/Caching/ElastiCache.Demo/ElastiCache.Demo/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ElastiCache.Demo")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ElastiCache.Demo")] 13 | [assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("9742279c-f626-4d91-9fab-132001ccf4ed")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /AppServices/SES/SESSender.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SESSender", "SESSender\SESSender.csproj", "{BE715401-E848-42FB-B346-8A912C035E41}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {BE715401-E848-42FB-B346-8A912C035E41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {BE715401-E848-42FB-B346-8A912C035E41}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {BE715401-E848-42FB-B346-8A912C035E41}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {BE715401-E848-42FB-B346-8A912C035E41}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {D78AD39D-119E-49FC-BBAD-C69E588258E3} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /AppServices/SES/SESSender/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /AppServices/SES/SESSender/Program.cs: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2009-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may 5 | * not use this file except in compliance with the License. A copy of the 6 | * License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0/ 9 | * 10 | * or in the "license" file accompanying this file. This file is 11 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 12 | * KIND, either express or implied. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | *******************************************************************************/ 15 | 16 | using Amazon; 17 | using System; 18 | using System.Collections.Generic; 19 | using System.Configuration; 20 | using Amazon.SimpleEmail; 21 | using Amazon.SimpleEmail.Model; 22 | using Amazon.Runtime; 23 | 24 | namespace SESSender 25 | { 26 | class Program 27 | { 28 | // Change the AWSProfileName to the profile you want to use in the App.config file. 29 | // See http://aws.amazon.com/credentials for more details. 30 | // You must also sign up for an Amazon SES account for this to work 31 | // See http://aws.amazon.com/ses/ for details on creating an Amazon SES account 32 | // This sample send a mail using SES. 33 | // Change the senderAddress and receiverAddress fields to values that match your senderAddress and receiverAddress 34 | 35 | // Set the sender's email address here. 36 | static readonly string senderAddress = "sacha.barber@gmail.com"; 37 | 38 | // Set the receiver's email address here. 39 | static readonly string receiverAddress = "sacha.barber@gmail.com"; 40 | 41 | static void Main(string[] args) 42 | { 43 | if (CheckRequiredFields()) 44 | { 45 | 46 | using (var client = new AmazonSimpleEmailServiceClient(RegionEndpoint.EUWest1)) 47 | { 48 | var sendRequest = new SendEmailRequest 49 | { 50 | Source = senderAddress, 51 | Destination = new Destination { ToAddresses = new List { receiverAddress } }, 52 | Message = new Message 53 | { 54 | Subject = new Content("Sample Mail using SES"), 55 | Body = new Body { Text = new Content("Sample message content.") } 56 | } 57 | }; 58 | try 59 | { 60 | Console.WriteLine("Sending email using AWS SES..."); 61 | var response = client.SendEmail(sendRequest); 62 | Console.WriteLine("The email was sent successfully."); 63 | } 64 | catch (Exception ex) 65 | { 66 | Console.WriteLine("The email was not sent."); 67 | Console.WriteLine("Error message: " + ex.Message); 68 | 69 | } 70 | } 71 | } 72 | 73 | Console.Write("Press any key to continue..."); 74 | Console.ReadKey(); 75 | } 76 | 77 | static bool CheckRequiredFields() 78 | { 79 | var appConfig = ConfigurationManager.AppSettings; 80 | 81 | if (string.IsNullOrEmpty(appConfig["AWSProfileName"])) 82 | { 83 | Console.WriteLine("AWSProfileName was not set in the App.config file."); 84 | return false; 85 | } 86 | if (string.IsNullOrEmpty(senderAddress)) 87 | { 88 | Console.WriteLine("The variable senderAddress is not set."); 89 | return false; 90 | } 91 | if (string.IsNullOrEmpty(receiverAddress)) 92 | { 93 | Console.WriteLine("The variable receiverAddress is not set."); 94 | return false; 95 | } 96 | return true; 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /AppServices/SES/SESSender/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SESSender")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SESSender")] 13 | [assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("be715401-e848-42fb-b346-8a912c035e41")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /AppServices/SES/SESSender/SESSender.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {BE715401-E848-42FB-B346-8A912C035E41} 8 | Exe 9 | SESSender 10 | SESSender 11 | v4.6.2 12 | 512 13 | true 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | ..\packages\AWSSDK.Core.3.3.29.3\lib\net45\AWSSDK.Core.dll 37 | 38 | 39 | ..\packages\AWSSDK.SimpleEmail.3.3.7.5\lib\net45\AWSSDK.SimpleEmail.dll 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /AppServices/SES/SESSender/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Compute/ElasticBeanstalk/WebApiForElasticBeanstalk/WebApiForElasticBeanstalk.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApiForElasticBeanstalk", "WebApiForElasticBeanstalk\WebApiForElasticBeanstalk.csproj", "{4D5BD347-7D2F-43D7-8E0F-72898DB2820A}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {4D5BD347-7D2F-43D7-8E0F-72898DB2820A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {4D5BD347-7D2F-43D7-8E0F-72898DB2820A}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {4D5BD347-7D2F-43D7-8E0F-72898DB2820A}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {4D5BD347-7D2F-43D7-8E0F-72898DB2820A}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {F57D7E76-0961-43D0-8DE1-3A0B6E43F4F6} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Compute/ElasticBeanstalk/WebApiForElasticBeanstalk/WebApiForElasticBeanstalk/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | namespace WebApiForElasticBeanstalk.Controllers 8 | { 9 | [Route("api/[controller]")] 10 | [ApiController] 11 | public class ValuesController : ControllerBase 12 | { 13 | // GET api/values 14 | [HttpGet] 15 | public ActionResult> Get() 16 | { 17 | return new string[] { "value1", "value2" }; 18 | } 19 | 20 | // GET api/values/5 21 | [HttpGet("{id}")] 22 | public ActionResult Get(int id) 23 | { 24 | return "value"; 25 | } 26 | 27 | // POST api/values 28 | [HttpPost] 29 | public void Post([FromBody] string value) 30 | { 31 | } 32 | 33 | // PUT api/values/5 34 | [HttpPut("{id}")] 35 | public void Put(int id, [FromBody] string value) 36 | { 37 | } 38 | 39 | // DELETE api/values/5 40 | [HttpDelete("{id}")] 41 | public void Delete(int id) 42 | { 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Compute/ElasticBeanstalk/WebApiForElasticBeanstalk/WebApiForElasticBeanstalk/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace WebApiForElasticBeanstalk 12 | { 13 | public class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | CreateWebHostBuilder(args).Build().Run(); 18 | } 19 | 20 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 21 | WebHost.CreateDefaultBuilder(args) 22 | .UseStartup(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Compute/ElasticBeanstalk/WebApiForElasticBeanstalk/WebApiForElasticBeanstalk/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.HttpsPolicy; 8 | using Microsoft.AspNetCore.Mvc; 9 | using Microsoft.Extensions.Configuration; 10 | using Microsoft.Extensions.DependencyInjection; 11 | using Microsoft.Extensions.Logging; 12 | using Microsoft.Extensions.Options; 13 | 14 | namespace WebApiForElasticBeanstalk 15 | { 16 | public class Startup 17 | { 18 | public Startup(IConfiguration configuration) 19 | { 20 | Configuration = configuration; 21 | } 22 | 23 | public IConfiguration Configuration { get; } 24 | 25 | // This method gets called by the runtime. Use this method to add services to the container. 26 | public void ConfigureServices(IServiceCollection services) 27 | { 28 | services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); 29 | } 30 | 31 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 32 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 33 | { 34 | if (env.IsDevelopment()) 35 | { 36 | app.UseDeveloperExceptionPage(); 37 | } 38 | else 39 | { 40 | app.UseHsts(); 41 | } 42 | 43 | app.UseHttpsRedirection(); 44 | app.UseMvc(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Compute/ElasticBeanstalk/WebApiForElasticBeanstalk/WebApiForElasticBeanstalk/WebApiForElasticBeanstalk.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Compute/ElasticBeanstalk/WebApiForElasticBeanstalk/WebApiForElasticBeanstalk/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Compute/ElasticBeanstalk/WebApiForElasticBeanstalk/WebApiForElasticBeanstalk/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning" 5 | } 6 | }, 7 | "AllowedHosts": "*" 8 | } 9 | -------------------------------------------------------------------------------- /Compute/ElasticBeanstalk/WebApiForElasticBeanstalk/WebApiForElasticBeanstalk/aws-beanstalk-tools-defaults.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "comment" : "This file is used to help set default values when using the dotnet CLI extension Amazon.ElasticBeanstalk.Tools. For more information run \"dotnet eb --help\" from the project root.", 4 | "profile" : "default", 5 | "region" : "eu-west-2", 6 | "application" : "WebApiForElasticBeanstalk", 7 | "environment" : "WebApiForElasticBeanstalk-dev", 8 | "cname" : "webapiforelasticbeanstalk-dev", 9 | "solution-stack" : "64bit Windows Server 2016 v1.2.0 running IIS 10.0", 10 | "environment-type" : "SingleInstance", 11 | "instance-profile" : "aws-elasticbeanstalk-ec2-role", 12 | "service-role" : "aws-elasticbeanstalk-service-role", 13 | "health-check-url" : "/", 14 | "instance-type" : "t2.micro", 15 | "key-pair" : "", 16 | "iis-website" : "Default Web Site", 17 | "app-path" : "/", 18 | "enable-xray" : false 19 | } -------------------------------------------------------------------------------- /Compute/Lambda.ApiGateway.DemoApp/Lambda.ApiGateway.DemoApp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lambda.ApiGateway.DemoApp", "Lambda.ApiGateway.DemoApp\Lambda.ApiGateway.DemoApp.csproj", "{D65030A1-38EC-42B8-B997-EF4B506042D6}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {D65030A1-38EC-42B8-B997-EF4B506042D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {D65030A1-38EC-42B8-B997-EF4B506042D6}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {D65030A1-38EC-42B8-B997-EF4B506042D6}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {D65030A1-38EC-42B8-B997-EF4B506042D6}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {27B62A55-C457-467A-8414-A749E689AEC5} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Compute/Lambda.ApiGateway.DemoApp/Lambda.ApiGateway.DemoApp/Function.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Net; 4 | using Amazon.Lambda.APIGatewayEvents; 5 | using Amazon.Lambda.Core; 6 | using Newtonsoft.Json; 7 | 8 | // Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class. 9 | [assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))] 10 | 11 | namespace Lambda.ApiGateway.DemoApp 12 | { 13 | public class Function 14 | { 15 | 16 | ITimeProcessor processor = new TimeProcessor(); 17 | 18 | /// 19 | /// Default constructor. This constructor is used by Lambda to construct 20 | /// the instance. When invoked in a Lambda environment 21 | /// the AWS credentials will come from the IAM role associated with the 22 | /// function and the AWS region will be set to the 23 | /// region the Lambda function is executed in. 24 | /// 25 | public Function() 26 | { 27 | 28 | } 29 | 30 | public APIGatewayProxyResponse FunctionHandler( 31 | APIGatewayProxyRequest apigProxyEvent, ILambdaContext context) 32 | { 33 | LogMessage(context, "Processing request started"); 34 | APIGatewayProxyResponse response; 35 | try 36 | { 37 | var result = processor.CurrentTimeUTC(); 38 | response = CreateResponse(result); 39 | 40 | LogMessage(context, "Processing request succeeded."); 41 | } 42 | catch (Exception ex) 43 | { 44 | LogMessage(context, 45 | string.Format("Processing request failed - {0}", ex.Message)); 46 | response = CreateResponse(null); 47 | } 48 | 49 | return response; 50 | } 51 | 52 | APIGatewayProxyResponse CreateResponse(DateTime? result) 53 | { 54 | int statusCode = (result != null) ? 55 | (int)HttpStatusCode.OK : 56 | (int)HttpStatusCode.InternalServerError; 57 | 58 | string body = (result != null) ? 59 | JsonConvert.SerializeObject(result) : string.Empty; 60 | 61 | var response = new APIGatewayProxyResponse 62 | { 63 | StatusCode = statusCode, 64 | Body = body, 65 | Headers = new Dictionary 66 | { 67 | { "Content-Type", "application/json" }, 68 | { "Access-Control-Allow-Origin", "*" } 69 | } 70 | }; 71 | return response; 72 | } 73 | 74 | /// 75 | /// Logs messages to cloud watch 76 | /// 77 | void LogMessage(ILambdaContext ctx, string msg) 78 | { 79 | ctx.Logger.LogLine( 80 | string.Format("{0}:{1} - {2}", 81 | ctx.AwsRequestId, 82 | ctx.FunctionName, 83 | msg)); 84 | } 85 | 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Compute/Lambda.ApiGateway.DemoApp/Lambda.ApiGateway.DemoApp/Lambda.ApiGateway.DemoApp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | true 6 | Lambda 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Compute/Lambda.ApiGateway.DemoApp/Lambda.ApiGateway.DemoApp/Readme.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | AWS Lambda With API Gateway /GET, which is routed to this Lambda function 4 | 5 | You can read more about The APIGateway Lambda library [here](https://github.com/aws/aws-lambda-dotnet/tree/master/Libraries/src/Amazon.Lambda.APIGatewayEvents) 6 | 7 | -------------------------------------------------------------------------------- /Compute/Lambda.ApiGateway.DemoApp/Lambda.ApiGateway.DemoApp/TimeProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Lambda.ApiGateway.DemoApp 6 | { 7 | public interface ITimeProcessor 8 | { 9 | DateTime CurrentTimeUTC(); 10 | } 11 | 12 | public class TimeProcessor : ITimeProcessor 13 | { 14 | public DateTime CurrentTimeUTC() 15 | { 16 | return DateTime.UtcNow; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Compute/Lambda.ApiGateway.DemoApp/Lambda.ApiGateway.DemoApp/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "Information" : [ 4 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 5 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 6 | "dotnet lambda help", 7 | "All the command line options for the Lambda command can be specified in this file." 8 | ], 9 | "profile" : "default", 10 | "region" : "eu-west-2", 11 | "configuration" : "Release", 12 | "framework" : "netcoreapp2.1", 13 | "function-runtime" : "dotnetcore2.1", 14 | "function-memory-size" : 256, 15 | "function-timeout" : 30, 16 | "function-handler" : "Lambda.ApiGateway.DemoApp::Lambda.ApiGateway.DemoApp.Function::FunctionHandler", 17 | "function-name" : "ApiGatewayDemoApp", 18 | "function-role" : "arn:aws:iam::464534050515:role/lambda_exec_ApiGatewayDemoApp", 19 | "tracing-mode" : "PassThrough", 20 | "environment-variables" : "" 21 | } -------------------------------------------------------------------------------- /Compute/Lambda.SQS.DemoApp/Lambda.SQS.DemoApp.Tests/FunctionTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | using Xunit; 7 | using Amazon.Lambda.TestUtilities; 8 | using Amazon.Lambda.SQSEvents; 9 | 10 | using Lambda.SQS.DemoApp; 11 | using Amazon.S3; 12 | using Amazon.S3.Model; 13 | 14 | namespace Lambda.SQS.DemoApp.Tests 15 | { 16 | public class FunctionTest 17 | { 18 | private static string bucketName = "lamda-sqs-demo-app-out-bucket"; 19 | 20 | 21 | [Fact] 22 | public async Task TestSQSEventLambdaFunction() 23 | { 24 | var sqsEvent = new SQSEvent 25 | { 26 | Records = new List 27 | { 28 | new SQSEvent.SQSMessage 29 | { 30 | Body = "foobar" 31 | } 32 | } 33 | }; 34 | 35 | var logger = new TestLambdaLogger(); 36 | var context = new TestLambdaContext 37 | { 38 | Logger = logger 39 | }; 40 | 41 | var countBefore = await CountOfItemsInBucketAsync(bucketName); 42 | 43 | var function = new Function(); 44 | await function.FunctionHandler(sqsEvent, context); 45 | 46 | var countAfter = await CountOfItemsInBucketAsync(bucketName); 47 | 48 | Assert.Contains("Processed message foobar", logger.Buffer.ToString()); 49 | 50 | Assert.Equal(1, countAfter - countBefore); 51 | } 52 | 53 | 54 | private async Task CountOfItemsInBucketAsync(string bucketName) 55 | { 56 | using (var client = new AmazonS3Client(Amazon.RegionEndpoint.EUWest2)) 57 | { 58 | ListObjectsRequest request = new ListObjectsRequest(); 59 | request.BucketName = bucketName; 60 | ListObjectsResponse response = await client.ListObjectsAsync(request); 61 | return response.S3Objects.Count; 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Compute/Lambda.SQS.DemoApp/Lambda.SQS.DemoApp.Tests/Lambda.SQS.DemoApp.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Compute/Lambda.SQS.DemoApp/Lambda.SQS.DemoApp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lambda.SQS.DemoApp", "Lambda.SQS.DemoApp\Lambda.SQS.DemoApp.csproj", "{F981EC01-05CD-43F9-A39E-7810D1F19814}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lambda.SQS.DemoApp.Tests", "Lambda.SQS.DemoApp.Tests\Lambda.SQS.DemoApp.Tests.csproj", "{B00BC177-CB59-4685-B117-C11159F05562}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SQSPublisher", "SQSPublisher\SQSPublisher.csproj", "{27A3BF49-56A2-418F-8AAE-49AC64F9642A}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {F981EC01-05CD-43F9-A39E-7810D1F19814}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {F981EC01-05CD-43F9-A39E-7810D1F19814}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {F981EC01-05CD-43F9-A39E-7810D1F19814}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {F981EC01-05CD-43F9-A39E-7810D1F19814}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {B00BC177-CB59-4685-B117-C11159F05562}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {B00BC177-CB59-4685-B117-C11159F05562}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {B00BC177-CB59-4685-B117-C11159F05562}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {B00BC177-CB59-4685-B117-C11159F05562}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {27A3BF49-56A2-418F-8AAE-49AC64F9642A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {27A3BF49-56A2-418F-8AAE-49AC64F9642A}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {27A3BF49-56A2-418F-8AAE-49AC64F9642A}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {27A3BF49-56A2-418F-8AAE-49AC64F9642A}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {6CFCF4A1-C084-4BEF-98CD-9AD2424ACB3A} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /Compute/Lambda.SQS.DemoApp/Lambda.SQS.DemoApp/Function.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | using Amazon.Lambda.Core; 5 | using Amazon.Lambda.SQSEvents; 6 | using Amazon.S3; 7 | using Amazon.S3.Model; 8 | 9 | 10 | // Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class. 11 | [assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))] 12 | 13 | namespace Lambda.SQS.DemoApp 14 | { 15 | public class Function 16 | { 17 | static IAmazonS3 client; 18 | private static string bucketName = "lamda-sqs-demo-app-out-bucket"; 19 | 20 | /// 21 | /// Default constructor. This constructor is used by Lambda to construct the instance. When invoked in a Lambda environment 22 | /// the AWS credentials will come from the IAM role associated with the function and the AWS region will be set to the 23 | /// region the Lambda function is executed in. 24 | /// 25 | public Function() 26 | { 27 | 28 | } 29 | 30 | 31 | /// 32 | /// This method is called for every Lambda invocation. This method takes in an SQS event object and can be used 33 | /// to respond to SQS messages. 34 | /// 35 | /// 36 | /// 37 | /// 38 | public async Task FunctionHandler(SQSEvent evnt, ILambdaContext context) 39 | { 40 | foreach(var message in evnt.Records) 41 | { 42 | await ProcessMessageAsync(message, context); 43 | } 44 | } 45 | 46 | private async Task ProcessMessageAsync(SQSEvent.SQSMessage message, ILambdaContext context) 47 | { 48 | context.Logger.LogLine($"Processed message {message.Body}"); 49 | 50 | using (client = new AmazonS3Client(Amazon.RegionEndpoint.EUWest2)) 51 | { 52 | Console.WriteLine("Creating a bucket"); 53 | await CreateABucketAsync(bucketName, false); 54 | Console.WriteLine("Writing message from SQS to bucket"); 55 | await WritingAnObjectAsync(message.Body.ToUpper(), Guid.NewGuid().ToString("N").ToLower()); 56 | } 57 | 58 | 59 | // TODO: Do interesting work based on the new message 60 | await Task.CompletedTask; 61 | } 62 | 63 | 64 | async Task WritingAnObjectAsync(string messageBody, string keyName) 65 | { 66 | await CarryOutAWSTask(async () => 67 | { 68 | // simple object put 69 | PutObjectRequest request = new PutObjectRequest() 70 | { 71 | ContentBody = messageBody, 72 | BucketName = bucketName, 73 | Key = keyName 74 | }; 75 | 76 | PutObjectResponse response = await client.PutObjectAsync(request); 77 | return Unit.Empty; 78 | }, "Writing object"); 79 | } 80 | 81 | 82 | async Task CreateABucketAsync(string bucketToCreate, bool isPublic = true) 83 | { 84 | await CarryOutAWSTask(async () => 85 | { 86 | if(await BucketExists(bucketToCreate)) 87 | { 88 | Console.WriteLine($"{bucketToCreate} already exists, skipping this step"); 89 | } 90 | 91 | PutBucketRequest putBucketRequest = new PutBucketRequest() 92 | { 93 | BucketName = bucketToCreate, 94 | BucketRegion = S3Region.EUW2, 95 | CannedACL = isPublic ? S3CannedACL.PublicRead : S3CannedACL.Private 96 | }; 97 | var response = await client.PutBucketAsync(putBucketRequest); 98 | return Unit.Empty; 99 | }, "Create a bucket"); 100 | } 101 | 102 | 103 | async Task BucketExists(string bucketName) 104 | { 105 | return await CarryOutAWSTask(async () => 106 | { 107 | ListBucketsResponse response = await client.ListBucketsAsync(); 108 | return response.Buckets.Select(x => x.BucketName).Contains(bucketName); 109 | }, "Listing buckets"); 110 | } 111 | 112 | async Task CarryOutAWSTask(Func> taskToPerform, string op) 113 | { 114 | try 115 | { 116 | return await taskToPerform(); 117 | } 118 | catch (AmazonS3Exception amazonS3Exception) 119 | { 120 | if (amazonS3Exception.ErrorCode != null && 121 | (amazonS3Exception.ErrorCode.Equals("InvalidAccessKeyId") || 122 | amazonS3Exception.ErrorCode.Equals("InvalidSecurity"))) 123 | { 124 | Console.WriteLine("Please check the provided AWS Credentials."); 125 | Console.WriteLine("If you haven't signed up for Amazon S3, please visit http://aws.amazon.com/s3"); 126 | } 127 | else 128 | { 129 | Console.WriteLine($"An Error, number '{amazonS3Exception.ErrorCode}', " + 130 | $"occurred when '{op}' with the message '{amazonS3Exception.Message}'"); 131 | } 132 | 133 | return default(T); 134 | } 135 | } 136 | 137 | 138 | } 139 | 140 | 141 | 142 | public class Unit 143 | { 144 | public static Unit Empty => new Unit(); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /Compute/Lambda.SQS.DemoApp/Lambda.SQS.DemoApp/Lambda.SQS.DemoApp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | true 6 | Lambda 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Compute/Lambda.SQS.DemoApp/Lambda.SQS.DemoApp/Readme.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Simple SQS Function Project 2 | 3 | This starter project consists of: 4 | * Function.cs - class file containing a class with a single function handler method 5 | * aws-lambda-tools-defaults.json - default argument settings for use with Visual Studio and command line deployment tools for AWS 6 | 7 | You may also have a test project depending on the options selected. 8 | 9 | The generated function handler responds to events on an Amazon SQS queue. 10 | 11 | After deploying your function you must configure an Amazon SQS queue as an event source to trigger your Lambda function. 12 | 13 | ## Here are some steps to follow from Visual Studio: 14 | 15 | To deploy your function to AWS Lambda, right click the project in Solution Explorer and select *Publish to AWS Lambda*. 16 | 17 | To view your deployed function open its Function View window by double-clicking the function name shown beneath the AWS Lambda node in the AWS Explorer tree. 18 | 19 | To perform testing against your deployed function use the Test Invoke tab in the opened Function View window. 20 | 21 | To configure event sources for your deployed function use the Event Sources tab in the opened Function View window. 22 | 23 | To update the runtime configuration of your deployed function use the Configuration tab in the opened Function View window. 24 | 25 | To view execution logs of invocations of your function use the Logs tab in the opened Function View window. 26 | 27 | ## Here are some steps to follow to get started from the command line: 28 | 29 | Once you have edited your template and code you can deploy your application using the [Amazon.Lambda.Tools Global Tool](https://github.com/aws/aws-extensions-for-dotnet-cli#aws-lambda-amazonlambdatools) from the command line. 30 | 31 | Install Amazon.Lambda.Tools Global Tools if not already installed. 32 | ``` 33 | dotnet tool install -g Amazon.Lambda.Tools 34 | ``` 35 | 36 | If already installed check if new version is available. 37 | ``` 38 | dotnet tool update -g Amazon.Lambda.Tools 39 | ``` 40 | 41 | Execute unit tests 42 | ``` 43 | cd "Lambda.SQS.DemoApp/test/Lambda.SQS.DemoApp.Tests" 44 | dotnet test 45 | ``` 46 | 47 | Deploy function to AWS Lambda 48 | ``` 49 | cd "Lambda.SQS.DemoApp/src/Lambda.SQS.DemoApp" 50 | dotnet lambda deploy-function 51 | ``` 52 | -------------------------------------------------------------------------------- /Compute/Lambda.SQS.DemoApp/Lambda.SQS.DemoApp/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "Information" : [ 4 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 5 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 6 | "dotnet lambda help", 7 | "All the command line options for the Lambda command can be specified in this file." 8 | ], 9 | "profile" : "default", 10 | "region" : "eu-west-2", 11 | "configuration" : "Release", 12 | "framework" : "netcoreapp2.1", 13 | "function-runtime" : "dotnetcore2.1", 14 | "function-memory-size" : 256, 15 | "function-timeout" : 30, 16 | "function-handler" : "Lambda.SQS.DemoApp::Lambda.SQS.DemoApp.Function::FunctionHandler", 17 | "function-name" : "lambda-sqs-to-s3-bucket", 18 | "function-role" : "arn:aws:iam::464534050515:role/lambda_exec_lambda-sqs-to-s3-bucket", 19 | "tracing-mode" : "PassThrough", 20 | "environment-variables" : "" 21 | } -------------------------------------------------------------------------------- /Compute/Lambda.SQS.DemoApp/SQSPublisher/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Compute/Lambda.SQS.DemoApp/SQSPublisher/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Amazon.SQS; 3 | using Amazon.SQS.Model; 4 | using Nito.AsyncEx; 5 | 6 | namespace SQSSPublisher 7 | { 8 | class Program 9 | { 10 | private static bool _receieverShouldDeleteMessage = false; 11 | private static AmazonSQSClient _sqs = new AmazonSQSClient(); 12 | private static string _myQueueUrl; 13 | private static string _queueName = "lamda-sqs-demo-app"; 14 | 15 | static void Main(string[] args) 16 | { 17 | AsyncContext.Run(() => MainAsync(args)); 18 | } 19 | 20 | static async void MainAsync(string[] args) 21 | { 22 | try 23 | { 24 | 25 | var listQueuesRequest = new ListQueuesRequest(); 26 | var listQueuesResponse = await _sqs.ListQueuesAsync(listQueuesRequest); 27 | 28 | try 29 | { 30 | Console.WriteLine($"Checking for a queue called {_queueName}.\n"); 31 | var resp = await _sqs.GetQueueUrlAsync(_queueName); 32 | _myQueueUrl = resp.QueueUrl; 33 | 34 | } 35 | catch(QueueDoesNotExistException quex) 36 | { 37 | //Creating a queue 38 | Console.WriteLine($"Create a queue called {_queueName}.\n"); 39 | var sqsRequest = new CreateQueueRequest { QueueName = _queueName }; 40 | var createQueueResponse = await _sqs.CreateQueueAsync(sqsRequest); 41 | _myQueueUrl = createQueueResponse.QueueUrl; 42 | } 43 | 44 | //Sending a message 45 | for (int i = 0; i < 2; i++) 46 | { 47 | var message = $"This is my message text-Id-{Guid.NewGuid().ToString("N")}"; 48 | //var message = $"This is my message text"; 49 | Console.WriteLine($"Sending a message to MyQueue : {message}"); 50 | var sendMessageRequest = new SendMessageRequest 51 | { 52 | QueueUrl = _myQueueUrl, //URL from initial queue creation 53 | MessageBody = message 54 | }; 55 | await _sqs.SendMessageAsync(sendMessageRequest); 56 | } 57 | } 58 | catch (AmazonSQSException ex) 59 | { 60 | Console.WriteLine("Caught Exception: " + ex.Message); 61 | Console.WriteLine("Response Status Code: " + ex.StatusCode); 62 | Console.WriteLine("Error Code: " + ex.ErrorCode); 63 | Console.WriteLine("Error Type: " + ex.ErrorType); 64 | Console.WriteLine("Request ID: " + ex.RequestId); 65 | } 66 | 67 | Console.WriteLine("Press Enter to continue..."); 68 | Console.Read(); 69 | } 70 | 71 | 72 | 73 | } 74 | } -------------------------------------------------------------------------------- /Compute/Lambda.SQS.DemoApp/SQSPublisher/SQSPublisher.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net45 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Compute/SWF/Decider/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Compute/SWF/Decider/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading.Tasks; 4 | using Amazon; 5 | using Amazon.SimpleWorkflow; 6 | using Amazon.SimpleWorkflow.Model; 7 | 8 | namespace SwfDeciderDecider 9 | { 10 | class Program 11 | { 12 | static string domainName = "SwfDemoDomain"; 13 | static IAmazonSimpleWorkflow SwfDeciderClient = 14 | AWSClientFactory.CreateAmazonSimpleWorkflowClient(); 15 | 16 | public static void Main(string[] args) 17 | { 18 | Console.Title = "DECIDER"; 19 | // Start the Deciders, which defines the structure/flow of Workflow 20 | Task.Run(() => Decider()); 21 | Console.Read(); 22 | } 23 | 24 | 25 | // Simple logic 26 | // Creates four activities at the begining 27 | // Waits for them to complete and completes the workflow 28 | static void Decider() 29 | { 30 | int activityCount = 0; // This refers to total number of activities per workflow 31 | while (true) 32 | { 33 | Console.WriteLine("DECIDER: Polling for decision task ..."); 34 | var request = new PollForDecisionTaskRequest() 35 | { 36 | Domain = domainName, 37 | TaskList = new TaskList() { Name = "SwfDemo" } 38 | }; 39 | 40 | var response = SwfDeciderClient.PollForDecisionTask(request); 41 | if (response.DecisionTask.TaskToken == null) 42 | { 43 | Console.WriteLine("DECIDER: NULL"); 44 | continue; 45 | } 46 | 47 | int completedActivityTaskCount = 0, totalActivityTaskCount = 0; 48 | foreach (HistoryEvent e in response.DecisionTask.Events) 49 | { 50 | Console.WriteLine($"DECIDER: EventType - {e.EventType}" + 51 | $", EventId - {e.EventId}"); 52 | if (e.EventType == "ActivityTaskCompleted") 53 | completedActivityTaskCount++; 54 | if (e.EventType.Value.StartsWith("Activity")) 55 | totalActivityTaskCount++; 56 | } 57 | Console.WriteLine($"completedCount={completedActivityTaskCount}"); 58 | 59 | var decisions = new List(); 60 | if (totalActivityTaskCount == 0) // Create this only at the begining 61 | { 62 | ScheduleActivity("Activity1A", decisions); 63 | ScheduleActivity("Activity1B", decisions); 64 | ScheduleActivity("Activity2", decisions); 65 | ScheduleActivity("Activity2", decisions); 66 | activityCount = 4; 67 | } 68 | else if (completedActivityTaskCount == activityCount) 69 | { 70 | var decision = new Decision() 71 | { 72 | DecisionType = DecisionType.CompleteWorkflowExecution, 73 | CompleteWorkflowExecutionDecisionAttributes = 74 | new CompleteWorkflowExecutionDecisionAttributes 75 | { 76 | Result = "{\"Result\":\"WF Complete!\"}" 77 | } 78 | }; 79 | decisions.Add(decision); 80 | 81 | Console.WriteLine("DECIDER: WORKFLOW COMPLETE"); 82 | } 83 | var respondDecisionTaskCompletedRequest = 84 | new RespondDecisionTaskCompletedRequest() 85 | { 86 | Decisions = decisions, 87 | TaskToken = response.DecisionTask.TaskToken 88 | }; 89 | SwfDeciderClient.RespondDecisionTaskCompleted(respondDecisionTaskCompletedRequest); 90 | } 91 | } 92 | 93 | static void ScheduleActivity(string name, List decisions) 94 | { 95 | var decision = new Decision() 96 | { 97 | DecisionType = DecisionType.ScheduleActivityTask, 98 | ScheduleActivityTaskDecisionAttributes = 99 | new ScheduleActivityTaskDecisionAttributes() 100 | { 101 | ActivityType = new ActivityType() 102 | { 103 | Name = name, 104 | Version = "2.0" 105 | }, 106 | ActivityId = name + "-" + System.Guid.NewGuid().ToString(), 107 | Input = "{\"activityInput1\":\"value1\"}" 108 | } 109 | }; 110 | Console.WriteLine($"DECIDER: ActivityId={decision.ScheduleActivityTaskDecisionAttributes.ActivityId}"); 111 | decisions.Add(decision); 112 | } 113 | } 114 | } -------------------------------------------------------------------------------- /Compute/SWF/Decider/SwfDecider.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {FBD389B9-B6B1-4420-AEC2-D95BD09482B4} 9 | Exe 10 | Properties 11 | SwfDecider 12 | SwfDecider 13 | v4.5 14 | 512 15 | false 16 | 17 | 18 | 3.5 19 | 20 | publish\ 21 | true 22 | Disk 23 | false 24 | Foreground 25 | 7 26 | Days 27 | false 28 | false 29 | true 30 | 0 31 | 1.0.0.%2a 32 | false 33 | true 34 | 35 | 36 | 37 | true 38 | full 39 | false 40 | bin\Debug\ 41 | DEBUG;TRACE 42 | prompt 43 | 4 44 | 45 | 46 | AllRules.ruleset 47 | 48 | 49 | pdbonly 50 | true 51 | bin\Release\ 52 | TRACE 53 | prompt 54 | 4 55 | 56 | 57 | AllRules.ruleset 58 | 59 | 60 | SwfDeciderDecider.Program 61 | 62 | 63 | 70 | 71 | 72 | 73 | 74 | False 75 | True 76 | C:\Program Files (x86)\AWS SDK for .NET\bin\Net35\AWSSDK.dll 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | ..\packages\AWSSDK.2.3.55.2\lib\net45\AWSSDK.dll 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | False 102 | .NET Framework 3.5 SP1 Client Profile 103 | false 104 | 105 | 106 | False 107 | .NET Framework 2.0 %28x86%29 108 | true 109 | 110 | 111 | False 112 | .NET Framework 3.0 %28x86%29 113 | false 114 | 115 | 116 | False 117 | .NET Framework 3.5 118 | false 119 | 120 | 121 | False 122 | .NET Framework 3.5 SP1 123 | false 124 | 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /Compute/SWF/Decider/assemblyinfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SwfDecider")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SwfDecider")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | // [assembly: Guid("20b7ed34-3642-464a-a43f-65212cec0855")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Compute/SWF/Decider/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Compute/SWF/Initiator/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Compute/SWF/Initiator/SwfInitiator.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {2ECCA326-DA2E-4B3E-8152-459FF716B7FC} 9 | Exe 10 | Properties 11 | SwfInitiator 12 | SwfInitiator 13 | v4.5 14 | 512 15 | false 16 | 17 | 18 | 3.5 19 | 20 | publish\ 21 | true 22 | Disk 23 | false 24 | Foreground 25 | 7 26 | Days 27 | false 28 | false 29 | true 30 | 0 31 | 1.0.0.%2a 32 | false 33 | true 34 | 35 | 36 | 37 | true 38 | full 39 | false 40 | bin\Debug\ 41 | DEBUG;TRACE 42 | prompt 43 | 4 44 | 45 | 46 | AllRules.ruleset 47 | 48 | 49 | pdbonly 50 | true 51 | bin\Release\ 52 | TRACE 53 | prompt 54 | 4 55 | 56 | 57 | AllRules.ruleset 58 | 59 | 60 | SwfInitiator.Program 61 | 62 | 63 | 70 | 71 | 72 | 73 | 74 | False 75 | True 76 | C:\Program Files (x86)\AWS SDK for .NET\bin\Net35\AWSSDK.dll 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | ..\packages\AWSSDK.2.3.55.2\lib\net45\AWSSDK.dll 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | False 102 | .NET Framework 3.5 SP1 Client Profile 103 | false 104 | 105 | 106 | False 107 | .NET Framework 2.0 %28x86%29 108 | true 109 | 110 | 111 | False 112 | .NET Framework 3.0 %28x86%29 113 | false 114 | 115 | 116 | False 117 | .NET Framework 3.5 118 | false 119 | 120 | 121 | False 122 | .NET Framework 3.5 SP1 123 | false 124 | 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /Compute/SWF/Initiator/assemblyinfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SwfInitiator")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SwfInitiator")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | // [assembly: Guid("20b7ed34-3642-464a-a43f-65212cec0855")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Compute/SWF/Initiator/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Compute/SWF/Worker/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Compute/SWF/Worker/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Amazon; 4 | using Amazon.SimpleWorkflow; 5 | using Amazon.SimpleWorkflow.Model; 6 | 7 | namespace SwfWorker 8 | { 9 | class Program 10 | { 11 | static string domainName = "SwfDemoDomain"; 12 | static IAmazonSimpleWorkflow SwfClient = AWSClientFactory.CreateAmazonSimpleWorkflowClient(); 13 | 14 | public static void Main(string[] args) 15 | { 16 | string tasklistName = args[0]; 17 | Console.Title = tasklistName.ToUpper(); 18 | Task.Run(() => Worker(tasklistName)); 19 | Console.Read(); 20 | } 21 | 22 | 23 | static void Worker(string tasklistName) 24 | { 25 | string prefix = string.Format("WORKER {0}:{1:x} ", tasklistName, 26 | System.Threading.Thread.CurrentThread.ManagedThreadId); 27 | while (true) 28 | { 29 | Console.WriteLine($"{prefix} : Polling for activity task ..."); 30 | var pollForActivityTaskRequest = 31 | new PollForActivityTaskRequest() 32 | { 33 | Domain = domainName, 34 | TaskList = new TaskList() 35 | { 36 | // Poll only the tasks assigned to me 37 | Name = tasklistName 38 | } 39 | }; 40 | 41 | var pollForActivityTaskResponse = 42 | SwfClient.PollForActivityTask(pollForActivityTaskRequest); 43 | 44 | if (pollForActivityTaskResponse.ActivityTask.ActivityId == null) 45 | { 46 | Console.WriteLine($"{prefix} : NULL"); 47 | } 48 | else 49 | { 50 | Console.WriteLine($"{prefix} : saw Input {pollForActivityTaskResponse.ActivityTask.Input}"); 51 | 52 | var respondActivityTaskCompletedRequest = new RespondActivityTaskCompletedRequest() 53 | { 54 | Result = "{\"activityResult1\":\"Result Value1\"}", 55 | TaskToken = pollForActivityTaskResponse.ActivityTask.TaskToken 56 | }; 57 | 58 | var respondActivityTaskCompletedResponse = 59 | SwfClient.RespondActivityTaskCompleted(respondActivityTaskCompletedRequest); 60 | Console.WriteLine($"{prefix} : Activity task completed. ActivityId - " + 61 | pollForActivityTaskResponse.ActivityTask.ActivityId); 62 | } 63 | } 64 | } 65 | 66 | 67 | } 68 | } -------------------------------------------------------------------------------- /Compute/SWF/Worker/SwfWorker.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {7C2FA538-9265-4E81-A91D-1964A75869C7} 9 | Exe 10 | Properties 11 | SwfWorker 12 | SwfWorker 13 | v4.5 14 | 512 15 | false 16 | 17 | 18 | 3.5 19 | 20 | publish\ 21 | true 22 | Disk 23 | false 24 | Foreground 25 | 7 26 | Days 27 | false 28 | false 29 | true 30 | 0 31 | 1.0.0.%2a 32 | false 33 | true 34 | 35 | 36 | 37 | true 38 | full 39 | false 40 | bin\Debug\ 41 | DEBUG;TRACE 42 | prompt 43 | 4 44 | 45 | 46 | AllRules.ruleset 47 | 48 | 49 | pdbonly 50 | true 51 | bin\Release\ 52 | TRACE 53 | prompt 54 | 4 55 | 56 | 57 | AllRules.ruleset 58 | 59 | 60 | SwfWorker.Program 61 | 62 | 63 | 70 | 71 | 72 | 73 | 74 | False 75 | True 76 | C:\Program Files (x86)\AWS SDK for .NET\bin\Net35\AWSSDK.dll 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | ..\packages\AWSSDK.2.3.55.2\lib\net45\AWSSDK.dll 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | False 102 | .NET Framework 3.5 SP1 Client Profile 103 | false 104 | 105 | 106 | False 107 | .NET Framework 2.0 %28x86%29 108 | true 109 | 110 | 111 | False 112 | .NET Framework 3.0 %28x86%29 113 | false 114 | 115 | 116 | False 117 | .NET Framework 3.5 118 | false 119 | 120 | 121 | False 122 | .NET Framework 3.5 SP1 123 | false 124 | 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /Compute/SWF/Worker/assemblyinfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SwfWorker")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SwfWorker")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | // [assembly: Guid("20b7ed34-3642-464a-a43f-65212cec0855")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Compute/SWF/Worker/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Compute/SWF/swf.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SwfInitiator", "Initiator\SwfInitiator.csproj", "{2ECCA326-DA2E-4B3E-8152-459FF716B7FC}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SwfWorker", "Worker\SwfWorker.csproj", "{7C2FA538-9265-4E81-A91D-1964A75869C7}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SwfDecider", "Decider\SwfDecider.csproj", "{FBD389B9-B6B1-4420-AEC2-D95BD09482B4}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {2ECCA326-DA2E-4B3E-8152-459FF716B7FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {2ECCA326-DA2E-4B3E-8152-459FF716B7FC}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {2ECCA326-DA2E-4B3E-8152-459FF716B7FC}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {2ECCA326-DA2E-4B3E-8152-459FF716B7FC}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {7C2FA538-9265-4E81-A91D-1964A75869C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {7C2FA538-9265-4E81-A91D-1964A75869C7}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {7C2FA538-9265-4E81-A91D-1964A75869C7}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {7C2FA538-9265-4E81-A91D-1964A75869C7}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {FBD389B9-B6B1-4420-AEC2-D95BD09482B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {FBD389B9-B6B1-4420-AEC2-D95BD09482B4}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {FBD389B9-B6B1-4420-AEC2-D95BD09482B4}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {FBD389B9-B6B1-4420-AEC2-D95BD09482B4}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {9BEB401C-3138-4E31-990B-8A6B2A80D11B} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /Compute/ServerlessFrameworkLambda/.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 | -------------------------------------------------------------------------------- /Compute/ServerlessFrameworkLambda/Handler.cs: -------------------------------------------------------------------------------- 1 | using Amazon.Lambda.APIGatewayEvents; 2 | using Amazon.Lambda.Core; 3 | using Newtonsoft.Json; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Net; 7 | 8 | [assembly:LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))] 9 | 10 | namespace AwsDotnetCsharp 11 | { 12 | public class Handler 13 | { 14 | ITimeProcessor processor = new TimeProcessor(); 15 | 16 | public APIGatewayProxyResponse Hello( 17 | APIGatewayProxyRequest apigProxyEvent, ILambdaContext context) 18 | { 19 | LogMessage(context, "Processing request started"); 20 | APIGatewayProxyResponse response; 21 | try 22 | { 23 | var result = processor.CurrentTimeUTC(); 24 | response = CreateResponse(result); 25 | 26 | LogMessage(context, "Processing request succeeded."); 27 | } 28 | catch (Exception ex) 29 | { 30 | LogMessage(context, 31 | string.Format("Processing request failed - {0}", ex.Message)); 32 | response = CreateResponse(null); 33 | } 34 | 35 | return response; 36 | } 37 | 38 | APIGatewayProxyResponse CreateResponse(DateTime? result) 39 | { 40 | int statusCode = (result != null) ? 41 | (int)HttpStatusCode.OK : 42 | (int)HttpStatusCode.InternalServerError; 43 | 44 | string body = (result != null) ? 45 | JsonConvert.SerializeObject(result) : string.Empty; 46 | 47 | var response = new APIGatewayProxyResponse 48 | { 49 | StatusCode = statusCode, 50 | Body = body, 51 | Headers = new Dictionary 52 | { 53 | { "Content-Type", "application/json" }, 54 | { "Access-Control-Allow-Origin", "*" } 55 | } 56 | }; 57 | return response; 58 | } 59 | 60 | /// 61 | /// Logs messages to cloud watch 62 | /// 63 | void LogMessage(ILambdaContext ctx, string msg) 64 | { 65 | ctx.Logger.LogLine( 66 | string.Format("{0}:{1} - {2}", 67 | ctx.AwsRequestId, 68 | ctx.FunctionName, 69 | msg)); 70 | } 71 | } 72 | 73 | 74 | } 75 | -------------------------------------------------------------------------------- /Compute/ServerlessFrameworkLambda/TimeProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace AwsDotnetCsharp 6 | { 7 | public interface ITimeProcessor 8 | { 9 | DateTime CurrentTimeUTC(); 10 | } 11 | 12 | public class TimeProcessor : ITimeProcessor 13 | { 14 | public DateTime CurrentTimeUTC() 15 | { 16 | return DateTime.UtcNow; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Compute/ServerlessFrameworkLambda/aws-csharp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp2.1 5 | true 6 | CsharpHandlers 7 | aws-csharp 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Compute/ServerlessFrameworkLambda/build.cmd: -------------------------------------------------------------------------------- 1 | dotnet restore 2 | dotnet lambda package --configuration Release --framework netcoreapp2.1 --output-package bin/release/netcoreapp2.1/deploy-package.zip 3 | -------------------------------------------------------------------------------- /Compute/ServerlessFrameworkLambda/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #install zip on debian OS, since microsoft/dotnet container doesn't have zip by default 4 | if [ -f /etc/debian_version ] 5 | then 6 | apt -qq update 7 | apt -qq -y install zip 8 | fi 9 | 10 | dotnet restore 11 | dotnet lambda package --configuration release --framework netcoreapp2.1 --output-package bin/release/netcoreapp2.1/deploy-package.zip 12 | -------------------------------------------------------------------------------- /Compute/ServerlessFrameworkLambda/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: ServerlessFrameworkLambda # 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: dotnetcore2.1 23 | 24 | # you can overwrite defaults here 25 | # stage: dev 26 | region: eu-west-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.1/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: gettime 65 | method: get 66 | cors: true 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: amzn1.ask.skill.xx-xx-xx-xx 72 | # - alexaSmartHome: amzn1.ask.skill.xx-xx-xx-xx 73 | # - iot: 74 | # sql: "SELECT * FROM 'some_topic'" 75 | # - cloudwatchEvent: 76 | # event: 77 | # source: 78 | # - "aws.ec2" 79 | # detail-type: 80 | # - "EC2 Instance State-change Notification" 81 | # detail: 82 | # state: 83 | # - pending 84 | # - cloudwatchLog: '/aws/lambda/hello' 85 | # - cognitoUserPool: 86 | # pool: MyUserPool 87 | # trigger: PreSignUp 88 | 89 | # Define function environment variables here 90 | # environment: 91 | # variable2: value2 92 | 93 | # you can add CloudFormation resource templates here 94 | #resources: 95 | # Resources: 96 | # NewResource: 97 | # Type: AWS::S3::Bucket 98 | # Properties: 99 | # BucketName: my-new-bucket 100 | # Outputs: 101 | # NewOutput: 102 | # Description: "Description for the output" 103 | # Value: "Some output value" 104 | -------------------------------------------------------------------------------- /Compute/SimpleStepFunction/InvokeStatemachine/InvokeStatemachine.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Compute/SimpleStepFunction/InvokeStatemachine/Program.cs: -------------------------------------------------------------------------------- 1 |  using Amazon; 2 | using Amazon.Extensions.NETCore.Setup; 3 | using Amazon.SecurityToken; 4 | using Amazon.SecurityToken.Model; 5 | using Amazon.StepFunctions; 6 | using Amazon.StepFunctions.Model; 7 | using Newtonsoft.Json; 8 | using SimpleStepFunction; 9 | using System; 10 | using System.Threading.Tasks; 11 | 12 | namespace InvokeStatemachine 13 | { 14 | class Program 15 | { 16 | static void Main(string[] args) 17 | { 18 | //The IAM Default user you are using here will need StepFunctionsFullAccess 19 | ExecuteStepFunctionUsingDefaultProfileWithIAMStepFunctionsFullAccessInIAMConsole(); 20 | //ExecuteStepFunctionUsingAssumedExistingStateMachineRole(); 21 | Console.ReadLine(); 22 | } 23 | 24 | 25 | static void ExecuteStepFunctionUsingDefaultProfileWithIAMStepFunctionsFullAccessInIAMConsole() 26 | { 27 | var options = new AWSOptions() 28 | { 29 | Profile = "default", 30 | Region = RegionEndpoint.EUWest2 31 | }; 32 | 33 | var amazonStepFunctionsConfig = new AmazonStepFunctionsConfig { RegionEndpoint = RegionEndpoint.EUWest2 }; 34 | using (var amazonStepFunctionsClient = new AmazonStepFunctionsClient(amazonStepFunctionsConfig)) 35 | { 36 | var state = new State 37 | { 38 | Name = "MyStepFunctions" 39 | }; 40 | var jsonData1 = JsonConvert.SerializeObject(state); 41 | var startExecutionRequest = new StartExecutionRequest 42 | { 43 | Input = jsonData1, 44 | Name = $"SchedulingEngine_{Guid.NewGuid().ToString("N")}", 45 | StateMachineArn = "arn:aws:states:eu-west-2:464534050515:stateMachine:StateMachine-z8hrOwmL9CiG" 46 | }; 47 | var taskStartExecutionResponse = amazonStepFunctionsClient.StartExecutionAsync(startExecutionRequest).ConfigureAwait(false).GetAwaiter().GetResult(); 48 | } 49 | 50 | 51 | Console.ReadLine(); 52 | } 53 | 54 | 55 | static void ExecuteStepFunctionUsingAssumedExistingStateMachineRole() 56 | { 57 | var options = new AWSOptions() 58 | { 59 | Profile = "default", 60 | Region = RegionEndpoint.EUWest2 61 | }; 62 | 63 | var assumedRoleResponse = ManualAssume(options).ConfigureAwait(false).GetAwaiter().GetResult(); 64 | var assumedCredentials = assumedRoleResponse.Credentials; 65 | var amazonStepFunctionsConfig = new AmazonStepFunctionsConfig { RegionEndpoint = RegionEndpoint.EUWest2 }; 66 | using (var amazonStepFunctionsClient = new AmazonStepFunctionsClient( 67 | assumedCredentials.AccessKeyId, 68 | assumedCredentials.SecretAccessKey, amazonStepFunctionsConfig)) 69 | { 70 | var state = new State 71 | { 72 | Name = "MyStepFunctions" 73 | }; 74 | var jsonData1 = JsonConvert.SerializeObject(state); 75 | var startExecutionRequest = new StartExecutionRequest 76 | { 77 | Input = jsonData1, 78 | Name = $"SchedulingEngine_{Guid.NewGuid().ToString("N")}", 79 | StateMachineArn = "arn:aws:states:eu-west-2:464534050515:stateMachine:StateMachine-z8hrOwmL9CiG" 80 | }; 81 | var taskStartExecutionResponse = amazonStepFunctionsClient.StartExecutionAsync(startExecutionRequest).ConfigureAwait(false).GetAwaiter().GetResult(); 82 | } 83 | 84 | Console.ReadLine(); 85 | } 86 | 87 | 88 | public static async Task ManualAssume(AWSOptions options) 89 | { 90 | var stsClient = options.CreateServiceClient(); 91 | var assumedRoleResponse = await stsClient.AssumeRoleAsync(new AssumeRoleRequest() 92 | { 93 | RoleArn = "arn:aws:iam::464534050515:role/SimpleStepFunction-StateMachineRole-1N638DC3RLA16", 94 | RoleSessionName = "test" 95 | }); 96 | 97 | return assumedRoleResponse; 98 | 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Compute/SimpleStepFunction/MoreRealWorldStepFunction/MoreRealWorldStepFunction.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | true 6 | Lambda 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Compute/SimpleStepFunction/MoreRealWorldStepFunction/Readme.md: -------------------------------------------------------------------------------- 1 | # Step Functions Hello World 2 | 3 | This starter project consists of: 4 | 5 | * serverless.template - An AWS CloudFormation template file for declaring your Serverless functions and other AWS resources 6 | * state-machine.json -The definition of the Step Function state machine. 7 | * StepFunctionTasks.cs - This class contains the Lambda functions that the Step Function state machine will call. 8 | * State.cs - This class represent the state of the step function executions between Lambda function calls. 9 | * aws-lambda-tools-defaults.json - default argument settings for use with Visual Studio and command line deployment tools for AWS 10 | 11 | You may also have a test project depending on the options selected. 12 | 13 | The generated project is a simple hello world Step Functions example. It generates 2 Lambda functions that are called as tasks in a state machine. In the state-machine.json file the Step Function state machine is defined that tells the Step Function service in what order to call the Lambda functions. The Step Function execution's state is maintained in the State object which the Lambda functions read from, populate and return. In this example the first Lambda function also returns back a wait time to show how to configure a wait in the state machine. 14 | 15 | ### Defining a State Machine 16 | 17 | The state machine is defined in the state-machine.json file. When the project is deployed the contents of state-machine.json are copied into the serverless.template. The insertion location is controlled by the --template-substitutions parameter. The project template presets the --template-substitutions parameter in aws-lambda-tools-defaults.json. The format of the value for --template-substitutions is =. 18 | 19 | For example this project template sets the value to be: 20 | 21 | --template-substitutions $.Resources.StateMachine.Properties.DefinitionString.Fn::Sub=state-machine.json 22 | 23 | ### Test State Machine 24 | 25 | Once the project is deployed you can test it with the Step Functions in the web console https://console.aws.amazon.com/states/home. Select the newly created state machine and then click the "New Execution" button. Enter the initial JSON document for the input to the execution which will be serialized in to the State object. This project will look for a "Name" property to use in its execution. Here is an example input JSON. 26 | 27 | { 28 | "Name" : "MyStepFunctions" 29 | } 30 | 31 | ## Here are some steps to follow from Visual Studio: 32 | 33 | To deploy your Serverless application, right click the project in Solution Explorer and select *Publish to AWS Lambda*. 34 | 35 | To view your deployed application open the Stack View window by double-clicking the stack name shown beneath the AWS CloudFormation node in the AWS Explorer tree. The Stack View also displays the root URL to your published application. 36 | 37 | ## Here are some steps to follow to get started from the command line: 38 | 39 | Once you have edited your template and code you can deploy your application using the [Amazon.Lambda.Tools Global Tool](https://github.com/aws/aws-extensions-for-dotnet-cli#aws-lambda-amazonlambdatools) from the command line. 40 | 41 | Install Amazon.Lambda.Tools Global Tools if not already installed. 42 | ``` 43 | dotnet tool install -g Amazon.Lambda.Tools 44 | ``` 45 | 46 | If already installed check if new version is available. 47 | ``` 48 | dotnet tool update -g Amazon.Lambda.Tools 49 | ``` 50 | 51 | Execute unit tests 52 | ``` 53 | cd "MoreRealWorldStepFunction/test/MoreRealWorldStepFunction.Tests" 54 | dotnet test 55 | ``` 56 | 57 | Deploy application 58 | ``` 59 | cd "MoreRealWorldStepFunction/src/MoreRealWorldStepFunction" 60 | dotnet lambda deploy-serverless 61 | ``` 62 | -------------------------------------------------------------------------------- /Compute/SimpleStepFunction/MoreRealWorldStepFunction/State.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MoreRealWorldStepFunction 6 | { 7 | /// 8 | /// The state passed between the step function executions. 9 | /// 10 | public class State 11 | { 12 | /// 13 | /// Input value when starting the execution 14 | /// 15 | public string Name { get; set; } 16 | 17 | /// 18 | /// The message built through the step function execution. 19 | /// 20 | public string Message { get; set; } 21 | 22 | /// 23 | /// The number of seconds to wait between calling the Salutations task and Greeting task. 24 | /// 25 | public int WaitInSeconds { get; set; } 26 | 27 | /// 28 | /// 0 for female, 1 for male 29 | /// 30 | public int IsMale { get; set; } 31 | 32 | public override string ToString() 33 | { 34 | return $"Name='{Name}'-Message='{Message}'"; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Compute/SimpleStepFunction/MoreRealWorldStepFunction/StepFunctionTasks.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Threading.Tasks; 6 | 7 | using Amazon.Lambda.Core; 8 | 9 | 10 | // Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class. 11 | [assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))] 12 | 13 | namespace MoreRealWorldStepFunction 14 | { 15 | public class StepFunctionTasks 16 | { 17 | /// 18 | /// Default constructor that Lambda will invoke. 19 | /// 20 | public StepFunctionTasks() 21 | { 22 | } 23 | 24 | 25 | public State Initial(State state, ILambdaContext context) 26 | { 27 | state.Message = $"Hello-{Guid.NewGuid().ToString()}"; 28 | 29 | LogMessage(context, state.ToString()); 30 | 31 | 32 | state.IsMale = state.Name.StartsWith("Mr") ? 1 : 0; 33 | 34 | 35 | // Tell Step Function to wait 5 seconds before calling 36 | state.WaitInSeconds = 5; 37 | 38 | return state; 39 | } 40 | 41 | public State PrintMaleInfo(State state, ILambdaContext context) 42 | { 43 | LogMessage(context, "IS MALE"); 44 | return state; 45 | } 46 | 47 | public State PrintFemaleInfo(State state, ILambdaContext context) 48 | { 49 | LogMessage(context, "IS FEMALE"); 50 | return state; 51 | } 52 | 53 | 54 | public State Pass(State state, ILambdaContext context) 55 | { 56 | return state; 57 | } 58 | 59 | 60 | public State PrintInfo(State state, ILambdaContext context) 61 | { 62 | LogMessage(context, state.ToString()); 63 | return state; 64 | } 65 | 66 | 67 | void LogMessage(ILambdaContext ctx, string msg) 68 | { 69 | ctx.Logger.LogLine( 70 | string.Format("{0}:{1} - {2}", 71 | ctx.AwsRequestId, 72 | ctx.FunctionName, 73 | msg)); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Compute/SimpleStepFunction/MoreRealWorldStepFunction/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "Information" : [ 4 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 5 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 6 | "dotnet lambda help", 7 | "All the command line options for the Lambda command can be specified in this file." 8 | ], 9 | "profile" : "default", 10 | "region" : "eu-west-2", 11 | "configuration" : "Release", 12 | "framework" : "netcoreapp2.1", 13 | "s3-prefix" : "MoreRealWorldStepFunction/", 14 | "template" : "serverless.template", 15 | "template-parameters" : "", 16 | "template-substitutions" : "$.Resources.StateMachine.Properties.DefinitionString.Fn::Sub=state-machine.json", 17 | "s3-bucket" : "elasticbeanstalk-eu-west-2-464534050515", 18 | "stack-name" : "MoreRealWorldStepFunction" 19 | } -------------------------------------------------------------------------------- /Compute/SimpleStepFunction/MoreRealWorldStepFunction/serverless.template: -------------------------------------------------------------------------------- 1 | { 2 | "AWSTemplateFormatVersion" : "2010-09-09", 3 | "Transform" : "AWS::Serverless-2016-10-31", 4 | "Description" : "An AWS Serverless Application.", 5 | 6 | "Resources" : { 7 | "InitialTask" : { 8 | "Type" : "AWS::Lambda::Function", 9 | "Properties" : { 10 | "Handler" : "MoreRealWorldStepFunction::MoreRealWorldStepFunction.StepFunctionTasks::Initial", 11 | "Role" : {"Fn::GetAtt" : [ "LambdaRole", "Arn"]}, 12 | "Runtime" : "dotnetcore2.1", 13 | "MemorySize" : 256, 14 | "Timeout" : 30, 15 | "Code" : { 16 | "S3Bucket" : "", 17 | "S3Key" : "" 18 | } 19 | } 20 | }, 21 | "PassTask" : { 22 | "Type" : "AWS::Lambda::Function", 23 | "Properties" : { 24 | "Handler" : "MoreRealWorldStepFunction::MoreRealWorldStepFunction.StepFunctionTasks::Pass", 25 | "Role" : {"Fn::GetAtt" : [ "LambdaRole", "Arn"]}, 26 | "Runtime" : "dotnetcore2.1", 27 | "MemorySize" : 256, 28 | "Timeout" : 30, 29 | "Code" : { 30 | "S3Bucket" : "", 31 | "S3Key" : "" 32 | } 33 | } 34 | }, 35 | "PrintInfoTask" : { 36 | "Type" : "AWS::Lambda::Function", 37 | "Properties" : { 38 | "Handler" : "MoreRealWorldStepFunction::MoreRealWorldStepFunction.StepFunctionTasks::PrintInfo", 39 | "Role" : {"Fn::GetAtt" : [ "LambdaRole", "Arn"]}, 40 | "Runtime" : "dotnetcore2.1", 41 | "MemorySize" : 256, 42 | "Timeout" : 30, 43 | "Code" : { 44 | "S3Bucket" : "", 45 | "S3Key" : "" 46 | } 47 | } 48 | }, 49 | "PrintMaleInfoTask" : { 50 | "Type" : "AWS::Lambda::Function", 51 | "Properties" : { 52 | "Handler" : "MoreRealWorldStepFunction::MoreRealWorldStepFunction.StepFunctionTasks::PrintMaleInfo", 53 | "Role" : {"Fn::GetAtt" : [ "LambdaRole", "Arn"]}, 54 | "Runtime" : "dotnetcore2.1", 55 | "MemorySize" : 256, 56 | "Timeout" : 30, 57 | "Code" : { 58 | "S3Bucket" : "", 59 | "S3Key" : "" 60 | } 61 | } 62 | }, 63 | "PrintFemaleInfoTask" : { 64 | "Type" : "AWS::Lambda::Function", 65 | "Properties" : { 66 | "Handler" : "MoreRealWorldStepFunction::MoreRealWorldStepFunction.StepFunctionTasks::PrintFemaleInfo", 67 | "Role" : {"Fn::GetAtt" : [ "LambdaRole", "Arn"]}, 68 | "Runtime" : "dotnetcore2.1", 69 | "MemorySize" : 256, 70 | "Timeout" : 30, 71 | "Code" : { 72 | "S3Bucket" : "", 73 | "S3Key" : "" 74 | } 75 | } 76 | }, 77 | "StateMachine" : { 78 | "Type" : "AWS::StepFunctions::StateMachine", 79 | "Properties": { 80 | "RoleArn": { "Fn::GetAtt": [ "StateMachineRole", "Arn" ] }, 81 | "DefinitionString": { "Fn::Sub": "" } 82 | } 83 | }, 84 | "LambdaRole" : { 85 | "Type" : "AWS::IAM::Role", 86 | "Properties" : { 87 | "AssumeRolePolicyDocument" : { 88 | "Version" : "2012-10-17", 89 | "Statement" : [ 90 | { 91 | "Action" : [ 92 | "sts:AssumeRole" 93 | ], 94 | "Effect" : "Allow", 95 | "Principal" : { 96 | "Service" : [ 97 | "lambda.amazonaws.com" 98 | ] 99 | } 100 | } 101 | ] 102 | }, 103 | "ManagedPolicyArns" : [ 104 | "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" 105 | ] 106 | } 107 | }, 108 | "StateMachineRole" : { 109 | "Type" : "AWS::IAM::Role", 110 | "Properties" : { 111 | "AssumeRolePolicyDocument" : { 112 | "Version": "2012-10-17", 113 | "Statement": [ 114 | { 115 | "Effect": "Allow", 116 | "Principal": { 117 | "Service": {"Fn::Sub" : "states.${AWS::Region}.amazonaws.com"} 118 | }, 119 | "Action": "sts:AssumeRole" 120 | } 121 | ] 122 | }, 123 | "Policies" : [{ 124 | "PolicyName": "StepFunctionLambdaInvoke", 125 | "PolicyDocument": { 126 | "Version": "2012-10-17", 127 | "Statement": [ 128 | { 129 | "Effect": "Allow", 130 | "Action": [ 131 | "lambda:InvokeFunction" 132 | ], 133 | "Resource": "*" 134 | } 135 | ] 136 | } 137 | }] 138 | } 139 | } 140 | }, 141 | "Outputs" : { 142 | } 143 | } -------------------------------------------------------------------------------- /Compute/SimpleStepFunction/MoreRealWorldStepFunction/state-machine.json: -------------------------------------------------------------------------------- 1 | { 2 | "Comment": "State Machine", 3 | "StartAt": "Initial", 4 | "States": { 5 | "Initial": { 6 | "Type": "Task", 7 | "Resource": "${InitialTask.Arn}", 8 | "Next": "WaitToActivate" 9 | }, 10 | "WaitToActivate": { 11 | "Type": "Wait", 12 | "SecondsPath": "$.WaitInSeconds", 13 | "Next": "Pass" 14 | }, 15 | "Pass": { 16 | "Type": "Task", 17 | "Resource": "${PassTask.Arn}", 18 | "Next": "ChoiceStateX" 19 | }, 20 | 21 | "ChoiceStateX": { 22 | "Type": "Choice", 23 | "Choices": [ 24 | { 25 | "Variable": "$.IsMale", 26 | "NumericEquals": 1, 27 | "Next": "PrintMaleInfo" 28 | }, 29 | { 30 | "Variable": "$.IsMale", 31 | "NumericEquals": 0, 32 | "Next": "PrintFemaleInfo" 33 | } 34 | ], 35 | "Default": "PrintInfo" 36 | }, 37 | "PrintMaleInfo": { 38 | "Type": "Task", 39 | "Resource": "${PrintMaleInfoTask.Arn}", 40 | "End": true 41 | }, 42 | "PrintFemaleInfo": { 43 | "Type": "Task", 44 | "Resource": "${PrintFemaleInfoTask.Arn}", 45 | "End": true 46 | }, 47 | "PrintInfo": { 48 | "Type": "Task", 49 | "Resource": "${PrintInfoTask.Arn}", 50 | "End": true 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Compute/SimpleStepFunction/SimpleStepFunction.Tests/FunctionTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Xunit; 5 | using Amazon.Lambda.TestUtilities; 6 | using Amazon.StepFunctions; 7 | using Amazon; 8 | using Newtonsoft.Json; 9 | using Amazon.StepFunctions.Model; 10 | using System.Net; 11 | using Amazon.SecurityToken; 12 | using Amazon.SecurityToken.Model; 13 | using Amazon.Runtime; 14 | using System.Threading.Tasks; 15 | using System.Threading; 16 | 17 | namespace SimpleStepFunction.Tests 18 | { 19 | public class FunctionTest 20 | { 21 | public FunctionTest() 22 | { 23 | } 24 | 25 | [Fact] 26 | public void TestGreeting() 27 | { 28 | TestLambdaContext context = new TestLambdaContext(); 29 | 30 | StepFunctionTasks functions = new StepFunctionTasks(); 31 | 32 | var state = new State 33 | { 34 | Name = "MyStepFunctions" 35 | }; 36 | 37 | 38 | state = functions.Greeting(state, context); 39 | 40 | Assert.Equal(5, state.WaitInSeconds); 41 | Assert.Equal("Hello MyStepFunctions", state.Message); 42 | } 43 | 44 | } 45 | } 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /Compute/SimpleStepFunction/SimpleStepFunction.Tests/SimpleStepFunction.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Compute/SimpleStepFunction/SimpleStepFunction.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleStepFunction", "SimpleStepFunction\SimpleStepFunction.csproj", "{3B59CB50-582E-4B74-AE39-723FC40AD535}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleStepFunction.Tests", "SimpleStepFunction.Tests\SimpleStepFunction.Tests.csproj", "{5120BB3D-5AA7-4989-93C8-4D8C0BEB2159}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InvokeStatemachine", "InvokeStatemachine\InvokeStatemachine.csproj", "{2A1911B1-022B-4825-8685-B8B8668D4667}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MoreRealWorldStepFunction", "MoreRealWorldStepFunction\MoreRealWorldStepFunction.csproj", "{558ADCB9-BD7F-4ADF-BBFB-594957357BB0}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {3B59CB50-582E-4B74-AE39-723FC40AD535}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {3B59CB50-582E-4B74-AE39-723FC40AD535}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {3B59CB50-582E-4B74-AE39-723FC40AD535}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {3B59CB50-582E-4B74-AE39-723FC40AD535}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {5120BB3D-5AA7-4989-93C8-4D8C0BEB2159}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {5120BB3D-5AA7-4989-93C8-4D8C0BEB2159}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {5120BB3D-5AA7-4989-93C8-4D8C0BEB2159}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {5120BB3D-5AA7-4989-93C8-4D8C0BEB2159}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {2A1911B1-022B-4825-8685-B8B8668D4667}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {2A1911B1-022B-4825-8685-B8B8668D4667}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {2A1911B1-022B-4825-8685-B8B8668D4667}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {2A1911B1-022B-4825-8685-B8B8668D4667}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {558ADCB9-BD7F-4ADF-BBFB-594957357BB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {558ADCB9-BD7F-4ADF-BBFB-594957357BB0}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {558ADCB9-BD7F-4ADF-BBFB-594957357BB0}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {558ADCB9-BD7F-4ADF-BBFB-594957357BB0}.Release|Any CPU.Build.0 = Release|Any CPU 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | GlobalSection(ExtensibilityGlobals) = postSolution 41 | SolutionGuid = {FE955F92-91ED-4CF1-8126-D6D323DB4599} 42 | EndGlobalSection 43 | EndGlobal 44 | -------------------------------------------------------------------------------- /Compute/SimpleStepFunction/SimpleStepFunction/Readme.md: -------------------------------------------------------------------------------- 1 | # Step Functions Hello World 2 | 3 | This starter project consists of: 4 | 5 | * serverless.template - An AWS CloudFormation template file for declaring your Serverless functions and other AWS resources 6 | * state-machine.json -The definition of the Step Function state machine. 7 | * StepFunctionTasks.cs - This class contains the Lambda functions that the Step Function state machine will call. 8 | * State.cs - This class represent the state of the step function executions between Lambda function calls. 9 | * aws-lambda-tools-defaults.json - default argument settings for use with Visual Studio and command line deployment tools for AWS 10 | 11 | You may also have a test project depending on the options selected. 12 | 13 | The generated project is a simple hello world Step Functions example. It generates 2 Lambda functions that are called as tasks in a state machine. In the state-machine.json file the Step Function state machine is defined that tells the Step Function service in what order to call the Lambda functions. The Step Function execution's state is maintained in the State object which the Lambda functions read from, populate and return. In this example the first Lambda function also returns back a wait time to show how to configure a wait in the state machine. 14 | 15 | ### Defining a State Machine 16 | 17 | The state machine is defined in the state-machine.json file. When the project is deployed the contents of state-machine.json are copied into the serverless.template. The insertion location is controlled by the --template-substitutions parameter. The project template presets the --template-substitutions parameter in aws-lambda-tools-defaults.json. The format of the value for --template-substitutions is =. 18 | 19 | For example this project template sets the value to be: 20 | 21 | --template-substitutions $.Resources.StateMachine.Properties.DefinitionString.Fn::Sub=state-machine.json 22 | 23 | ### Test State Machine 24 | 25 | Once the project is deployed you can test it with the Step Functions in the web console https://console.aws.amazon.com/states/home. Select the newly created state machine and then click the "New Execution" button. Enter the initial JSON document for the input to the execution which will be serialized in to the State object. This project will look for a "Name" property to use in its execution. Here is an example input JSON. 26 | 27 | { 28 | "Name" : "MyStepFunctions" 29 | } 30 | 31 | ## Here are some steps to follow from Visual Studio: 32 | 33 | To deploy your Serverless application, right click the project in Solution Explorer and select *Publish to AWS Lambda*. 34 | 35 | To view your deployed application open the Stack View window by double-clicking the stack name shown beneath the AWS CloudFormation node in the AWS Explorer tree. The Stack View also displays the root URL to your published application. 36 | 37 | ## Here are some steps to follow to get started from the command line: 38 | 39 | Once you have edited your template and code you can deploy your application using the [Amazon.Lambda.Tools Global Tool](https://github.com/aws/aws-extensions-for-dotnet-cli#aws-lambda-amazonlambdatools) from the command line. 40 | 41 | Install Amazon.Lambda.Tools Global Tools if not already installed. 42 | ``` 43 | dotnet tool install -g Amazon.Lambda.Tools 44 | ``` 45 | 46 | If already installed check if new version is available. 47 | ``` 48 | dotnet tool update -g Amazon.Lambda.Tools 49 | ``` 50 | 51 | Execute unit tests 52 | ``` 53 | cd "SimpleStepFunction/test/SimpleStepFunction.Tests" 54 | dotnet test 55 | ``` 56 | 57 | Deploy application 58 | ``` 59 | cd "SimpleStepFunction/src/SimpleStepFunction" 60 | dotnet lambda deploy-serverless 61 | ``` 62 | -------------------------------------------------------------------------------- /Compute/SimpleStepFunction/SimpleStepFunction/SimpleStepFunction.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | true 6 | Lambda 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Compute/SimpleStepFunction/SimpleStepFunction/State.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SimpleStepFunction 6 | { 7 | /// 8 | /// The state passed between the step function executions. 9 | /// 10 | public class State 11 | { 12 | /// 13 | /// Input value when starting the execution 14 | /// 15 | public string Name { get; set; } 16 | 17 | /// 18 | /// The message built through the step function execution. 19 | /// 20 | public string Message { get; set; } 21 | 22 | /// 23 | /// The number of seconds to wait between calling the Salutations task and Greeting task. 24 | /// 25 | public int WaitInSeconds { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Compute/SimpleStepFunction/SimpleStepFunction/StepFunctionTasks.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Threading.Tasks; 6 | 7 | using Amazon.Lambda.Core; 8 | 9 | 10 | // Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class. 11 | [assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))] 12 | 13 | namespace SimpleStepFunction 14 | { 15 | public class StepFunctionTasks 16 | { 17 | /// 18 | /// Default constructor that Lambda will invoke. 19 | /// 20 | public StepFunctionTasks() 21 | { 22 | } 23 | 24 | 25 | public State Greeting(State state, ILambdaContext context) 26 | { 27 | state.Message = "Hello"; 28 | 29 | if(!string.IsNullOrEmpty(state.Name)) 30 | { 31 | state.Message += " " + state.Name; 32 | } 33 | 34 | // Tell Step Function to wait 5 seconds before calling 35 | state.WaitInSeconds = 5; 36 | 37 | return state; 38 | } 39 | 40 | public State Salutations(State state, ILambdaContext context) 41 | { 42 | state.Message += ", Goodbye"; 43 | 44 | if (!string.IsNullOrEmpty(state.Name)) 45 | { 46 | state.Message += " " + state.Name; 47 | } 48 | 49 | return state; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Compute/SimpleStepFunction/SimpleStepFunction/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "Information" : [ 4 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 5 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 6 | "dotnet lambda help", 7 | "All the command line options for the Lambda command can be specified in this file." 8 | ], 9 | "profile" : "default", 10 | "region" : "eu-west-2", 11 | "configuration" : "Release", 12 | "framework" : "netcoreapp2.1", 13 | "s3-prefix" : "SimpleStepFunction/", 14 | "template" : "serverless.template", 15 | "template-parameters" : "", 16 | "template-substitutions" : "$.Resources.StateMachine.Properties.DefinitionString.Fn::Sub=state-machine.json", 17 | "s3-bucket" : "simplestepfunction", 18 | "stack-name" : "SimpleStepFunction" 19 | } -------------------------------------------------------------------------------- /Compute/SimpleStepFunction/SimpleStepFunction/serverless.template: -------------------------------------------------------------------------------- 1 | { 2 | "AWSTemplateFormatVersion" : "2010-09-09", 3 | "Transform" : "AWS::Serverless-2016-10-31", 4 | "Description" : "An AWS Serverless Application.", 5 | 6 | "Resources" : { 7 | "GreetingTask" : { 8 | "Type" : "AWS::Lambda::Function", 9 | "Properties" : { 10 | "Handler" : "SimpleStepFunction::SimpleStepFunction.StepFunctionTasks::Greeting", 11 | "Role" : {"Fn::GetAtt" : [ "LambdaRole", "Arn"]}, 12 | "Runtime" : "dotnetcore2.1", 13 | "MemorySize" : 256, 14 | "Timeout" : 30, 15 | "Code" : { 16 | "S3Bucket" : "", 17 | "S3Key" : "" 18 | } 19 | } 20 | }, 21 | "SalutationsTask" : { 22 | "Type" : "AWS::Lambda::Function", 23 | "Properties" : { 24 | "Handler" : "SimpleStepFunction::SimpleStepFunction.StepFunctionTasks::Salutations", 25 | "Role" : {"Fn::GetAtt" : [ "LambdaRole", "Arn"]}, 26 | "Runtime" : "dotnetcore2.1", 27 | "MemorySize" : 256, 28 | "Timeout" : 30, 29 | "Code" : { 30 | "S3Bucket" : "", 31 | "S3Key" : "" 32 | } 33 | } 34 | }, 35 | "StateMachine" : { 36 | "Type" : "AWS::StepFunctions::StateMachine", 37 | "Properties": { 38 | "RoleArn": { "Fn::GetAtt": [ "StateMachineRole", "Arn" ] }, 39 | "DefinitionString": { "Fn::Sub": "" } 40 | } 41 | }, 42 | "LambdaRole" : { 43 | "Type" : "AWS::IAM::Role", 44 | "Properties" : { 45 | "AssumeRolePolicyDocument" : { 46 | "Version" : "2012-10-17", 47 | "Statement" : [ 48 | { 49 | "Action" : [ 50 | "sts:AssumeRole" 51 | ], 52 | "Effect" : "Allow", 53 | "Principal" : { 54 | "Service" : [ 55 | "lambda.amazonaws.com" 56 | ] 57 | } 58 | } 59 | ] 60 | }, 61 | "ManagedPolicyArns" : [ 62 | "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" 63 | ] 64 | } 65 | }, 66 | "StateMachineRole" : { 67 | "Type" : "AWS::IAM::Role", 68 | "Properties" : { 69 | "AssumeRolePolicyDocument" : { 70 | "Version": "2012-10-17", 71 | "Statement": [ 72 | { 73 | "Effect": "Allow", 74 | "Principal": { 75 | "Service": {"Fn::Sub" : "states.${AWS::Region}.amazonaws.com"} 76 | }, 77 | "Action": "sts:AssumeRole" 78 | } 79 | ] 80 | }, 81 | "Policies" : [{ 82 | "PolicyName": "StepFunctionLambdaInvoke", 83 | "PolicyDocument": { 84 | "Version": "2012-10-17", 85 | "Statement": [ 86 | { 87 | "Effect": "Allow", 88 | "Action": [ 89 | "lambda:InvokeFunction" 90 | ], 91 | "Resource": "*" 92 | } 93 | ] 94 | } 95 | }] 96 | } 97 | } 98 | }, 99 | "Outputs" : { 100 | } 101 | } -------------------------------------------------------------------------------- /Compute/SimpleStepFunction/SimpleStepFunction/state-machine.json: -------------------------------------------------------------------------------- 1 | { 2 | "Comment": "State Machine", 3 | "StartAt": "Greeting", 4 | "States": { 5 | "Greeting": { 6 | "Type": "Task", 7 | "Resource": "${GreetingTask.Arn}", 8 | "Next": "WaitToActivate" 9 | }, 10 | "WaitToActivate": { 11 | "Type": "Wait", 12 | "SecondsPath": "$.WaitInSeconds", 13 | "Next": "Salutations" 14 | }, 15 | "Salutations": { 16 | "Type": "Task", 17 | "Resource": "${SalutationsTask.Arn}", 18 | "End": true 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Databases/DynamoDB/DynamoDBDataModel.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DynamoDBDataModel", "DynamoDBDataModel\DynamoDBDataModel.csproj", "{8E25F579-EFC4-412D-99AB-7662CF94FAF9}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamoDBDemo", "DynamoDBDemo\DynamoDBDemo.csproj", "{12F480DC-7B4C-484D-AE2B-DC5BE80F922E}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {8E25F579-EFC4-412D-99AB-7662CF94FAF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {8E25F579-EFC4-412D-99AB-7662CF94FAF9}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {8E25F579-EFC4-412D-99AB-7662CF94FAF9}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {8E25F579-EFC4-412D-99AB-7662CF94FAF9}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {12F480DC-7B4C-484D-AE2B-DC5BE80F922E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {12F480DC-7B4C-484D-AE2B-DC5BE80F922E}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {12F480DC-7B4C-484D-AE2B-DC5BE80F922E}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {12F480DC-7B4C-484D-AE2B-DC5BE80F922E}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {269E1772-2AC6-43AE-964E-B1F85BBD1F69} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Databases/DynamoDB/DynamoDBDataModel/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Databases/DynamoDB/DynamoDBDataModel/DataModelSchema.cs: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2009-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may 5 | * not use this file except in compliance with the License. A copy of the 6 | * License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0/ 9 | * 10 | * or in the "license" file accompanying this file. This file is 11 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 12 | * KIND, either express or implied. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | *******************************************************************************/ 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using System.Linq; 19 | using System.Text; 20 | 21 | using Amazon.DynamoDBv2.DataModel; 22 | using Amazon.DynamoDBv2.DocumentModel; 23 | using System.Xml.Serialization; 24 | using System.IO; 25 | using System.Xml; 26 | 27 | namespace AwsDynamoDBDataModelSample1 28 | { 29 | [DynamoDBTable("Movies")] 30 | public class Movie 31 | { 32 | [DynamoDBHashKey] 33 | public string Title { get; set; } 34 | [DynamoDBRangeKey(AttributeName = "Released")] 35 | public DateTime ReleaseDate { get; set; } 36 | 37 | public List Genres { get; set; } 38 | [DynamoDBProperty("Actors")] 39 | public List ActorNames { get; set; } 40 | 41 | public override string ToString() 42 | { 43 | return string.Format(@"{0} - {1} 44 | Actors: {2}", Title, ReleaseDate, string.Join(", ", ActorNames.ToArray())); 45 | } 46 | } 47 | 48 | [DynamoDBTable("Actors")] 49 | public class Actor 50 | { 51 | [DynamoDBHashKey] 52 | public string Name { get; set; } 53 | 54 | public string Bio { get; set; } 55 | public DateTime BirthDate { get; set; } 56 | 57 | [DynamoDBProperty(AttributeName = "Height")] 58 | public float HeightInMeters { get; set; } 59 | 60 | [DynamoDBProperty(Converter = typeof(AddressConverter))] 61 | public Address Address { get; set; } 62 | 63 | [DynamoDBIgnore] 64 | public string Comment { get; set; } 65 | 66 | public TimeSpan Age 67 | { 68 | get 69 | { 70 | return DateTime.UtcNow - BirthDate.ToUniversalTime(); 71 | } 72 | } 73 | 74 | public override string ToString() 75 | { 76 | return string.Format("{0} - {1}", Name, BirthDate); 77 | } 78 | } 79 | 80 | public class Address 81 | { 82 | public string Street { get; set; } 83 | public string City { get; set; } 84 | public string Country { get; set; } 85 | } 86 | 87 | public class AddressConverter : IPropertyConverter 88 | { 89 | private XmlSerializer _serializer = new XmlSerializer(typeof(Address)); 90 | 91 | #region IPropertyConverter Members 92 | 93 | public object FromEntry(DynamoDBEntry entry) 94 | { 95 | Primitive primitive = entry as Primitive; 96 | if (primitive == null) return null; 97 | 98 | if (primitive.Type != DynamoDBEntryType.String) throw new InvalidCastException(); 99 | string xml = primitive.AsString(); 100 | using (StringReader reader = new StringReader(xml)) 101 | { 102 | return _serializer.Deserialize(reader); 103 | } 104 | } 105 | 106 | public DynamoDBEntry ToEntry(object value) 107 | { 108 | Address address = value as Address; 109 | if (address == null) return null; 110 | 111 | string xml; 112 | using (StringWriter stringWriter = new StringWriter()) 113 | { 114 | _serializer.Serialize(stringWriter, address); 115 | xml = stringWriter.ToString(); 116 | } 117 | return new Primitive(xml); 118 | } 119 | 120 | #endregion 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /Databases/DynamoDB/DynamoDBDataModel/DynamoDBDataModel.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net45 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Databases/DynamoDB/DynamoDBDataModel/Program.cs: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2009-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may 5 | * not use this file except in compliance with the License. A copy of the 6 | * License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0/ 9 | * 10 | * or in the "license" file accompanying this file. This file is 11 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 12 | * KIND, either express or implied. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | *******************************************************************************/ 15 | 16 | using System; 17 | 18 | using Amazon; 19 | using Amazon.DynamoDBv2; 20 | using Amazon.DynamoDBv2.DataModel; 21 | 22 | namespace AwsDynamoDBDataModelSample1 23 | { 24 | public partial class Program 25 | { 26 | public static void Main(string[] args) 27 | { 28 | Console.WriteLine(); 29 | Console.WriteLine("Setting up DynamoDB client"); 30 | AmazonDynamoDBClient client = new AmazonDynamoDBClient(); 31 | 32 | Console.WriteLine(); 33 | Console.WriteLine("Creating sample tables"); 34 | TableOperations.CreateSampleTables(client); 35 | 36 | Console.WriteLine(); 37 | Console.WriteLine("Creating the context object"); 38 | DynamoDBContext context = new DynamoDBContext(client); 39 | 40 | Console.WriteLine(); 41 | Console.WriteLine("Running DataModel sample"); 42 | RunDataModelSample(context); 43 | 44 | Console.WriteLine(); 45 | Console.WriteLine("Removing sample tables"); 46 | TableOperations.DeleteSampleTables(client); 47 | 48 | Console.WriteLine(); 49 | Console.WriteLine("Press Enter to continue..."); 50 | Console.ReadLine(); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Messaging/Kinesis/AWS_Kinesis.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Amazon.Kinesis.ClientLibrary", "Amazon.Kinesis.ClientLibrary", "{6A5832F9-5282-4942-AB13-0F1D4D391BB2}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DataStreamsAPI", "DataStreamsAPI", "{E2063DE1-FD8E-4E17-AA29-6BC93222649E}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataStreamConsumer", "DataStreamAPI\DataStreamConsumer\DataStreamConsumer.csproj", "{8820FBE2-51CF-4250-8F5B-0DEB2B01FDF4}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataStreamProducer", "DataStreamAPI\DataStreamProducer\DataStreamProducer.csproj", "{288C37CF-E7A4-41F9-AC81-B27710E6E1AB}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bootstrap", "KCL\Bootstrap\Bootstrap.csproj", "{8848A31F-A263-45F3-BCC4-16F560E35A15}" 15 | EndProject 16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientLibrary", "KCL\ClientLibrary\ClientLibrary.csproj", "{66D88DB0-8140-4864-A8A5-2A6AA065BBDF}" 17 | EndProject 18 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleConsumer", "KCL\SampleConsumer\SampleConsumer.csproj", "{F7486F6F-0B1F-484E-95B2-7A267844A936}" 19 | EndProject 20 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleProducer", "KCL\SampleProducer\SampleProducer.csproj", "{6EB6D8DA-0BC7-41E5-8F14-18D9E1B2152C}" 21 | EndProject 22 | Global 23 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 24 | Debug|Any CPU = Debug|Any CPU 25 | Release|Any CPU = Release|Any CPU 26 | EndGlobalSection 27 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 28 | {8820FBE2-51CF-4250-8F5B-0DEB2B01FDF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {8820FBE2-51CF-4250-8F5B-0DEB2B01FDF4}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {8820FBE2-51CF-4250-8F5B-0DEB2B01FDF4}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {8820FBE2-51CF-4250-8F5B-0DEB2B01FDF4}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {288C37CF-E7A4-41F9-AC81-B27710E6E1AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {288C37CF-E7A4-41F9-AC81-B27710E6E1AB}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {288C37CF-E7A4-41F9-AC81-B27710E6E1AB}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {288C37CF-E7A4-41F9-AC81-B27710E6E1AB}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {8848A31F-A263-45F3-BCC4-16F560E35A15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {8848A31F-A263-45F3-BCC4-16F560E35A15}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {8848A31F-A263-45F3-BCC4-16F560E35A15}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {8848A31F-A263-45F3-BCC4-16F560E35A15}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {66D88DB0-8140-4864-A8A5-2A6AA065BBDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {66D88DB0-8140-4864-A8A5-2A6AA065BBDF}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {66D88DB0-8140-4864-A8A5-2A6AA065BBDF}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {66D88DB0-8140-4864-A8A5-2A6AA065BBDF}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {F7486F6F-0B1F-484E-95B2-7A267844A936}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {F7486F6F-0B1F-484E-95B2-7A267844A936}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {F7486F6F-0B1F-484E-95B2-7A267844A936}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {F7486F6F-0B1F-484E-95B2-7A267844A936}.Release|Any CPU.Build.0 = Release|Any CPU 48 | {6EB6D8DA-0BC7-41E5-8F14-18D9E1B2152C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 49 | {6EB6D8DA-0BC7-41E5-8F14-18D9E1B2152C}.Debug|Any CPU.Build.0 = Debug|Any CPU 50 | {6EB6D8DA-0BC7-41E5-8F14-18D9E1B2152C}.Release|Any CPU.ActiveCfg = Release|Any CPU 51 | {6EB6D8DA-0BC7-41E5-8F14-18D9E1B2152C}.Release|Any CPU.Build.0 = Release|Any CPU 52 | EndGlobalSection 53 | GlobalSection(SolutionProperties) = preSolution 54 | HideSolutionNode = FALSE 55 | EndGlobalSection 56 | GlobalSection(NestedProjects) = preSolution 57 | {8820FBE2-51CF-4250-8F5B-0DEB2B01FDF4} = {E2063DE1-FD8E-4E17-AA29-6BC93222649E} 58 | {288C37CF-E7A4-41F9-AC81-B27710E6E1AB} = {E2063DE1-FD8E-4E17-AA29-6BC93222649E} 59 | {8848A31F-A263-45F3-BCC4-16F560E35A15} = {6A5832F9-5282-4942-AB13-0F1D4D391BB2} 60 | {66D88DB0-8140-4864-A8A5-2A6AA065BBDF} = {6A5832F9-5282-4942-AB13-0F1D4D391BB2} 61 | {F7486F6F-0B1F-484E-95B2-7A267844A936} = {6A5832F9-5282-4942-AB13-0F1D4D391BB2} 62 | {6EB6D8DA-0BC7-41E5-8F14-18D9E1B2152C} = {6A5832F9-5282-4942-AB13-0F1D4D391BB2} 63 | EndGlobalSection 64 | GlobalSection(ExtensibilityGlobals) = postSolution 65 | SolutionGuid = {2BEA84E0-80AB-46A9-BBA5-0542ABAE7140} 66 | EndGlobalSection 67 | EndGlobal 68 | -------------------------------------------------------------------------------- /Messaging/Kinesis/DataStreamAPI/DataStreamConsumer/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Messaging/Kinesis/DataStreamAPI/DataStreamConsumer/ConsumerApp.cs: -------------------------------------------------------------------------------- 1 | using Amazon.Kinesis.Model; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Amazon.Kinesis.DataStreamConsumer 8 | { 9 | /// 10 | /// A sample producer of Kinesis records. 11 | /// 12 | class ConsumerApp 13 | { 14 | private static readonly AmazonKinesisClient kinesisClient = 15 | new AmazonKinesisClient(RegionEndpoint.EUWest2); 16 | const string myStreamName = "myTestStream"; 17 | 18 | public static void Main(string[] args) 19 | { 20 | new ConsumerApp().ReadFromStream().GetAwaiter().GetResult(); 21 | } 22 | 23 | private async Task ReadFromStream() 24 | { 25 | DescribeStreamRequest describeRequest = new DescribeStreamRequest(); 26 | describeRequest.StreamName = myStreamName; 27 | 28 | DescribeStreamResponse describeResponse = 29 | await kinesisClient.DescribeStreamAsync(describeRequest); 30 | List shards = describeResponse.StreamDescription.Shards; 31 | 32 | foreach (Shard shard in shards) 33 | { 34 | GetShardIteratorRequest iteratorRequest = new GetShardIteratorRequest(); 35 | iteratorRequest.StreamName = myStreamName; 36 | iteratorRequest.ShardId = shard.ShardId; 37 | iteratorRequest.ShardIteratorType = ShardIteratorType.TRIM_HORIZON; 38 | 39 | GetShardIteratorResponse iteratorResponse = await kinesisClient.GetShardIteratorAsync(iteratorRequest); 40 | string iteratorId = iteratorResponse.ShardIterator; 41 | 42 | while (!string.IsNullOrEmpty(iteratorId)) 43 | { 44 | GetRecordsRequest getRequest = new GetRecordsRequest(); 45 | getRequest.Limit = 1000; 46 | getRequest.ShardIterator = iteratorId; 47 | 48 | GetRecordsResponse getResponse = await kinesisClient.GetRecordsAsync(getRequest); 49 | string nextIterator = getResponse.NextShardIterator; 50 | List records = getResponse.Records; 51 | 52 | if (records.Count > 0) 53 | { 54 | Console.WriteLine("Received {0} records. ", records.Count); 55 | foreach (Record record in records) 56 | { 57 | string theMessage = Encoding.UTF8.GetString(record.Data.ToArray()); 58 | Console.WriteLine("message string: " + theMessage); 59 | } 60 | } 61 | iteratorId = nextIterator; 62 | } 63 | } 64 | } 65 | 66 | } 67 | } -------------------------------------------------------------------------------- /Messaging/Kinesis/DataStreamAPI/DataStreamConsumer/DataStreamConsumer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | Always 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Messaging/Kinesis/DataStreamAPI/DataStreamProducer/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Messaging/Kinesis/DataStreamAPI/DataStreamProducer/DataStreamProducer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | Always 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Messaging/Kinesis/DataStreamAPI/DataStreamProducer/DataStreamProducerApp.cs: -------------------------------------------------------------------------------- 1 | using Amazon.Kinesis.Model; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | namespace Amazon.Kinesis.DataStreamproducer 10 | { 11 | /// 12 | /// A sample producer of Kinesis records. 13 | /// 14 | class ProducerApp 15 | { 16 | 17 | 18 | private static readonly AmazonKinesisClient kinesisClient = 19 | new AmazonKinesisClient(RegionEndpoint.EUWest2); 20 | const string myStreamName = "myTestStream"; 21 | 22 | public static void Main(string[] args) 23 | { 24 | new ProducerApp().WriteToStream().GetAwaiter().GetResult(); 25 | } 26 | 27 | private async Task WriteToStream() 28 | { 29 | const string myStreamName = "myTestStream"; 30 | const int myStreamSize = 1; 31 | 32 | try 33 | { 34 | var createStreamRequest = new CreateStreamRequest(); 35 | createStreamRequest.StreamName = myStreamName; 36 | createStreamRequest.ShardCount = myStreamSize; 37 | var createStreamReq = createStreamRequest; 38 | 39 | var existingStreams = await kinesisClient.ListStreamsAsync(); 40 | 41 | if (!existingStreams.StreamNames.Contains(myStreamName)) 42 | { 43 | 44 | var CreateStreamResponse = await kinesisClient.CreateStreamAsync(createStreamReq); 45 | Console.WriteLine("Created Stream : " + myStreamName); 46 | } 47 | } 48 | catch (ResourceInUseException) 49 | { 50 | Console.Error.WriteLine("Producer is quitting without creating stream " + myStreamName + 51 | " to put records into as a stream of the same name already exists."); 52 | Environment.Exit(1); 53 | } 54 | 55 | await WaitForStreamToBecomeAvailableAsync(myStreamName); 56 | 57 | Console.Error.WriteLine("Putting records in stream : " + myStreamName); 58 | // Write 10 UTF-8 encoded records to the stream. 59 | for (int j = 0; j < 10; ++j) 60 | { 61 | byte[] dataAsBytes = Encoding.UTF8.GetBytes("testdata-" + j); 62 | using (MemoryStream memoryStream = new MemoryStream(dataAsBytes)) 63 | { 64 | try 65 | { 66 | PutRecordRequest requestRecord = new PutRecordRequest(); 67 | requestRecord.StreamName = myStreamName; 68 | requestRecord.PartitionKey = "url-response-times"; 69 | requestRecord.Data = memoryStream; 70 | 71 | PutRecordResponse responseRecord = 72 | await kinesisClient.PutRecordAsync(requestRecord); 73 | Console.WriteLine("Successfully sent record to Kinesis. Sequence number: {0}", 74 | responseRecord.SequenceNumber); 75 | } 76 | catch (Exception ex) 77 | { 78 | Console.WriteLine("Failed to send record to Kinesis. Exception: {0}", ex.Message); 79 | } 80 | } 81 | } 82 | 83 | Console.ReadLine(); 84 | 85 | } 86 | 87 | /// 88 | /// This method waits a maximum of 10 minutes for the specified stream to become active. 89 | /// Name of the stream whose active status is waited upon. 90 | /// 91 | private static async Task WaitForStreamToBecomeAvailableAsync(string myStreamName) 92 | { 93 | var deadline = DateTime.UtcNow + TimeSpan.FromMinutes(10); 94 | while (DateTime.UtcNow < deadline) 95 | { 96 | DescribeStreamRequest describeStreamReq = new DescribeStreamRequest(); 97 | describeStreamReq.StreamName = myStreamName; 98 | var describeResult = await kinesisClient.DescribeStreamAsync(describeStreamReq); 99 | string streamStatus = describeResult.StreamDescription.StreamStatus; 100 | Console.Error.WriteLine(" - current state: " + streamStatus); 101 | if (streamStatus == StreamStatus.ACTIVE) 102 | { 103 | return; 104 | } 105 | Thread.Sleep(TimeSpan.FromSeconds(20)); 106 | } 107 | 108 | throw new Exception("Stream " + myStreamName + " never went active."); 109 | } 110 | 111 | 112 | } 113 | } -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/Bootstrap/Bootstrap.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | Exe 6 | netcoreapp2.0 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/Bootstrap/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | // Information about this assembly is defined by the following attributes. 4 | // Change them to the values specific to your project. 5 | 6 | [assembly: AssemblyTitle("Bootstrap for Amazon Kinesis Client Library .NET")] 7 | [assembly: AssemblyDescription("Bootstrap program for Amazon Kinesis Client Library .NET")] 8 | [assembly: AssemblyConfiguration("")] 9 | [assembly: AssemblyCompany("Amazon.com, Inc")] 10 | [assembly: AssemblyProduct("Bootstrap for Amazon Kinesis Client Library .NET")] 11 | [assembly: AssemblyCopyright("Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.")] 12 | [assembly: AssemblyTrademark("")] 13 | [assembly: AssemblyCulture("")] 14 | 15 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 16 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 17 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 18 | 19 | [assembly: AssemblyVersion("1.0")] 20 | [assembly: AssemblyFileVersion("1.0.0")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | 28 | -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/ClientLibrary/ClientLibrary.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.0 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/ClientLibrary/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle("Amazon Kinesis Client Library .NET")] 8 | [assembly: AssemblyDescription("Amazon Kinesis Client Library for .NET")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("Amazon.com, Inc")] 11 | [assembly: AssemblyProduct("Amazon Kinesis Client Library .NET")] 12 | [assembly: AssemblyCopyright("Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion("1.0")] 21 | [assembly: AssemblyFileVersion("1.0.0")] 22 | 23 | // The following attributes are used to specify the signing key for the assembly, 24 | // if desired. See the Mono documentation for more information about signing. 25 | 26 | //[assembly: AssemblyDelaySign(false)] 27 | //[assembly: AssemblyKeyFile("")] 28 | 29 | // Required for Substitutes in tests 30 | [assembly:InternalsVisibleTo("DynamicProxyGenAssembly2")] 31 | [assembly:InternalsVisibleTo("ClientLibrary.Test")] -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/ClientLibrary/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/SampleConsumer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | Always 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/jars/amazon-kinesis-client-1.9.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/Messaging/Kinesis/KCL/SampleConsumer/jars/amazon-kinesis-client-1.9.0.jar -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/jars/aws-java-sdk-cloudwatch-1.11.273.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/Messaging/Kinesis/KCL/SampleConsumer/jars/aws-java-sdk-cloudwatch-1.11.273.jar -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/jars/aws-java-sdk-core-1.11.273.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/Messaging/Kinesis/KCL/SampleConsumer/jars/aws-java-sdk-core-1.11.273.jar -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/jars/aws-java-sdk-dynamodb-1.11.273.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/Messaging/Kinesis/KCL/SampleConsumer/jars/aws-java-sdk-dynamodb-1.11.273.jar -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/jars/aws-java-sdk-kinesis-1.11.273.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/Messaging/Kinesis/KCL/SampleConsumer/jars/aws-java-sdk-kinesis-1.11.273.jar -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/jars/aws-java-sdk-kms-1.11.273.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/Messaging/Kinesis/KCL/SampleConsumer/jars/aws-java-sdk-kms-1.11.273.jar -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/jars/aws-java-sdk-s3-1.11.273.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/Messaging/Kinesis/KCL/SampleConsumer/jars/aws-java-sdk-s3-1.11.273.jar -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/jars/commons-codec-1.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/Messaging/Kinesis/KCL/SampleConsumer/jars/commons-codec-1.9.jar -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/jars/commons-lang-2.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/Messaging/Kinesis/KCL/SampleConsumer/jars/commons-lang-2.6.jar -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/jars/commons-logging-1.1.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/Messaging/Kinesis/KCL/SampleConsumer/jars/commons-logging-1.1.3.jar -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/jars/guava-18.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/Messaging/Kinesis/KCL/SampleConsumer/jars/guava-18.0.jar -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/jars/httpclient-4.5.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/Messaging/Kinesis/KCL/SampleConsumer/jars/httpclient-4.5.2.jar -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/jars/httpcore-4.4.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/Messaging/Kinesis/KCL/SampleConsumer/jars/httpcore-4.4.4.jar -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/jars/jackson-annotations-2.6.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/Messaging/Kinesis/KCL/SampleConsumer/jars/jackson-annotations-2.6.0.jar -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/jars/jackson-core-2.6.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/Messaging/Kinesis/KCL/SampleConsumer/jars/jackson-core-2.6.6.jar -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/jars/jackson-databind-2.6.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/Messaging/Kinesis/KCL/SampleConsumer/jars/jackson-databind-2.6.6.jar -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/jars/jackson-dataformat-cbor-2.6.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/Messaging/Kinesis/KCL/SampleConsumer/jars/jackson-dataformat-cbor-2.6.6.jar -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/jars/joda-time-2.8.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/Messaging/Kinesis/KCL/SampleConsumer/jars/joda-time-2.8.1.jar -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/jars/protobuf-java-2.6.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachabarber/AWS/2c3c0d551d23b52f2f059bfe9642041b4190e336/Messaging/Kinesis/KCL/SampleConsumer/jars/protobuf-java-2.6.1.jar -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleConsumer/kcl.properties: -------------------------------------------------------------------------------- 1 | # The script that abides by the multi-language protocol. This script will 2 | # be executed by the MultiLangDaemon, which will communicate with this script 3 | # over STDIN and STDOUT according to the multi-language protocol. 4 | executableName = dotnet C:\\Users\\sacha\\Desktop\\AWS-Playground\\AWS\\Messaging\\Kinesis\\KCL\\SampleConsumer\\bin\\Debug\\netcoreapp2.0\\SampleConsumer.dll 5 | 6 | 7 | # The name of an Amazon Kinesis stream to process. 8 | streamName = myTestStream 9 | 10 | # Used by the KCL as the name of this application. Will be used as the name 11 | # of an Amazon DynamoDB table which will store the lease and checkpoint 12 | # information for workers with this application name 13 | applicationName = DotNetKinesisSample 14 | 15 | # Users can change the credentials provider the KCL will use to retrieve credentials. 16 | # The DefaultAWSCredentialsProviderChain checks several other providers, which is 17 | # described here: 18 | # http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/auth/DefaultAWSCredentialsProviderChain.html 19 | AWSCredentialsProvider = DefaultAWSCredentialsProviderChain 20 | 21 | # Appended to the user agent of the KCL. Does not impact the functionality of the 22 | # KCL in any other way. 23 | processingLanguage = C# 24 | 25 | # Valid options at TRIM_HORIZON or LATEST. 26 | # See http://docs.aws.amazon.com/kinesis/latest/APIReference/API_GetShardIterator.html#API_GetShardIterator_RequestSyntax 27 | initialPositionInStream = TRIM_HORIZON 28 | 29 | # The following properties are also available for configuring the KCL Worker that is created 30 | # by the MultiLangDaemon. 31 | 32 | # The KCL defaults to us-east-1 33 | regionName = eu-west-2 34 | 35 | # Fail over time in milliseconds. A worker which does not renew it's lease within this time interval 36 | # will be regarded as having problems and it's shards will be assigned to other workers. 37 | # For applications that have a large number of shards, this msy be set to a higher number to reduce 38 | # the number of DynamoDB IOPS required for tracking leases 39 | #failoverTimeMillis = 10000 40 | 41 | # A worker id that uniquely identifies this worker among all workers using the same applicationName 42 | # If this isn't provided a MultiLangDaemon instance will assign a unique workerId to itself. 43 | #workerId = 44 | 45 | # Shard sync interval in milliseconds - e.g. wait for this long between shard sync tasks. 46 | #shardSyncIntervalMillis = 60000 47 | 48 | # Max records to fetch from Kinesis in a single GetRecords call. 49 | maxRecords = 5000 50 | 51 | # Idle time between record reads in milliseconds. 52 | idleTimeBetweenReadsInMillis = 1000 53 | 54 | # Enables applications flush/checkpoint (if they have some data "in progress", but don't get new data for while) 55 | #callProcessRecordsEvenForEmptyRecordList = false 56 | 57 | # Interval in milliseconds between polling to check for parent shard completion. 58 | # Polling frequently will take up more DynamoDB IOPS (when there are leases for shards waiting on 59 | # completion of parent shards). 60 | #parentShardPollIntervalMillis = 10000 61 | 62 | # Cleanup leases upon shards completion (don't wait until they expire in Kinesis). 63 | # Keeping leases takes some tracking/resources (e.g. they need to be renewed, assigned), so by default we try 64 | # to delete the ones we don't need any longer. 65 | #cleanupLeasesUponShardCompletion = true 66 | 67 | # Backoff time in milliseconds for Amazon Kinesis Client Library tasks (in the event of failures). 68 | #taskBackoffTimeMillis = 500 69 | 70 | # Buffer metrics for at most this long before publishing to CloudWatch. 71 | #metricsBufferTimeMillis = 10000 72 | 73 | # Buffer at most this many metrics before publishing to CloudWatch. 74 | #metricsMaxQueueSize = 10000 75 | 76 | # KCL will validate client provided sequence numbers with a call to Amazon Kinesis before checkpointing for calls 77 | # to RecordProcessorCheckpointer#checkpoint(String) by default. 78 | #validateSequenceNumberBeforeCheckpointing = true 79 | 80 | # The maximum number of active threads for the MultiLangDaemon to permit. 81 | # If a value is provided then a FixedThreadPool is used with the maximum 82 | # active threads set to the provided value. If a non-positive integer or no 83 | # value is provided a CachedThreadPool is used. 84 | #maxActiveThreads = 0 85 | -------------------------------------------------------------------------------- /Messaging/Kinesis/KCL/SampleProducer/SampleProducer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | Always 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Messaging/SQSSinglePublisherManyReceivers/SQSSinglePublisherManyReceivers.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SQSSinglePublisherManyReceivers", "SQSSinglePublisherManyReceivers\SQSSinglePublisherManyReceivers.csproj", "{8A2ED24B-F309-4503-9AC2-FD874D0485C5}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {8A2ED24B-F309-4503-9AC2-FD874D0485C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {8A2ED24B-F309-4503-9AC2-FD874D0485C5}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {8A2ED24B-F309-4503-9AC2-FD874D0485C5}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {8A2ED24B-F309-4503-9AC2-FD874D0485C5}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {44F1921F-DD8A-4E96-81F9-4CAAC4DE0472} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Messaging/SQSSinglePublisherManyReceivers/SQSSinglePublisherManyReceivers/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Messaging/SQSSinglePublisherManyReceivers/SQSSinglePublisherManyReceivers/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | using Amazon.SQS; 5 | using Amazon.SQS.Model; 6 | using Nito.AsyncEx; 7 | 8 | namespace SQSSinglePublisherManyReceivers 9 | { 10 | class Program 11 | { 12 | private static bool _receieverShouldDeleteMessage = false; 13 | private static AmazonSQSClient _sqs = new AmazonSQSClient(); 14 | private static string _myQueueUrl; 15 | 16 | 17 | static void Main(string[] args) 18 | { 19 | AsyncContext.Run(() => MainAsync(args)); 20 | } 21 | 22 | 23 | static async void MainAsync(string[] args) 24 | { 25 | try 26 | { 27 | Console.WriteLine("==========================================="); 28 | Console.WriteLine("Getting Started with Amazon SQS"); 29 | Console.WriteLine("===========================================\n"); 30 | 31 | //Creating a queue 32 | Console.WriteLine("Create a queue called MyQueue.\n"); 33 | var sqsRequest = new CreateQueueRequest { QueueName = "MyQueue11" }; 34 | var createQueueResponse = await _sqs.CreateQueueAsync(sqsRequest); 35 | _myQueueUrl = createQueueResponse.QueueUrl; 36 | 37 | //Confirming the queue exists 38 | var listQueuesRequest = new ListQueuesRequest(); 39 | var listQueuesResponse = await _sqs.ListQueuesAsync(listQueuesRequest); 40 | 41 | Console.WriteLine("Printing list of Amazon SQS queues.\n"); 42 | if (listQueuesResponse.QueueUrls != null) 43 | { 44 | foreach (String queueUrl in listQueuesResponse.QueueUrls) 45 | { 46 | Console.WriteLine(" QueueUrl: {0}", queueUrl); 47 | } 48 | } 49 | Console.WriteLine(); 50 | 51 | //Sending a message 52 | for (int i = 0; i < 10; i++) 53 | { 54 | var message = $"This is my message text-Id-{Guid.NewGuid().ToString("N")}"; 55 | //var message = $"This is my message text"; 56 | Console.WriteLine($"Sending a message to MyQueue : {message}"); 57 | var sendMessageRequest = new SendMessageRequest 58 | { 59 | QueueUrl = _myQueueUrl, //URL from initial queue creation 60 | MessageBody = message 61 | }; 62 | await _sqs.SendMessageAsync(sendMessageRequest); 63 | } 64 | 65 | //start of 5 receiver tasks 66 | var tasks = Enumerable.Range(0, 5).Select(number => 67 | Task.Run(async () => 68 | await ReceiveMessage(number) 69 | )).ToList(); 70 | 71 | await Task.WhenAll(tasks); 72 | 73 | } 74 | catch (AmazonSQSException ex) 75 | { 76 | Console.WriteLine("Caught Exception: " + ex.Message); 77 | Console.WriteLine("Response Status Code: " + ex.StatusCode); 78 | Console.WriteLine("Error Code: " + ex.ErrorCode); 79 | Console.WriteLine("Error Type: " + ex.ErrorType); 80 | Console.WriteLine("Request ID: " + ex.RequestId); 81 | } 82 | 83 | Console.WriteLine("Press Enter to continue..."); 84 | Console.Read(); 85 | } 86 | 87 | 88 | private static async Task ReceiveMessage(int state) 89 | { 90 | //Receiving a message 91 | var receiveMessageRequest = new ReceiveMessageRequest { QueueUrl = _myQueueUrl }; 92 | var receiveMessageResponse = await _sqs.ReceiveMessageAsync(receiveMessageRequest); 93 | if (receiveMessageResponse.Messages != null) 94 | { 95 | Console.WriteLine($"Receiever {state} Printing received message.\n"); 96 | foreach (var message in receiveMessageResponse.Messages) 97 | { 98 | Console.WriteLine($"Receiever {state} Message"); 99 | if (!string.IsNullOrEmpty(message.MessageId)) 100 | { 101 | Console.WriteLine($"Receiever {state} MessageId: {message.MessageId}"); 102 | } 103 | if (!string.IsNullOrEmpty(message.ReceiptHandle)) 104 | { 105 | Console.WriteLine($"Receiever {state} ReceiptHandle: {message.ReceiptHandle}"); 106 | } 107 | if (!string.IsNullOrEmpty(message.MD5OfBody)) 108 | { 109 | Console.WriteLine($"Receiever {state} MD5OfBody: {message.MD5OfBody}"); 110 | } 111 | if (!string.IsNullOrEmpty(message.Body)) 112 | { 113 | Console.WriteLine($"Receiever {state} Body: {message.Body}"); 114 | } 115 | 116 | foreach (string attributeKey in message.Attributes.Keys) 117 | { 118 | Console.WriteLine(" Attribute"); 119 | Console.WriteLine(" Name: {0}", attributeKey); 120 | var value = message.Attributes[attributeKey]; 121 | Console.WriteLine(" Value: {0}", string.IsNullOrEmpty(value) ? "(no value)" : value); 122 | } 123 | } 124 | 125 | var messageRecieptHandle = receiveMessageResponse.Messages[0].ReceiptHandle; 126 | 127 | if (_receieverShouldDeleteMessage) 128 | { 129 | //Deleting a message 130 | Console.WriteLine("Deleting the message.\n"); 131 | var deleteRequest = new DeleteMessageRequest { QueueUrl = _myQueueUrl, ReceiptHandle = messageRecieptHandle }; 132 | _sqs.DeleteMessage(deleteRequest); 133 | } 134 | } 135 | } 136 | } 137 | } -------------------------------------------------------------------------------- /Messaging/SQSSinglePublisherManyReceivers/SQSSinglePublisherManyReceivers/SQSSinglePublisherManyReceivers.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net45 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AWS 2 | Collection of AWS .NET (and possibly Scala) Samples 3 | 4 | ## Intro 5 | - [Introduction to AWS account/tools etc etc](https://sachabarbs.wordpress.com/2018/08/30/aws-initial-setup/) 6 | 7 | ## Storage 8 | - [S3 Buckets and Keys example](https://sachabarbs.wordpress.com/2018/09/03/aws-s3-storage/) 9 | - [Glacier Storage](https://sachabarbs.wordpress.com/2018/09/04/aws-glacial-storage/) 10 | - [S3 File System](https://sachabarbs.wordpress.com/2018/09/05/aws-s3-file-system/) 11 | - [S3 TransferUtility](https://sachabarbs.wordpress.com/2018/09/10/aws-transferutility/) 12 | 13 | ## Messaging 14 | - [SQS](https://sachabarbs.wordpress.com/2018/09/12/aws-simple-queue-service-sqs/) 15 | - [Kinesis Data Streams / KCL](https://sachabarbs.wordpress.com/2018/09/17/aws-kinesis/) 16 | 17 | 18 | ## Compute 19 | - [Deploying ASP .NET Core app to Elastic Beanstalk](https://sachabarbs.wordpress.com/2018/09/19/aws-deploying-asp-net-core-app-to-elastic-beanstalk/) 20 | - [SQS triggered Lambda writing to S3](https://sachabarbs.wordpress.com/2018/09/27/aws-lambda/) 21 | - [Lambda exposed via Api Gateway](https://sachabarbs.wordpress.com/2018/10/07/aws-lambda-exposed-via-apigateway/) 22 | - [Lambda exposed via Api using 'Serverless Framework'](https://sachabarbs.wordpress.com/2018/10/15/aws-using-serveless-framework-to-create-a-lambda-function/) 23 | - [Step Functions](https://sachabarbs.wordpress.com/2018/10/30/aws-step-functions/) 24 | 25 | 26 | ## AppServices 27 | 28 | - [SES/SMTP](https://sachabarbs.wordpress.com/2018/11/05/aws-simple-email-service-ses/) 29 | - [SWF](https://sachabarbs.wordpress.com/2018/11/15/aws-swf/) 30 | - [ElastiCache](https://sachabarbs.wordpress.com/2018/12/10/aws-elasticache/) 31 | 32 | 33 | ## Databases 34 | - [DynamoDB](https://sachabarbs.wordpress.com/2018/12/09/aws-dynamodb/) 35 | 36 | 37 | 38 | TODO 39 | 40 | 41 | - Batch 42 | - Cloudwatch 43 | 44 | - SNS 45 | - RDS 46 | - Neptune 47 | - Amazon Redshift 48 | - Fargate 49 | - App Mesh : https://aws.amazon.com/about-aws/whats-new/2018/11/introducing-aws-app-mesh---service-mesh-for-microservices-on-aws/ 50 | 51 | -------------------------------------------------------------------------------- /Storage/GlacierStorage/GlacierStorage.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GlacierStorage", "GlacierStorage\GlacierStorage.csproj", "{493139EA-F800-48EF-92A6-0B83397F863C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {493139EA-F800-48EF-92A6-0B83397F863C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {493139EA-F800-48EF-92A6-0B83397F863C}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {493139EA-F800-48EF-92A6-0B83397F863C}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {493139EA-F800-48EF-92A6-0B83397F863C}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {AAFCB1AB-80F4-4DA3-B69A-0624569B25C3} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Storage/GlacierStorage/GlacierStorage/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Storage/GlacierStorage/GlacierStorage/GlacierStorage.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net45 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Storage/GlacierStorage/GlacierStorage/Program.cs: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2009-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may 5 | * not use this file except in compliance with the License. A copy of the 6 | * License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0/ 9 | * 10 | * or in the "license" file accompanying this file. This file is 11 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 12 | * KIND, either express or implied. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | *******************************************************************************/ 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using System.Linq; 19 | using System.Text; 20 | using Amazon; 21 | using Amazon.Glacier; 22 | using Amazon.Glacier.Model; 23 | using Amazon.Glacier.Transfer; 24 | using System.Collections.Specialized; 25 | using System.Configuration; 26 | using Amazon.Runtime; 27 | using Nito.AsyncEx; 28 | 29 | namespace GlacierStorage 30 | { 31 | class Program 32 | { 33 | // Change the AWSProfileName to the profile you want to use in the App.config file. 34 | // See http://aws.amazon.com/credentials for more details. 35 | // You must also sign up for an Amazon Glacier account for this to work 36 | // See http://aws.amazon.com/glacier/ for details on creating an Amazon Glacier account 37 | // Change the vaultName and fileName fields to values that match your vaultName and fileName 38 | 39 | static ArchiveTransferManager manager; 40 | static string archiveId; 41 | 42 | //Set the vault name you want to use here. 43 | static string vaultName = null; 44 | 45 | // Set the file path for the file you want to upload here. 46 | static string filePath = null; 47 | 48 | // Set the file path for the archive to be saved after download. 49 | static string downloadFilePath = null; 50 | 51 | 52 | private static void Main(string[] args) 53 | { 54 | AsyncContext.Run(() => MainAsync(args)); 55 | } 56 | 57 | static async void MainAsync(string[] args) 58 | { 59 | if (CheckRequiredFields()) 60 | { 61 | var glacierClient = new AmazonGlacierClient(); 62 | using (manager = new ArchiveTransferManager(glacierClient)) 63 | { 64 | try 65 | { 66 | // Creates a new Vault 67 | Console.WriteLine("Create Vault"); 68 | await manager.CreateVaultAsync(vaultName); 69 | 70 | // Uploads the specified file to Glacier. 71 | Console.WriteLine("Upload a Archive"); 72 | var uploadResult = await manager.UploadAsync(vaultName, "Archive Description", filePath); 73 | archiveId = uploadResult.ArchiveId; 74 | Console.WriteLine("Upload successful. Archive Id : {0} Checksum : {1}", 75 | uploadResult.ArchiveId, uploadResult.Checksum); 76 | 77 | 78 | // Downloads the file from Glacier 79 | // This operation can take a long time to complete. 80 | // The ArchiveTransferManager.Download() method creates an Amazon SNS topic, 81 | // and an Amazon SQS queue that is subscribed to that topic. 82 | // It then initiates the archive retrieval job and polls the queue for the 83 | // archive to be available. This polling takes about 4 hours. 84 | // Once the archive is available, download will begin. 85 | Console.WriteLine("Download the Archive"); 86 | var options = new DownloadOptions(); 87 | options.StreamTransferProgress += OnProgress; 88 | await manager.DownloadAsync(vaultName, archiveId, downloadFilePath, options); 89 | 90 | Console.WriteLine("Delete the Archive"); 91 | await manager.DeleteArchiveAsync(vaultName, archiveId); 92 | 93 | } 94 | catch (AmazonGlacierException e) 95 | { 96 | Console.WriteLine(e.Message); 97 | } 98 | catch (AmazonServiceException e) 99 | { 100 | Console.WriteLine(e.Message); 101 | } 102 | } 103 | } 104 | } 105 | 106 | static int currentPercentage = -1; 107 | 108 | static void OnProgress(object sender, StreamTransferProgressArgs args) 109 | { 110 | if (args.PercentDone != currentPercentage) 111 | { 112 | currentPercentage = args.PercentDone; 113 | Console.WriteLine("Downloaded {0}%", args.PercentDone); 114 | } 115 | } 116 | 117 | static bool CheckRequiredFields() 118 | { 119 | NameValueCollection appConfig = ConfigurationManager.AppSettings; 120 | 121 | if (string.IsNullOrEmpty(appConfig["AWSProfileName"])) 122 | { 123 | Console.WriteLine("AWSProfileName was not set in the App.config file."); 124 | return false; 125 | } 126 | if (string.IsNullOrEmpty(vaultName)) 127 | { 128 | Console.WriteLine("The variable vaultName is not set."); 129 | return false; 130 | } 131 | if (string.IsNullOrEmpty(filePath)) 132 | { 133 | Console.WriteLine("The variable filePath is not set."); 134 | return false; 135 | } 136 | if (string.IsNullOrEmpty(downloadFilePath)) 137 | { 138 | Console.WriteLine("The variable downloadFilePath is not set."); 139 | return false; 140 | } 141 | 142 | return true; 143 | } 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /Storage/S3BucketsAndKeys/S3BucketsAndKeys.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "S3BucketsAndKeys", "S3BucketsAndKeys\S3BucketsAndKeys.csproj", "{7CF51922-4900-4916-8E10-A94138ADBC0F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {7CF51922-4900-4916-8E10-A94138ADBC0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {7CF51922-4900-4916-8E10-A94138ADBC0F}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {7CF51922-4900-4916-8E10-A94138ADBC0F}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {7CF51922-4900-4916-8E10-A94138ADBC0F}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {5F82C966-8DC9-4972-B22F-E6C6747F05CB} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Storage/S3BucketsAndKeys/S3BucketsAndKeys/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Storage/S3BucketsAndKeys/S3BucketsAndKeys/S3BucketsAndKeys.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net45 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Storage/S3FileSystem/FileSystem.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileSystem", "FileSystem\FileSystem.csproj", "{F82802D2-AEF5-489E-8947-C02ED133ABCF}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {F82802D2-AEF5-489E-8947-C02ED133ABCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {F82802D2-AEF5-489E-8947-C02ED133ABCF}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {F82802D2-AEF5-489E-8947-C02ED133ABCF}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {F82802D2-AEF5-489E-8947-C02ED133ABCF}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {FC99592B-108B-4792-838C-37177D4ED27C} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Storage/S3FileSystem/FileSystem/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Storage/S3FileSystem/FileSystem/FileSystem.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net45 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Storage/S3FileSystem/FileSystem/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.Specialized; 4 | using System.Configuration; 5 | using System.IO; 6 | using System.Text; 7 | using Amazon.S3; 8 | using Amazon.S3.IO; 9 | 10 | namespace FileSystem 11 | { 12 | class Program 13 | { 14 | // Change the AWSProfileName to the profile you want to use in the App.config file. 15 | // See http://aws.amazon.com/credentials for more details. 16 | // You must also sign up for an Amazon S3 account for this to work 17 | // See http://aws.amazon.com/s3/ for details on creating an Amazon S3 account 18 | // Change the bucketName field to a unique name that will ;be created and used for the sample. 19 | static string bucketName = Guid.NewGuid().ToString("N").ToLower(); 20 | static IAmazonS3 client; 21 | static bool deleteAtEnd = false; 22 | 23 | private static void Main(string[] args) 24 | { 25 | if (checkRequiredFields()) 26 | { 27 | using (client = new AmazonS3Client(new AmazonS3Config() 28 | { 29 | MaxErrorRetry = 2, 30 | ThrottleRetries = true 31 | })) 32 | { 33 | // Creates the bucket. 34 | S3DirectoryInfo rootDirectory = new S3DirectoryInfo(client, bucketName); 35 | rootDirectory.Create(); 36 | 37 | // Creates a file at the root of the bucket. 38 | S3FileInfo readme = rootDirectory.GetFile("README.txt"); 39 | using (StreamWriter writer = new StreamWriter(readme.OpenWrite())) 40 | writer.WriteLine("This is my readme file."); 41 | 42 | // Create a directory called code and write a file to it. 43 | S3DirectoryInfo codeDir = rootDirectory.CreateSubdirectory("wiki"); 44 | S3FileInfo codeFile = codeDir.GetFile("Phantasmagoria.txt"); 45 | using (StreamWriter writer = new StreamWriter(codeFile.OpenWrite())) 46 | { 47 | writer.WriteLine("Phantasmagoria (About this sound American pronunciation (help·info), also fantasmagorie, fantasmagoria) was a form of horror theatre that "); 48 | writer.WriteLine("(among other techniques) used one or more magic lanterns to project frightening images such as skeletons, demons, and "); 49 | writer.WriteLine("ghosts onto walls, smoke, or semi-transparent screens, typically using rear projection to keep the lantern out of sight. Mobile or "); 50 | writer.WriteLine("portable projectors were used, allowing the projected image to move and change size on the screen, and multiple projecting "); 51 | writer.WriteLine("devices allowed for quick switching of different images. In many shows the use of spooky decoration, total darkness, sound "); 52 | writer.WriteLine("effects, (auto-)suggestive verbal presentation and sound effects were also key elements. Some shows added all kinds of "); 53 | writer.WriteLine("sensory stimulation, including smells and electric shocks. Even required fasting, fatigue (late shows) and drugs have been "); 54 | writer.WriteLine("mentioned as methods of making sure spectators would be more convinced of what they saw. The shows started under the "); 55 | writer.WriteLine("guise of actual séances in Germany in the late 18th century, and gained popularity through most of Europe (including Britain) "); 56 | writer.WriteLine("throughout the 19th century."); 57 | } 58 | 59 | 60 | // Create a directory called license and write a file to it. 61 | S3DirectoryInfo licensesDir = rootDirectory.CreateSubdirectory("licenses"); 62 | S3FileInfo licenseFile = licensesDir.GetFile("license.txt"); 63 | using (StreamWriter writer = new StreamWriter(licenseFile.OpenWrite())) 64 | writer.WriteLine("A license to code"); 65 | 66 | 67 | Console.WriteLine("Write Directory Structure"); 68 | Console.WriteLine("------------------------------------"); 69 | WriteDirectoryStructure(rootDirectory, 0); 70 | 71 | 72 | Console.WriteLine("\n\n"); 73 | foreach (var file in codeDir.GetFiles()) 74 | { 75 | Console.WriteLine("Content of {0}", file.Name); 76 | Console.WriteLine("------------------------------------"); 77 | using (StreamReader reader = file.OpenText()) 78 | { 79 | Console.WriteLine(reader.ReadToEnd()); 80 | } 81 | } 82 | 83 | // Deletes all the files and then the bucket. 84 | if(deleteAtEnd) 85 | rootDirectory.Delete(true); 86 | } 87 | } 88 | 89 | Console.WriteLine("Press any key to continue..."); 90 | Console.ReadKey(); 91 | } 92 | 93 | static void WriteDirectoryStructure(S3DirectoryInfo directory, int level) 94 | { 95 | StringBuilder indentation = new StringBuilder(); 96 | for (int i = 0; i < level; i++) 97 | indentation.Append("\t"); 98 | 99 | Console.WriteLine("{0}{1}", indentation, directory.Name); 100 | foreach (var file in directory.GetFiles()) 101 | Console.WriteLine("\t{0}{1}", indentation, file.Name); 102 | 103 | foreach (var subDirectory in directory.GetDirectories()) 104 | { 105 | WriteDirectoryStructure(subDirectory, level + 1); 106 | } 107 | } 108 | 109 | static bool checkRequiredFields() 110 | { 111 | NameValueCollection appConfig = ConfigurationManager.AppSettings; 112 | 113 | if (string.IsNullOrEmpty(appConfig["AWSProfileName"])) 114 | { 115 | Console.WriteLine("AWSProfileName was not set in the App.config file."); 116 | return false; 117 | } 118 | if (string.IsNullOrEmpty(bucketName)) 119 | { 120 | Console.WriteLine("The variable bucketName is not set."); 121 | return false; 122 | } 123 | 124 | return true; 125 | } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /Storage/S3TrasferUtility/S3TrasferUtility.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "S3TrasferUtility", "S3TrasferUtility\S3TrasferUtility.csproj", "{2A2686BA-E210-4BF8-AD53-55AD7761E900}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {2A2686BA-E210-4BF8-AD53-55AD7761E900}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {2A2686BA-E210-4BF8-AD53-55AD7761E900}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {2A2686BA-E210-4BF8-AD53-55AD7761E900}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {2A2686BA-E210-4BF8-AD53-55AD7761E900}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {5F82C966-8DC9-4972-B22F-E6C6747F05CB} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Storage/S3TrasferUtility/S3TrasferUtility/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Storage/S3TrasferUtility/S3TrasferUtility/S3TrasferUtility.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net45 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | --------------------------------------------------------------------------------