← AI Practitioner study path

Responsible AI, security and governance · 13 min

Amazon Macie and the data that feeds a model

In this lesson you will learn what Amazon Macie does, how it differs from the sensitive information filter of Amazon Bedrock Guardrails and which AWS services cover the quality, privacy, access, integrity and origin of a model's data.

The data used to fine-tune a model, that is, to teach it more about a topic, or to build a with , can contain sensitive information that nobody reviewed. Sensitive information is information that can harm someone if it leaks, such as a card number or an address. For example, a team that gathers ten years of support conversations in an S3 also takes along the card numbers, email addresses and physical addresses that customers wrote in them, and if nobody finds that data first, it ends up inside the model or in a chatbot response.

Task 5.1 of the AWS Certified AI Practitioner exam guide covers that problem: the services that protect the data of an AI system and the secure data engineering practices that come before training. Data engineering is the work of gathering, cleaning and preparing data so it can be used. On AWS, Amazon Macie is the service that finds sensitive data, and each of those practices also has its own service. For example, an online store that wants to train its chat with its support conversations uses Macie to know which files contain card data, and other services to clean and protect them.

What does Amazon Macie do?

AWS defines Amazon Macie as a data security service that discovers sensitive data using machine learning and pattern matching, which is looking for text with a known shape, such as sixteen digits in a row in a card number. Macie shows you the security risks of that data and lets you protect yourself against them automatically, and it only works with Amazon S3, the AWS service for storing files. For example, Macie can review the conversation files the store saved in S3, but not a database the store keeps in another service.

Monitoring buckets

Macie's first job is to monitor buckets. When you turn it on, Macie builds an inventory of your S3 general purpose buckets, that is, a list of all of them, and continuously evaluates their security and access control, which is who can get into each one. If a bucket becomes public or is shared with another account, Macie generates a policy finding, which is an alert that something in its permissions changed and may be a risk. For example, if a store employee leaves the bucket with the support conversations open to the whole internet, Macie flags it.

Finding sensitive data

The second job is to find sensitive data inside those buckets, and Macie does it in two ways:

  • Automated sensitive data discovery, which continuously takes representative samples from your buckets, that is, it reviews part of the files in each bucket to estimate what is in all of them. For example, it reviews some files in each of the store's buckets to know which ones probably contain card data.
  • Sensitive data discovery jobs, where you define which buckets are analyzed, how deeply and whether the job runs once or on a schedule. For example, the store asks for a full review of the conversations bucket just once before training.

To recognize the data, Macie uses managed data identifiers, which are detectors AWS already prepared that recognize many types of PII, financial data and from many countries. PII, or personally identifiable information, is the data that says who a person is, such as their name, their email address or their passport number. If you need to recognize something of your own, such as the format of your company's customer number, you create a custom data identifier with a . Allow lists do the opposite, because they tell Macie what to ignore, such as your company's public phone number. For example, the store adds its customer service phone number to the allow list so Macie doesn't count it as personal data in every conversation.

Findings

Everything Macie finds is recorded as a finding, with its severity, which says how serious it is, details about the resource and the date it was detected. You can send those findings to Amazon EventBridge and to AWS Security Hub CSPM so that other systems process them. For example, the store can have each serious finding reach the security team as an alert instead of waiting for someone to go look for it.

True or false?

0 of 4
  1. Macie can scan an Amazon DynamoDB table for PII.

  2. Macie alerts you if a bucket becomes public.

  3. Macie masks the card numbers it finds in a file.

  4. You can teach Macie a format of your own with a regular expression.

How do Macie and Guardrails differ?

Macie and the sensitive information filter of Amazon Bedrock Guardrails both find personal information, and that is why they get confused. What separates them is where they look and when.

Macie reviews the data stored in S3, before you use it, and tells you what it found. The Guardrails sensitive information filter, on the other hand, reviews what goes into and comes out of the model on each call, while the application is in use, and it can block the message or mask the data, that is, replace it with a marker such as {EMAIL}. For example, the store uses Macie to review the old conversations before training its chat, and uses Guardrails so the chat, once running, doesn't repeat the email address a customer wrote in their question.

Macie or Guardrails?

0 of 4

Tap the service that handles each case.

  1. Find card numbers in the files you are going to use to fine-tune a model

  2. Have a call summary come out with {NAME} instead of the customer's name

  3. Find out which of your 200 buckets contain personal data

  4. Keep the chatbot from returning an email address the user pasted into their question

