{"id":44451787,"url":"https://github.com/thebeebs/aws-lambda-chaos-injection-dotnet","last_synced_at":"2026-02-12T16:34:32.088Z","repository":{"id":40873831,"uuid":"265682314","full_name":"thebeebs/aws-lambda-chaos-injection-dotnet","owner":"thebeebs","description":"Chaos Injection library for AWS Lambda","archived":false,"fork":false,"pushed_at":"2022-12-08T04:39:01.000Z","size":61,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-20T04:08:28.191Z","etag":null,"topics":["aws","aws-lambda","chaos-engineering","csharp","dotnet-standard","dotnetcore"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/LambdaChaosInjection/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thebeebs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-20T20:45:47.000Z","updated_at":"2021-03-12T12:09:26.000Z","dependencies_parsed_at":"2023-01-24T11:15:34.706Z","dependency_job_id":null,"html_url":"https://github.com/thebeebs/aws-lambda-chaos-injection-dotnet","commit_stats":null,"previous_names":["thebeebs/lambdachaosinjection"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/thebeebs/aws-lambda-chaos-injection-dotnet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebeebs%2Faws-lambda-chaos-injection-dotnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebeebs%2Faws-lambda-chaos-injection-dotnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebeebs%2Faws-lambda-chaos-injection-dotnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebeebs%2Faws-lambda-chaos-injection-dotnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thebeebs","download_url":"https://codeload.github.com/thebeebs/aws-lambda-chaos-injection-dotnet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebeebs%2Faws-lambda-chaos-injection-dotnet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29372182,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T08:51:36.827Z","status":"ssl_error","status_checked_at":"2026-02-12T08:51:26.849Z","response_time":55,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-lambda","chaos-engineering","csharp","dotnet-standard","dotnetcore"],"created_at":"2026-02-12T16:34:32.013Z","updated_at":"2026-02-12T16:34:32.078Z","avatar_url":"https://github.com/thebeebs.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"![build and test](https://github.com/thebeebs/LambdaChaosInjection/workflows/build%20and%20test/badge.svg)\n\n# Chaos Injection for AWS Lambda - ChaosLambdaInjection\n\nChaosLambdaInjection is a small library injecting chaos into AWS Lambda. \nIt offers simple decorators to do delay, exception and statusCode injection \nand some methods to add delay to any 3rd party dependencies called from your function. \nThis allows to conduct small chaos engineering experiments \nfor your serverless application in the AWS Cloud.\n\n- Support for Latency injection using delay\n- Support for Exception injection using exception_msg\n- Support for HTTP Error status code injection using error_code\n- Using for SSM Parameter Store to control the experiment using isEnabled\n- Support for adding rate of failure using rate. (Default rate = 1)\n- Per Lambda function injection control using Environment variable (CHAOS_PARAM)\n\n## Install\n```bash\ndotnet add package LambdaChaosInjection --version 0.1.2\n```\n\n## Example\nWe can add a decorator to a function to inject a chaos policy\n```csharp\n[InjectDelayPolicy]\npublic async Task\u003cAPIGatewayProxyResponse\u003e FunctionHandler(APIGatewayProxyRequest apigProxyEvent, ILambdaContext context)\n{\n    var location = await GetCallingIP();\n    var body = new Dictionary\u003cstring, string\u003e\n    {\n        {\"message\", \"hello world\"},\n        {\"location\", location}\n    };\n\n    return new APIGatewayProxyResponse\n    {\n        Body = JsonConvert.SerializeObject(body),\n        StatusCode = 200,\n        Headers = new Dictionary\u003cstring, string\u003e {{\"Content-Type\", \"application/json\"}}\n    };\n}\n```\nAlternatively you can wrap a portion of code in a ChaosWrap. \nThis is ultimately what the decorator is doing anyway and I suspect \nthat is slightly better in terms of performance.   \n\n```csharp\npublic async Task\u003cAPIGatewayProxyResponse\u003e FunctionHandlerException(APIGatewayProxyRequest apigProxyEvent, ILambdaContext context)\n{\n    return await new ChaosWrap\u003cInjectException\u003e().Execute(async () =\u003e\n        {\n            var location = await GetCallingIP();\n            var body = new Dictionary\u003cstring, string\u003e\n            {\n                {\"message\", \"hello world\"},\n                {\"location\", location}\n            };\n\n            return new APIGatewayProxyResponse\n            {\n                Body = JsonConvert.SerializeObject(body),\n                StatusCode = 200,\n                Headers = new Dictionary\u003cstring, string\u003e {{\"Content-Type\", \"application/json\"}}\n            };\n        }\n    );\n}\n```\n\n## Configuration\nThe configuration for the failure injection is stored in the [AWS SSM Parameter Store](https://aws.amazon.com/ssm/):\n```\n{\n    \"isEnabled\": true,\n    \"delay\": 400,\n    \"error_code\": 404,\n    \"exception_msg\": \"I really failed seriously\",\n    \"rate\": 1\n}\n```\nTo store the above configuration into SSM using the AWS CLI do the following:\n\n```bash\naws ssm put-parameter --region eu-north-1 --name chaoslambda.config --type String --overwrite --value \"{ \"delay\": 400, \"isEnabled\": true, \"error_code\": 404, \"exception_msg\": \"I really failed seriously\", \"rate\": 1 }\"\n```\n\nAWS Lambda will need to have [IAM access to SSM](https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-paramstore-access.html).\n```\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"ssm:DescribeParameters\"\n            ],\n            \"Resource\": \"*\"\n        },\n        {\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"ssm:GetParameters\",\n                \"ssm:GetParameter\"\n            ],\n            \"Resource\": \"arn:aws:ssm:eu-north-1:12345678910:parameter/chaoslambda.config\"\n        }\n    ]\n}\n```\n## Supported Decorators:\n   ChaosLambdaInjection currently supports the following decorators:\n   \n- [InjectDelay] - add delay in the AWS Lambda execution\n- [InjectException] - Raise an exception during the AWS Lambda execution\n- [InjectStatusCode] - force AWS Lambda to return a specific HTTP error code\n\n## Project Files\n\nThis project contains source code and supporting files for the LamdaChaosInjection Nuget package.\n\n## Unit tests\n\nTests are defined in the `Tests` folder in this project.\n\n```bash\ndotnet test Tests\n```\n\n- Samples - Code for two sample Lambda functions that use Chaos Injection.\n- test - Unit tests for the LambdaChaosInjection project. \n- template.yaml - A template that defines the application's AWS resources should you wish to deploy the sample functions to your AWS account.\n\nThe application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the `template.yaml` file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code.\n\nIf you prefer to use an integrated development environment (IDE) to build and test your application, you can use the AWS Toolkit.  \nThe AWS Toolkit is an open source plug-in for popular IDEs that uses the SAM CLI to build and deploy serverless applications on AWS. The AWS Toolkit also adds a simplified step-through debugging experience for Lambda function code. See the following links to get started.\n\n* [Rider](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)\n* [VS Code](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/welcome.html)\n* [Visual Studio](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/welcome.html)\n\n## Deploy the sample application\n\nThe Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. It can also emulate your application's build environment and API.\n\nTo use the SAM CLI, you need the following tools.\n\n* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)\n* .NET Core - [Install .NET Core](https://www.microsoft.com/net/download)\n* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition\u0026offering=community)\n\nTo build and deploy your application for the first time, run the following in your shell:\n\n```bash\nsam build\nsam deploy --guided\n```\n\nThe first command will build the source of your application. The second command will package and deploy your application to AWS, with a series of prompts:\n\n* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name.\n* **AWS Region**: The AWS region you want to deploy your app to.\n* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes.\n* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modified IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command.\n* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application.\n\nYou can find your API Gateway Endpoint URL in the output values displayed after deployment.\n\n## Use the SAM CLI to build and test locally\n\nBuild your application with the `sam build` command.\n\n```bash\nsam build\n```\n\nThe SAM CLI installs dependencies defined in `src/HelloWorld.csproj`, creates a deployment package, and saves it in the `.aws-sam/build` folder.\n\nTest a single function by invoking it directly with a test event. An event is a JSON document that represents the input that the function receives from the event source. Test events are included in the `events` folder in this project.\n\nRun functions locally and invoke them with the `sam local invoke` command.\n\n```bash\nsam local invoke HelloWorldFunction --event events/event.json\n```\n\nThe SAM CLI can also emulate your application's API. Use the `sam local start-api` to run the API locally on port 3000.\n\n```bash\nsam local start-api\ncurl http://localhost:3000/\n```\n\nThe SAM CLI reads the application template to determine the API's routes and the functions that they invoke. The `Events` property on each function's definition includes the route and method for each path.\n\n```yaml\n      Events:\n        HelloWorld:\n          Type: Api\n          Properties:\n            Path: /hello\n            Method: get\n```\n\n## Add a resource to your application\nThe application template uses AWS Serverless Application Model (AWS SAM) to define application resources. AWS SAM is an extension of AWS CloudFormation with a simpler syntax for configuring common serverless application resources such as functions, triggers, and APIs. For resources not included in [the SAM specification](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md), you can use standard [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html) resource types.\n\n## Fetch, tail, and filter Lambda function logs\n\nTo simplify troubleshooting, SAM CLI has a command called `sam logs`. `sam logs` lets you fetch logs generated by your deployed Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug.\n\n`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using SAM.\n\n```bash\nsam logs -n HelloWorldFunction --stack-name AWS --tail\n```\n\nYou can find more information and examples about filtering Lambda function logs in the [SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html).\n\n\n## Cleanup\n\nTo delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following:\n\n```bash\naws cloudformation delete-stack --stack-name AWS\n```\n\n## Resources\n\nSee the [AWS SAM developer guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) for an introduction to SAM specification, the SAM CLI, and serverless application concepts.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthebeebs%2Faws-lambda-chaos-injection-dotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthebeebs%2Faws-lambda-chaos-injection-dotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthebeebs%2Faws-lambda-chaos-injection-dotnet/lists"}