Rule Development Kit Library for AWS Config
Project description
RDKlib
RDKlib is a Python library to enable you to run custom AWS Config Rules at scale. The library can be used to:
- Help you to focus only on the compliance logic, while the library does the heavy lifting
- Ease maintenance by moving the boilerplate code as a AWS Lambda Layer
- Ease deployment by using AWS Serverless Application Repository
RDKLib works in synergy with the AWS Config Rule Development Kit.
Getting Started
Install the library locally
pip install rdklib
Create a rule using the RDK
Note: you need to install the RDK first.
To use rdklib, specify a python3.x-lib runtime when you run rdk create (or don't specify any runtime; rdklib is now the default for rdk create). This will populate the rdklib runtime in the RDK parameters.json of your Rule template. Examples:
- For periodic trigger:
rdk create YOUR_RULE_NAME --runtime python3.12-lib --maximum-frequency TwentyFour_Hours
- For configuration change trigger (for example S3 Bucket):
rdk create YOUR_RULE_NAME --runtime python3.12-lib --resource-types AWS::S3::Bucket
After you've created your rule, update the .py file that was generated, adding your custom logic within the evaluate_change() method for change-triggered rules or the evaluate_periodic() method for periodic rules (you may need to uncomment evaluate_periodic(). If you need to create a boto3 client, use the client_factory helper (eg. instead of boto3.client("s3"), use client_factory.build_client("s3")). Examples of rdklib rules can be found here.
Deploy your rule with RDKlib layer
RDKlib is designed to work as a AWS Lambda Layer. It allows you to use the library without needing to include it in your deployment package.
- Install RDKlib layer (with AWS CLI)
aws serverlessrepo create-cloud-formation-change-set --application-id arn:aws:serverlessrepo:ap-southeast-1:711761543063:applications/rdklib --stack-name RDKlib-Layer
# Copy/paste the full change-set ARN to customize the following command
aws cloudformation execute-change-set --change-set-name NAME_OF_THE_CHANGE_SET
aws cloudformation describe-stack-resources --stack-name serverlessrepo-RDKlib-Layer
# Copy the ARN of the Lambda layer in the "PhysicalResourceId" key (i.e. arn:aws:lambda:YOUR_REGION:YOUR_ACCOUNT:layer:rdklib-layer:1).
Note: You can do the same step manually going to https://console.aws.amazon.com/lambda/home#/create/function?tab=serverlessApps and find "rdklib"
- Deploy the rule
rdk deploy YOUR_RULE_NAME --rdklib-layer-arn YOUR_RDKLIB_LAYER_ARN
FAQs
- Q. What is the
client_factorythat I see in myrdklibrules?- A. A
client_factoryis a class that allows for dynamic provisioning of aboto3client. In anrdklibrule, you should treatclient_factoryas the way to create aboto3client. So instead of callingclient = boto3.client("s3"), you would callclient = client_factory.build_client("s3").- Q. ...Why?
- A. It's mainly there to allow for cross-account functionality so that your client evaluates the rule in the right account.
- Q. ...Why?
- A. A
License
This project is licensed under the Apache-2.0 License.
Feedback / Questions
Feel free to email rdk-maintainers@amazon.com
Contacts
- Benjamin Morris - Maintainer, code, testing
Acknowledgements
- Mark Beacom - Maintainer, code, testing
- Michael Borchert - Design, code, testing, feedback
- Ricky Chau - Maintainer, code, testing
- Julio Delgado Jr. - Design, testing, feedback
- Chris Gutierrez - Design, feedback
- Joe Lee - Design, feedback
- Jonathan Rault - Maintainer, design, code, testing, feedback
- Carlo DePaolis - Maintainer, code, testing
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rdklib-0.3.10.tar.gz.
File metadata
- Download URL: rdklib-0.3.10.tar.gz
- Upload date:
- Size: 15.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.2 CPython/3.13.12 Linux/6.14.0-1017-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70263c5039e55e5d282e776822467789cdfa68c375d503f76eb1bb71d6f4cfa8
|
|
| MD5 |
e517b9a44f929f225640e85cba50851d
|
|
| BLAKE2b-256 |
05667530e5cbdd24b7c505ce1b6e0bf35ddd8e4616ec6d5ec66630a8912d0e09
|
File details
Details for the file rdklib-0.3.10-py3-none-any.whl.
File metadata
- Download URL: rdklib-0.3.10-py3-none-any.whl
- Upload date:
- Size: 19.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.2 CPython/3.13.12 Linux/6.14.0-1017-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f37b81aec12965062717b2a389f2b3cc361cc003d4d40195163f611b438f589
|
|
| MD5 |
3ba0f3d322d6f6dc383ec03939483203
|
|
| BLAKE2b-256 |
9e1c5cbddef2f775f06c2681e843a6939d67f422ca310c3ecded06eaa2991f0d
|