Data Classification and Protection with Amazon Macie
Overview
You cannot protect data well if you do not know how sensitive it is. A data classification scheme assigns labels such as Public, Internal, Confidential and Restricted, and each label has rules: who may access it, how it is encrypted, where it may be stored and how long it is kept. SOA-C03 asks you to "implement and enforce a data classification scheme", and Amazon Macie is the AWS service that discovers sensitive data in S3 to help you enforce it.
Imagine a hospital filing room. Every folder has a coloured sticker: green for general information, red for patient records. The red cabinet has a lock and a log of who opened it. Macie is the inspector who walks the room, finds red-worthy documents in green drawers and tells you to move them.
Classification becomes operational through tags, IAM conditions, encryption keys, Config rules and Macie findings, all sharing the same labels.
Key Concepts
- Classification scheme: define levels (for example Public, Internal, Confidential, Restricted) with required controls per level; label resources with a tag such as
DataClass=Confidential. - Macie uses machine learning and pattern matching to discover sensitive data (PII, credentials, financial data) in S3 objects, and evaluates bucket security (public access, encryption, sharing).
- Macie managed data identifiers cover common types (names, SSNs, credit cards, AWS keys); custom data identifiers use regex and keywords for company-specific data; allow lists suppress false positives.
- Automated sensitive data discovery samples buckets continuously across accounts; sensitive data discovery jobs scan chosen buckets on demand or on a schedule.
- Macie publishes findings (policy findings and sensitive data findings) to EventBridge, Security Hub and S3 for results; use them to trigger remediation.
- Enforce labels with tag policies (Organizations), AWS Config
required-tagsand S3 object tags; use ABAC (IAMaws:ResourceTag/aws:PrincipalTagconditions) to link access to classification. - Match classification to encryption: SSE-KMS with a dedicated CMK per class, key policies restricting decryption to approved roles, S3 Bucket Keys to reduce cost.
- Use S3 Object Lock, versioning, Block Public Access, lifecycle and retention rules to meet retention and integrity needs of regulated classes.
Detailed Notes
Example classification-to-control matrix
| Class | Examples | Encryption | Access | Monitoring |
|---|---|---|---|---|
| Public | Marketing assets | SSE-S3 | Anyone via CloudFront | Basic logging |
| Internal | Wiki, internal reports | SSE-S3 or SSE-KMS | Employees via SSO | CloudTrail |
| Confidential | Customer contracts, PII | SSE-KMS CMK | Specific roles, ABAC | Macie, data events, alarms |
| Restricted | Payment card, health, keys | Dedicated CMK, TLS only | Break-glass, MFA | Macie jobs, Object Lock, Config conformance pack |
Enable and use Macie
aws macie2 enable-macie
aws macie2 update-automated-discovery-configuration --status ENABLED
aws macie2 create-classification-job --job-type ONE_TIME --name scan-uploads \
--s3-job-definition '{"bucketDefinitions":[{"accountId":"111122223333","buckets":["customer-uploads"]}]}'
aws macie2 create-custom-data-identifier --name employee-id --regex "EMP-[0-9]{6}" --keywords employee
aws macie2 list-findings --finding-criteria '{"criterion":{"severity.description":{"eq":["High"]}}}'
| Finding type | Meaning | Typical action |
|---|---|---|
| Policy:IAMUser/S3BucketPublic (policy findings) | Bucket made public, encryption disabled or shared externally | Fix bucket policy, enable Block Public Access |
| SensitiveData:S3Object/Personal | PII detected in an object | Move, encrypt, tag as Confidential, restrict access |
| SensitiveData:S3Object/Credentials | Secrets such as keys found in files | Rotate credentials, remove the object |
Macie needs permission to read the objects: if buckets use SSE-KMS, the Macie service-linked role must be allowed to decrypt with the CMK, otherwise objects are skipped and reported as inaccessible.
Enforce labels with tags and ABAC
{ "Effect": "Allow", "Action": "s3:GetObject", "Resource": "*",
"Condition": { "StringEquals": { "s3:ExistingObjectTag/DataClass": "${aws:PrincipalTag/ClearanceLevel}" } } }
aws s3api put-object-tagging --bucket customer-uploads --key contracts/a.pdf \
--tagging 'TagSet=[{Key=DataClass,Value=Confidential}]'
aws configservice put-config-rule --config-rule file://required-dataclass-tag.json
- Tag policies in Organizations standardise keys and allowed values (
DataClassmust be one of four). - Config rules (
required-tags,s3-bucket-server-side-encryption-enabled,s3-bucket-public-read-prohibited) detect non-compliance. - EventBridge rule on Macie findings can invoke a Lambda or SSM Automation to tag the object, move it to a quarantine bucket, or notify the owner.
Combine services for the lifecycle
| Stage | Control |
|---|---|
| Discover | Macie automated discovery and jobs |
| Label | Tags, tag policies, object tags |
| Protect | KMS CMKs, bucket policies, VPC endpoints, Block Public Access |
| Retain | Lifecycle, versioning, Object Lock, AWS Backup |
| Detect | Macie findings, GuardDuty S3 protection, CloudTrail data events |
| Report | Security Hub, Config conformance packs, Audit Manager |
Operational notes
- Macie pricing depends on buckets evaluated and bytes inspected; scope jobs with filters (prefixes, object age, tags) and use sampling to control cost.
- Multi-account: designate a delegated administrator (through Organizations) to manage Macie centrally.
- Macie covers S3 only; for databases use RDS/Aurora features, DMS, or third-party and Glue-based classification.
Real World Example
Scenario – PII in the wrong bucket. A support team exports customer tickets to an "Internal" S3 bucket that many employees can read. Macie's automated discovery raises a SensitiveData:S3Object/Personal finding with credit-card numbers in several objects.
An EventBridge rule routes the finding to a Lambda function that tags the objects DataClass=Restricted and copies them to a KMS-encrypted quarantine bucket. IAM policies using ABAC now deny read unless the user's ClearanceLevel matches the object tag. A Config rule flags any bucket lacking the DataClass tag, and the security team receives a weekly Security Hub summary.
Architecture Diagram
- 1Define classes and the required controls for each (encryption, access, retention).
- 2Macie scans S3 and finds sensitive data or risky bucket policies.
- 3Findings flow to EventBridge and Security Hub.
- 4Automation tags objects, quarantines or encrypts them, and notifies owners.
- 5ABAC, KMS key policies and Config rules enforce the class going forward.
Best Practices
- ✓Publish a written classification scheme with required controls per class and enforce tag keys via tag policies.
- ✓Run Macie automated discovery organization-wide through a delegated administrator and review findings weekly.
- ✓Use ABAC with tags so access follows classification rather than per-bucket policies.
- ✓Encrypt Confidential/Restricted data with dedicated KMS keys and restrict decrypt permissions.
- ✓Automate remediation of Macie findings with EventBridge and SSM Automation or Lambda.
Common Interview Questions
Exam Tips
SOA-C03 focus
- Discover PII/sensitive data in S3 -> Macie; threats against accounts -> GuardDuty; vulnerabilities -> Inspector.
- Access based on tags/labels -> ABAC with
aws:ResourceTag/s3:ExistingObjectTagconditions. - Standardise tag keys across accounts -> Organizations tag policies; detect missing tags -> Config required-tags.
- Macie findings go to EventBridge and Security Hub for automated response.
Finished this lesson?
0 of 46 lessons done · 0% of the course

