Sub topic 12
Verifying your side with AWS Config and related services
This chapter assumes you know the split between security of the cloud and security in the cloud. It also assumes you can read a short AWS CLI command and know the basics of IAM, S3, and EC2. Earlier chapters covered what you must configure for identity, data, and network. This chapter covers how to prove you did it, and how to notice when it stops being true.
Why verification belongs to you
AWS runs the facilities, hardware, and virtualization layer, and it publishes audit reports that cover them. Nothing in that work checks whether your bucket is public, your volumes are encrypted, or your security groups are open. Those are configuration choices on your side of the line, and they change every time someone deploys, edits, or clicks in the console.
Verification therefore has to be continuous. A review done at launch tells you only that the workload was correct on that day. The services below let you ask the same questions repeatedly, and they record the answers.
The main verification services
Each service answers a different question. Using them together gives you coverage that none provides alone.
| Service | Question it answers | Typical output |
|---|---|---|
| AWS Config | What is the configuration of my resources, and does it match my rules? | Configuration history, compliance status per rule |
| AWS CloudTrail | Who called which API, and when? | Event records of API activity |
| IAM Access Analyzer | Which resources are shared outside my account or organization? | Findings about external or unused access |
| AWS Security Hub | What is my overall posture across checks and services? | Aggregated findings and security scores |
| Amazon GuardDuty | Is something suspicious happening right now? | Threat findings |
| AWS Trusted Advisor | Are there obvious gaps in security and other best practices? | Check results and recommendations |
Config and Security Hub check state. CloudTrail records actions. GuardDuty looks for behavior. Access Analyzer reasons about policies. Keep these roles distinct and you will know which tool to open for a given question.
How AWS Config works
AWS Config has three parts that you need to understand.
- A configuration recorder watches supported resource types in a Region and stores a configuration item each time one changes. The history of these items is what lets you answer "what did this security group look like last Tuesday?"
- A delivery channel sends configuration snapshots and history to an S3 bucket, and can notify an SNS topic.
- Config rules evaluate recorded configuration items against a condition and mark each resource COMPLIANT or NON_COMPLIANT.
Config is Regional. A recorder in us-east-1 does not see resources in eu-west-1. To cover an organization, you enable it in each account and Region you use, or use an aggregator to view results from many accounts and Regions in one place. An aggregator only reads; it does not turn on recording in the source accounts.
Managed rules and custom rules
AWS provides managed rules for common checks. Examples that map directly to your duties include:
s3-bucket-public-read-prohibitedands3-bucket-public-write-prohibitedfor public access.encrypted-volumesfor EBS encryption.restricted-sshfor security groups that allow SSH from anywhere.iam-user-mfa-enabledandroot-account-mfa-enabledfor authentication.rds-storage-encryptedfor database encryption.
When no managed rule fits, you write a custom rule backed by a Lambda function, or use AWS CloudFormation Guard with a custom policy rule. Prefer managed rules first, because AWS maintains them.
Rules run on one of two triggers. A configuration change trigger evaluates a resource when it changes. A periodic trigger evaluates at a fixed interval, such as every 24 hours. Rules that depend on something other than resource state, such as password age, need periodic evaluation.
Checking your side from the CLI
The Topic Spine's three commands each verify one of your duties. Start with S3. This command turns on all four Block Public Access settings for one bucket, because whether a bucket is public is your configuration choice.
aws s3api put-public-access-block \
--bucket amzn-s3-demo-bucket \
--public-access-block-configuration \
BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=trueTo confirm the result instead of assuming it, read the setting back.
aws s3api get-public-access-block --bucket amzn-s3-demo-bucketNext, encryption. AWS supplies the encryption capability and key infrastructure, but you decide to use it. This command makes new EBS volumes in the Region encrypted by default, and the second line confirms the setting.
aws ec2 enable-ebs-encryption-by-default --region us-east-1
aws ec2 get-ebs-encryption-by-default --region us-east-1Two edge cases matter here. The setting is per Region, so you must repeat it in every Region you use. It also applies only to volumes created after you enable it. Existing unencrypted volumes stay unencrypted until you copy or recreate them from an encrypted snapshot.
Finally, ask Config which rules currently report problems.
aws configservice describe-compliance-by-config-rule \
--compliance-types NON_COMPLIANTAn empty result can mean two different things: everything passes, or no rules exist. Before trusting an empty list, confirm that rules are deployed.
aws configservice describe-config-rules \
--query "ConfigRules[].ConfigRuleName"To see which specific resources fail a rule, drill down.
aws configservice get-compliance-details-by-config-rule \
--config-rule-name encrypted-volumes \
--compliance-types NON_COMPLIANTReading the other signals
CloudTrail
CloudTrail records management events, such as PutBucketPolicy or AuthorizeSecurityGroupIngress, along with who made the call. When Config tells you a security group became non-compliant, CloudTrail tells you which principal changed it. Create a trail that applies to all Regions and delivers to a bucket with log file validation turned on, so you can detect tampering. Data events, such as S3 object-level reads, are off by default and cost extra, so enable them deliberately for sensitive buckets.
IAM Access Analyzer
Access Analyzer evaluates resource policies and reports resources that grant access to principals outside your zone of trust, which is the account or organization you choose. It finds things like an S3 bucket policy that allows another account, or a KMS key shared externally. It can also report unused permissions and roles, which supports least privilege.
Security Hub and GuardDuty
Security Hub runs checks against standards such as the AWS Foundational Security Best Practices and collects findings from other services into one view. Many of its checks rely on AWS Config, so Config recording must be enabled for Security Hub to work well. GuardDuty is different. It analyzes CloudTrail events, VPC flow logs, and DNS logs for suspicious activity, so it detects problems that configuration checks cannot, such as credentials used from an unusual location.
Common failure modes
- Compliant is not secure. A rule checks one condition.
encrypted-volumespassing says nothing about who can use the key. - Evaluation lag. Change-triggered rules run after the change is recorded, so a short window exists where a bad configuration is live. Detection is not prevention.
- Alert fatigue. Hundreds of findings with no owner get ignored. Route each rule to a named owner.
- Config does not see inside your workload. It records resource configuration. It does not scan operating system patches on your EC2 instances or application vulnerabilities. Those need tools such as Amazon Inspector.
- Cost surprises. Config charges per configuration item recorded and per rule evaluation. Recording every resource type in every Region adds up, so scope it to what you need.
Detect versus prevent
Verification tools detect. To prevent, add controls that block the change itself. Service control policies in AWS Organizations can deny actions such as disabling CloudTrail or turning off Block Public Access. Config rules can also attach automatic remediation through AWS Systems Manager Automation documents, which fixes drift after the fact. Use remediation carefully on production resources, since an automatic fix can break an application that depended on the old setting.
Tying it back to the model
Each check you set up corresponds to a line in your responsibility matrix, which a later chapter builds. For every customer-side control, you should be able to name three things: the setting, the rule or service that verifies it, and the person who responds when it fails. A control with no verifier is an assumption, not a control.
Exercise
You run aws configservice describe-compliance-by-config-rule --compliance-types NON_COMPLIANT in one Region and get an empty result. Give two different explanations and one command you would run to tell them apart.
Show answer
Either every evaluated resource is compliant, or no Config rules or recorder exist in that Region, so nothing is evaluated. Run aws configservice describe-config-rules --query "ConfigRules[].ConfigRuleName" to see whether rules are deployed, and aws configservice describe-configuration-recorder-status to check that the recorder is running.
Exercise
You enabled EBS encryption by default in us-east-1. A teammate says all of your EBS volumes are now encrypted. What is wrong with that claim?
Show answer
The setting is per Region, so other Regions are unaffected. It also applies only to volumes created after it was enabled, so existing unencrypted volumes remain unencrypted until they are recreated from an encrypted snapshot copy. The encrypted-volumes Config rule can list the ones that remain.
Exercise
Config reports that a security group became NON_COMPLIANT with restricted-ssh. Which service tells you who made the change, and which control would have prevented it?
Show answer
CloudTrail records the AuthorizeSecurityGroupIngress call and the principal that made it. A preventive control such as a service control policy or a tightly scoped IAM policy denying that action to most principals would have blocked the change.