The CDK Construct Library for AWS::Config
Project description
AWS Config Construct Library
This is a developer preview (public beta) module. Releases might lack important features and might have future breaking changes.
This API is still under active development and subject to non-backward compatible changes or removal in any future version. Use of the API is not recommended in production environments. Experimental APIs are not subject to the Semantic Versioning model.
This module is part of the AWS Cloud Development Kit project.
Supported:
- Config rules
Not supported
- Configuration recoder
- Delivery channel
- Aggregation
Rules
AWS managed rules
To set up a managed rule, define a ManagedRule and specify its identifier:
new ManagedRule(this, 'AccessKeysRotated', {
identifier: 'ACCESS_KEYS_ROTATED'
});
Available identifiers and parameters are listed in the List of AWS Config Managed Rules.
Higher level constructs for managed rules are available, see Managed Rules. Prefer to use those constructs when available (PRs welcome to add more of those).
Custom rules
To set up a custom rule, define a CustomRule and specify the Lambda Function to run and the trigger types:
new CustomRule(this, 'CustomRule', {
lambdaFunction: myFn,
configurationChanges: true,
periodic: true
});
Restricting the scope
By default rules are triggered by changes to all resources. Use the scopeToResource(), scopeToResources() or scopeToTag() methods to restrict the scope of both managed and custom rules:
const sshRule = new ManagedRule(this, 'SSH', {
identifier: 'INCOMING_SSH_DISABLED'
});
// Restrict to a specific security group
rule.scopeToResource('AWS::EC2::SecurityGroup', 'sg-1234567890abcdefgh');
const customRule = new CustomRule(this, 'CustomRule', {
lambdaFunction: myFn,
configurationChanges: true
});
// Restrict to a specific tag
customRule.scopeToTag('Cost Center', 'MyApp');
Only one type of scope restriction can be added to a rule (the last call to scopeToXxx() sets the scope).
Events
To define Amazon CloudWatch event rules, use the onComplianceChange() or onReEvaluationStatus() methods:
const rule = new CloudFormationStackDriftDetectionCheck(this, 'Drift');
rule.onComplianceChange('TopicEvent', {
target: new targets.SnsTopic(topic))
});
Example
Creating custom and managed rules with scope restriction and events:
// A custom rule that runs on configuration changes of EC2 instances
const fn = new lambda.Function(this, 'CustomFunction', {
code: lambda.AssetCode.inline('exports.handler = (event) => console.log(event);'),
handler: 'index.handler',
runtime: lambda.Runtime.Nodejs810
});
const customRule = new config.CustomRule(this, 'Custom', {
configurationChanges: true,
lambdaFunction: fn
});
customRule.scopeToResource('AWS::EC2::Instance');
// A rule to detect stacks drifts
const driftRule = new config.CloudFormationStackDriftDetectionCheck(this, 'Drift');
// Topic for compliance events
const complianceTopic = new sns.Topic(this, 'ComplianceTopic');
// Send notification on compliance change
driftRule.onComplianceChange('ComplianceChange', {
target: new targets.SnsTopic(complianceTopic)
});
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 aws-cdk.aws-config-0.35.0.tar.gz.
File metadata
- Download URL: aws-cdk.aws-config-0.35.0.tar.gz
- Upload date:
- Size: 71.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54379a32105b1866fd578bc7ad7c27e3142160bddbc2b706caf46aa723f0a3fc
|
|
| MD5 |
7ce8848794c01200efb43beada547f2c
|
|
| BLAKE2b-256 |
874e056f5c12691cd1278856a16d6dba1b51f8b622d7ef4c6b80bd4a98609f61
|
File details
Details for the file aws_cdk.aws_config-0.35.0-py3-none-any.whl.
File metadata
- Download URL: aws_cdk.aws_config-0.35.0-py3-none-any.whl
- Upload date:
- Size: 67.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97acd221ed5461b5f2f7d7c31b1f3068e529de3a617080e0950deef299b06165
|
|
| MD5 |
7a1b80a4dbda1f8db291f3baaa0d33dd
|
|
| BLAKE2b-256 |
682add355e64a6d147fe39a851eefa88635ef1b54b5cb0f2dba37d786bdd226d
|