Lesson 3 of 4 Securing Generative AI Applications

Protecting Data in Generative AI Applications

This lesson explains how standard AWS controls, private networking, encryption, least privilege and logging, protect the prompts, documents and responses of a generative AI application, together with limits that stop abuse.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe how Amazon Bedrock protects customer data.
  • Describe controls that limit abuse and cost.
  • Explain how model invocation logs that contain sensitive data are protected.

Protecting data with Bedrock

Organisations often hesitate to send confidential data to foundation models because they fear it will be retained, used for training or exposed to the model provider. Amazon Bedrock addresses these concerns: model providers have no access to customer prompts or responses, and customer data is not used to improve the base models. Standard AWS controls then protect the data in the same way as for other services, through private networking, encryption, access control and logging. The following list describes these controls.

  • Prompts and responses are not used to train base models or shared with model providers.
  • Interface VPC endpoints (PrivateLink) provide private access.
  • KMS customer managed keys encrypt custom models, knowledge bases and agents.
  • IAM policies scoped to model IDs limit which models can be used.
  • Model invocation logging to CloudWatch Logs or S3 supports auditing.

The following diagram shows the private network path to the model and the protected logs of a healthcare assistant built on Amazon Bedrock.

Keeping a healthcare assistant's data private. Bedrock is reached through an interface VPC endpoint whose policy allows only the application role, which may invoke only the approved model; invocation logs go to an S3 bucket encrypted with a key only compliance can decrypt, and a guardrail masks patient identifiers.
The scenario is illustrative.
True or false

Bedrock data protection

Exam skills 3.2.7 · 5.2.1

Check how Bedrock protects customer prompts and data.

Log in to try this activity Interactive activities are free with an account.

Limiting abuse

Every request to a generative AI application costs money, so public endpoints attract abuse that can run up cost or exhaust capacity. Four controls limit it. A maximum token limit per request bounds the length, and so the cost, of each response. Rate limits and per-user or per-tenant quotas, for example through API Gateway usage plans, stop one client from consuming all capacity. AWS WAF on public endpoints blocks bots and abusive clients before they reach the model. CloudWatch monitoring of invocations and token usage raises alerts when usage becomes unusual. The following table summarises the controls.

ControlEffect
Maximum tokens per requestBounds the cost and length of each response
Rate limits and per-user or per-tenant quotasStops one client consuming all capacity
AWS WAF on public endpointsBlocks bots and abusive clients
CloudWatch monitoringAlerts on unusual usage
Match the pairs

Limiting abuse of a GenAI endpoint

Exam skills 3.2.7

Match each abuse control with its effect.

Log in to try this activity Interactive activities are free with an account.

Protecting logs

Model invocation logging records the full text of prompts and responses, which is valuable for auditing and troubleshooting but may itself contain personal data, credentials or confidential business information. The logs therefore need the same protection as the source data. They belong in destinations encrypted with a customer managed KMS key and restricted to the people who need them. Sensitive values can be reduced before or after logging: Bedrock Guardrails can mask personally identifiable information in prompts and responses, and CloudWatch Logs data protection policies can mask sensitive data in the log group. Retention periods should be no longer than required.

Select all that apply

Protecting invocation logs

Exam skills 3.2.7 · 5.3.4

Pick the practices that protect model invocation logs.

Log in to try this activity Interactive activities are free with an account.
Worked example

Keeping an assistant's data private

A healthcare company's assistant processes patient questions. Security requires that traffic never crosses the internet, that only one approved model is used, and that logs are encrypted and restricted. The application role's policy allows only the approved model:

{
  "Effect": "Allow",
  "Action": ["bedrock:InvokeModel", "bedrock:Converse"],
  "Resource": "arn:aws:bedrock:eu-west-1::foundation-model/anthropic.claude-sonnet-model-id"
}

Bedrock is reached through an interface VPC endpoint whose endpoint policy allows only the application role. Model invocation logging writes to an S3 bucket encrypted with a customer managed key that only the compliance team can decrypt, and a guardrail masks patient identifiers before responses are logged or returned.

Check yourself

How can Bedrock traffic be kept off the internet?

Show answer

With an interface VPC endpoint for Bedrock.

Exam Tips

Remember for the exam

  • Bedrock does not use prompts or responses to train base models.
  • To keep Bedrock traffic off the internet, use an interface VPC endpoint.
  • To audit prompts and responses, enable model invocation logging.
  • Encrypt knowledge bases and agents with customer managed KMS keys.
  • Limit tokens, rates and per-tenant quotas to prevent abuse.