SkillSprout
Chapter 10 · Lesson 2
Intermediate
6 min read

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-tags and S3 object tags; use ABAC (IAM aws:ResourceTag / aws:PrincipalTag conditions) 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

ClassExamplesEncryptionAccessMonitoring
PublicMarketing assetsSSE-S3Anyone via CloudFrontBasic logging
InternalWiki, internal reportsSSE-S3 or SSE-KMSEmployees via SSOCloudTrail
ConfidentialCustomer contracts, PIISSE-KMS CMKSpecific roles, ABACMacie, data events, alarms
RestrictedPayment card, health, keysDedicated CMK, TLS onlyBreak-glass, MFAMacie jobs, Object Lock, Config conformance pack

Enable and use Macie

bash
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 typeMeaningTypical action
Policy:IAMUser/S3BucketPublic (policy findings)Bucket made public, encryption disabled or shared externallyFix bucket policy, enable Block Public Access
SensitiveData:S3Object/PersonalPII detected in an objectMove, encrypt, tag as Confidential, restrict access
SensitiveData:S3Object/CredentialsSecrets such as keys found in filesRotate 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

json
{ "Effect": "Allow", "Action": "s3:GetObject", "Resource": "*",
  "Condition": { "StringEquals": { "s3:ExistingObjectTag/DataClass": "${aws:PrincipalTag/ClearanceLevel}" } } }
bash
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 (DataClass must 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

StageControl
DiscoverMacie automated discovery and jobs
LabelTags, tag policies, object tags
ProtectKMS CMKs, bucket policies, VPC endpoints, Block Public Access
RetainLifecycle, versioning, Object Lock, AWS Backup
DetectMacie findings, GuardDuty S3 protection, CloudTrail data events
ReportSecurity 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

Classify, label and protect
Architecture
Data governance
S3 buckets
Maciediscovery
EventBridge
Remediatetag + quarantine
KMS key per class
  1. 1Define classes and the required controls for each (encryption, access, retention).
  2. 2Macie scans S3 and finds sensitive data or risky bucket policies.
  3. 3Findings flow to EventBridge and Security Hub.
  4. 4Automation tags objects, quarantines or encrypts them, and notifies owners.
  5. 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:ExistingObjectTag conditions.
  • 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