What is secure data engineering?

The four secure data engineering practices and their AWS service: data quality with AWS Glue Data Quality, privacy with AWS Glue Detect PII, access control with AWS Lake Formation and integrity with S3 Object Lock

Macie tells you where the sensitive data is, but a secure dataset needs more than that. Task 5.1 names four secure data engineering practices, and each one has an AWS service:

  • Data quality, which is covered with AWS Glue Data Quality, where you measure and monitor data with rules you write in its own language, DQDL. For example, a rule can require that no store conversation arrives empty.
  • Privacy-enhancing technologies, such as the AWS Glue Detect PII transform, which finds personal data and masks or removes it before training. For example, it deletes customers' email addresses from each conversation.
  • Data access control, which is covered with AWS Lake Formation, where you govern fine-grained access to the data in S3 and to its catalog with its own permissions model built on top of IAM. Fine-grained access is granting permission by column, by row or by cell of a table, and not only to the whole table. For example, a store analyst can see the conversations but not the column with the customer's phone number.
  • Data integrity, which is covered with S3 Object Lock, which prevents from being deleted or overwritten for a period of time or forever. For example, nobody can change the conversations that were used to train the model.

S3 Object Lock follows the WORM model, where an object is written once and read many times. As for privacy, the AWS AI Security Scoping Matrix recommends not training or fine-tuning models with PII, and if the application needs it, having it receive the PII at query time with RAG. For example, the store's chat is trained without names or addresses, and when a customer asks about their order, the application looks up that customer's address at that moment and passes it to the model.

How do you document where data comes from?

Four services for documenting where data comes from: Amazon Bedrock Knowledge Bases, AWS Glue Data Catalog, SageMaker Unified Studio lineage and Amazon SageMaker Model Cards

Task 5.1 also asks you to document where data comes from, so you can check later whether a piece of data came from a trustworthy source and whether it could be used. On AWS there are four services or features for that:

  • Amazon Bedrock Knowledge Bases, which responds with citations that link each part of the answer to its document in S3. For example, the chat says what the return policy is and points to the manual it took it from.
  • The AWS Glue Data Catalog, which stores the location, the and the metrics of each dataset, and which is populated by a that scans the sources. For example, it records which bucket holds the store's conversations and which columns they have.
  • Data lineage in Amazon SageMaker Unified Studio, which shows where a dataset comes from, what transformations it went through and who uses it. For example, it shows that the conversations came from the support system, went through Detect PII and were used by the chat team.
  • Amazon SageMaker Model Cards, which documents what data each model was trained on. For example, the chat's card says it was trained on support conversations without personal data.

Match each practice with its service

0 of 5 pairs

Tap a practice and then the AWS service that handles it.

0 of 5 pairs.

Macie in both accounts

In the new experience account, Macie is not available unless you turn on the advanced features. In a full account you get a 30-day free trial that includes automated sensitive data discovery (up to 150 GB inspected) and the bucket inventory, although the discovery jobs you create are not included in the trial. For example, if during the trial you create a discovery job to review a whole bucket, that job is charged.

Outside the trial, the examples on the Macie pricing page (in us-east-1) charge 0.10 USD per bucket per month for monitoring and 1 USD for each GB inspected by discovery. AWS Glue, Lake Formation, S3 and SageMaker Unified Studio, on the other hand, are available on the free plan of the new experience. For example, at those example prices, monitoring ten buckets for a month costs one dollar before counting the GB inspected.

cloud path tip: if you turn on Macie in your full account to try it, turn it off before the 30 days of the trial are over.

On the exam

Questions on this topic usually ask for the service that protects or documents the data, and these words in the question point to the answer:

  • "Discover sensitive data in S3" or "PII in buckets", which point to Macie.
  • "Mask PII in the conversation", which points to Guardrails.
  • "Column-level or row-level permissions", which points to Lake Formation.
  • "Catalog" or "metadata", which point to the Glue Data Catalog. Metadata is the data that describes other data, such as a table's name and location.
  • "Where a piece of data comes from", which points to lineage.

For example, if the question says a school wants teachers to see grades but not each student's address, the phrase "column-level" leads you to Lake Formation.

Review question

Before using thousands of documents from S3 for a knowledge base, a company wants to know which ones contain passport numbers and credentials. Which service should it use?

Next