enable/ disable aws lambda triggers(rules) using boto3 and python
- python 3.8.x
- Install boto3 into the toggle-lambda-events function
pip install --target={{path_to_toggle-lambda-events}} boto3
eg:
pip install --target=D:\vishnu_personal\projects\rf\toggle-lambda-events boto3
- Zip the the files including the packages
- toggle-lambda-events.zip
- bin
- boto3
- boto3-1.17.3.dist-info
- .
- .
- .
- lambda_function.py
-
Specify the following env variables in the lambda environment variables
- aws_access_key_id
- aws_secret_access_key
- region_name
-
Upload the zipfile to the respective lambda function
Assuming a succesfull api gateway has been setup for the lambda
Using the entry point perform a POST request with the following JSON format as body
{
"rules": [
{
"name": "<rule name | str>",
"status": <status | bool | 0-disable 1-enable>
}
]
}
eg:
{
"rules": [
{
"name": "rule-1",
"status": 0
},
{
"name": "rule-2",
"status": 1
}
]
}