- Le plus récent
- Le plus de votes
- La plupart des commentaires
Consider AWS Cloud Development Kit (CDK) for this, as it supports the C# programming language. CDK helps you concentrate on your resources by automatically implementing some aspects such as adding IAM permissions and defining the dependencies. AWS CDK synthesizes a CloudFormation template as a final step, so you don't have to write it manually. The CLI tool can also deploy the synthesized CloudFormation stack for you so you don't even have to care about uploading assets used in your stack - this will be done for you.
In this GitHub repository, you can find some examples of CDK projects demonstrating the usage and the project structure - for various programming languages, including C#.
For example, the RandomWriter project shows you how to configure an EventBridge rule, a Lambda function, and a DynamoDB table, including required IAM permissions.
The LambdaCron example is a tiny one but also shows you how to connect a Lambda function to an EventBridge rule.
Creating a custom EventBus can also be done very easily. Here's a code snippet to give you an idea how to do that. Note that all the required (basic) IAM permissions will be automatically created and attached by CDK for you.
using Amazon.CDK.AWS.Events; using Amazon.CDK.AWS.Lambda; using Targets = Amazon.CDK.AWS.Events.Targets; // adding a Python function as an example here, // but you can also use C# for the Lambda code for sure var myLambda = new Function(this, "MyEventProcessor", new FunctionProps { Code = new InlineCode("def main(event, context):\n\tprint(event)\n\treturn {'statusCode': 200, 'body': 'Hello, World'}"), Handler = "index.main", Runtime = Runtime.PYTHON_3_7 }); // a custom event bus var eventBus = new EventBus(this, "MyLanguageBus"); // an EventBridge rule attached to the custom event bus new Rule(this, "LambdaProcessorRule", new RuleProps { EventBus = eventBus, EventPattern = new EventPattern { Source = new[] { "com.amazon.alexa.english" } }, Targets = new[] { new Targets.LambdaFunction(myLambda) } });
Contenus pertinents
- demandé il y a un an
- demandé il y a un an
- AWS OFFICIELA mis à jour il y a 3 mois
- AWS OFFICIELA mis à jour il y a 10 mois
- AWS OFFICIELA mis à jour il y a 4 mois