AWS Config
Ahh got it โ you're asking about AWS Config, the service โ not the CLI command aws configure.
๐ What is AWS Config?¶
AWS Config is a service that monitors, records, and evaluates the configurations of your AWS resources. It helps you track resource changes and check compliance with rules over time.
๐งฐ Use Cases¶
-
Auditing and compliance
-
Security analysis
-
Resource change tracking
-
Operational troubleshooting
๐ง How AWS Config Works¶
-
Recorder: Tracks changes in selected resources.
-
Delivery Channel: Sends logs to an S3 bucket.
-
Rules (optional): Validate resource compliance using AWS-managed or custom rules.
-
Aggregator (optional): Collects data across accounts and regions.
๐ฆ Example Setup via Console or CLI¶
Let's set up AWS Config with:
-
Resource recording for all resources
-
Delivery to an S3 bucket (
aws-config-logs-bucket) -
Optional SNS topic for notifications
-
One AWS-managed rule (
s3-bucket-public-read-prohibited)
๐ป CLI Setup Example¶
# 1. Create an S3 bucket for storing config logs
aws s3 mb s3://aws-config-logs-bucket
# 2. Create an IAM Role for AWS Config (skip if already done)
aws iam create-role --role-name AWSConfigRole \
--assume-role-policy-document file://trust-policy.json
# trust-policy.json should contain:
# {
# "Version": "2012-10-17",
# "Statement": [{
# "Effect": "Allow",
# "Principal": { "Service": "config.amazonaws.com" },
# "Action": "sts:AssumeRole"
# }]
# }
# Attach required policy to the role
aws iam attach-role-policy --role-name AWSConfigRole \
--policy-arn arn:aws:iam::aws:policy/service-role/AWSConfigRole
# 3. Set up the delivery channel
aws configservice put-delivery-channel \
--delivery-channel-name default \
--s3-bucket-name aws-config-logs-bucket
# 4. Start the configuration recorder
aws configservice start-configuration-recorder \
--configuration-recorder-name default \
--role-arn arn:aws:iam::<ACCOUNT_ID>:role/AWSConfigRole
# 5. (Optional) Add a managed AWS Config rule
aws configservice put-config-rule \
--config-rule file://s3-rule.json
# s3-rule.json:
# {
# "ConfigRuleName": "s3-bucket-public-read-prohibited",
# "Source": {
# "Owner": "AWS",
# "SourceIdentifier": "S3_BUCKET_PUBLIC_READ_PROHIBITED"
# }
# }
๐ After Setup¶
-
Go to AWS Config Console to view:
-
Timeline of resource changes
-
Compliance reports
-
Rule violations
-
-
You can set up SNS notifications for alerts
๐ AWS Config Setup โ Full Guide (Console + CLI)¶
๐ฅ๏ธ 1. Console Method (Step-by-step)¶
โ Prerequisites:¶
-
IAM permissions to create roles and use AWS Config
-
An S3 bucket (you can create it during the process)
๐งญ Steps:¶
-
Go to AWS Config Console
-
Navigate to AWS Console > AWS Config.
-
Click โGet startedโ if itโs your first time.
-
-
Specify resource recording
-
Select Record all resources supported in this region (recommended).
-
Or choose specific resource types.
-
-
Create or choose an S3 bucket
-
Use โCreate a bucketโ or select an existing bucket (e.g.,
aws-config-logs-bucket). -
This is where AWS Config stores configuration snapshots and compliance results.
-
-
Set up an IAM role
-
Choose โCreate AWS Config service-linked roleโ (easiest option).
-
Or specify your custom IAM role.
-
-
Set up an SNS topic (optional)
-
For receiving notifications (e.g., compliance changes).
-
You can skip this for basic setup.
-
-
Enable AWS Config Rules (Optional)
-
Choose AWS managed rules, like:
-
s3-bucket-public-read-prohibited -
ec2-instance-no-public-ip
-
-
Or skip for now and add rules later.
-
-
Review and confirm
- Review your settings and click โConfirmโ.
๐ Result:¶
-
AWS Config starts recording resource changes.
-
Sends logs to S3.
-
Evaluates rules (if configured).
๐ป 2. CLI Method (Quick Recap with Example)¶
โ Prerequisites:¶
-
AWS CLI installed & configured
-
S3 bucket (e.g.,
aws-config-logs-bucket) -
IAM role with
AWSConfigRolepolicy
# Create a delivery channel
aws configservice put-delivery-channel \
--delivery-channel-name default \
--s3-bucket-name aws-config-logs-bucket
# Start the configuration recorder
aws configservice start-configuration-recorder \
--configuration-recorder-name default \
--role-arn arn:aws:iam::<ACCOUNT_ID>:role/AWSConfigRole
# Add a managed AWS Config rule (e.g., block public S3 buckets)
aws configservice put-config-rule \
--config-rule file://s3-rule.json
Example s3-rule.json:
{
"ConfigRuleName": "s3-bucket-public-read-prohibited",
"Source": {
"Owner": "AWS",
"SourceIdentifier": "S3_BUCKET_PUBLIC_READ_PROHIBITED"
}
}
๐ฏ Common Managed Rules Examples¶
| Rule Name | Description |
|---|---|
S3_BUCKET_PUBLIC_READ_PROHIBITED |
Ensures S3 buckets aren't publicly readable |
EC2_INSTANCE_NO_PUBLIC_IP |
Ensures EC2s don't have public IPs |
ENCRYPTED_VOLUMES |
Checks if EBS volumes are encrypted |
IAM_PASSWORD_POLICY |
Validates strong IAM password policies |