Skip to main content

Lambda delete event source mapping

Lambda delete event source mapping removes the event source mapping from an AWS Lambda function for a specific duration.

  • It checks the performance of the application (or service) without the event source mapping which may cause missing entries in a database.

Lambda Delete Event Source Mapping

Usage

View fault usage
Deleting an event source mapping from a Lambda function is critical. It can lead to scenarios such as failure to update the database on an event trigger, which can break the service. Such faults determine if proper error handling or auto recovery options have been configured for the application.

Prerequisites

  • Kubernetes >= 1.17
  • AWS Lambda event source mapping attached to the lambda function.
  • Kubernetes secret that has AWS access configuration(key) in the CHAOS_NAMESPACE. A secret file looks like this:
apiVersion: v1
kind: Secret
metadata:
name: cloud-secret
type: Opaque
stringData:
cloud_config.yml: |-
# Add the cloud AWS credentials respectively
[default]
aws_access_key_id = XXXXXXXXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXXXXX
  • If you change the secret key name (from cloud_config.yml), update the AWS_SHARED_CREDENTIALS_FILE environment variable value on experiment.yaml with the same name.

Permissions required

Here is an example AWS policy to execute the fault.

View policy for the fault
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"lambda:ListEventSourceMappings",
"lambda:DeleteEventSourceMapping",
"lambda:UpdateEventSourceMapping",
"lambda:CreateEventSourceMapping",
"lambda:UpdateFunctionConfiguration",
"lambda:GetFunctionConcurrency",
"lambda:GetFunction",
"lambda:DeleteFunctionConcurrency",
"lambda:PutFunctionConcurrency"
],
"Resource": "*"
}
]
}

Refer to the superset permission/policy to execute all AWS faults.

Default validations

The AWS Lambda event source mapping is healthy and attached to the lambda function.

Fault tunables

Fault tunables

Mandatory fields

Variables Description Notes
FUNCTION_NAME Function name of the target lambda function. It supports single function name. For example, test-function
EVENT_UUIDS Provide the UUID for the target event source mapping. You can provide multiple values as (,) comma-separated values. For example, id1,id2
REGION The region name of the target lambda function For example, us-east-2

Optional fields

Variables Description Notes
TOTAL_CHAOS_DURATION The total time duration for chaos insertion in seconds Defaults to 30s
SEQUENCE It defines sequence of chaos execution for multiple instance Default value: parallel. Supported: serial, parallel
RAMP_TIME Period to wait before and after injection of chaos in sec For example, 30

Fault Examples

Common and AWS-specific tunables

Refer to the common attributes and AWS-specific tunables to tune the common tunables for all faults and aws specific tunables.

Multiple Event Source Mapping

It can delete multiple event source mappings for a certain chaos duration using EVENT_UUIDS environment variable that takes the UUID of the events as a comma-separated value (CSV file).

Use the following example to tune it:

# contains the removal of multiple event source mapping
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
chaosServiceAccount: litmus-admin
experiments:
- name: lambda-delete-event-source-mapping
spec:
components:
env:
# provide UUIDS of event source mapping
- name: EVENT_UUIDS
value: 'id1,id2'
# provide the function name for the chaos
- name: FUNCTION_NAME
value: 'chaos-function'