Securing a generative AI application on AWS
For AIF-C01: how IAM, KMS, PrivateLink, Macie, Guardrails, CloudTrail, Config, Inspector and Artifact secure a generative AI app on AWS.
7 min readBy AI Guru AcademyFacts last checked
By AI Guru Academy
In short
Securing a generative AI application on AWS means layering familiar cloud controls with a few AI-specific ones. IAM decides who can call a model, AWS KMS and TLS protect data at rest and in transit, AWS PrivateLink keeps traffic off the public internet, Amazon Macie finds sensitive data before it reaches a prompt, and Amazon Bedrock Guardrails screens prompts and responses. AWS CloudTrail, AWS Config, Amazon Inspector and AWS Artifact then give you the audit trail, configuration checks, vulnerability findings and compliance reports. The Generative AI Security Scoping Matrix tells you how much of this you own.
What does AIF-C01 expect you to know about AI security?
Domain 5 of the exam guide, Security, Compliance, and Governance for AI Solutions, is 14% of scored content. Its skills name IAM, encryption, Amazon Macie, AWS PrivateLink, the shared responsibility model, Amazon Bedrock AgentCore Identity, Policy in AgentCore and Bedrock Guardrails, then AWS Config, Amazon Inspector, AWS Artifact, AWS CloudTrail and AWS Trusted Advisor for governance.
The exam guide lists implementing security or compliance protocols as out of scope, so you need to recognise which service solves which problem, not write the policies yourself.
How do you decide what you are responsible for?
Start with the Generative AI Security Scoping Matrix, which sorts generative AI use into five scopes ordered from least to greatest ownership of the model and data. AWS's page is titled "Securing Generative AI: The Generative AI Security Scoping Matrix".
| Scope | What it means | Example from AWS |
|---|---|---|
| 1. Consumer app | A public third-party generative AI service used under the provider's terms | An employee brainstorms campaign ideas in a public chat app |
| 2. Enterprise app | A business application with generative AI built in, under a vendor agreement | A scheduling app that drafts meeting agendas |
| 3. Pre-trained models | Your own application on an existing foundation model accessed by API | A RAG support chatbot on Amazon Bedrock |
| 4. Fine-tuned models | An existing model refined with your business data | A model tuned to summarise patient records |
| 5. Self-trained models | A model trained from scratch on data you own or acquire | A custom video interpolation model |
The matrix names five security disciplines to prioritise across every scope: governance and compliance, legal and privacy, risk management, controls, and resilience. The further down the table you go, the more of the stack you secure yourself.
This sits on top of the AWS shared responsibility model. The Amazon Bedrock data protection page states that AWS protects the global infrastructure, while you control your content and the security configuration of the services you use.
Which controls protect access and data?
Four services cover identity, keys, network and data discovery.
- IAM. Grant only the permissions a task needs, on specific resources, and have workloads use temporary credentials from IAM roles rather than long-lived access keys. For Bedrock, that means allowing invocation only of the models a role actually uses.
- AWS KMS and TLS. You can encrypt Bedrock resources such as model customisation jobs and their custom models, knowledge base data source ingestion jobs and model evaluation jobs with a KMS key you manage. For data in transit, the Bedrock data protection page says AWS requires TLS 1.2 and recommends TLS 1.3.
- AWS PrivateLink. An interface VPC endpoint lets your VPC reach Bedrock privately, without an internet gateway, NAT device, VPN or AWS Direct Connect. The default endpoint policy allows full access to Bedrock, so attach a custom endpoint policy to restrict who can do what through it.
- Amazon Macie. Macie discovers sensitive data in Amazon S3 using machine learning and pattern matching. Run it over the buckets that feed a knowledge base or a fine-tuning job, so personal data is found before it is indexed or trained into a model.
Agentic applications add their own identity layer. Amazon Bedrock AgentCore Identity manages identities and credentials for AI agents and automated workloads, and Policy in AgentCore evaluates each agent request against defined policies at the AgentCore Gateway before tool access is allowed.
How do you defend against prompt injection and data leakage?
Treat every user prompt as untrusted input, and filter both what goes in and what comes out. AWS defines prompt injection as user prompts designed to ignore and override the developer's instructions, jailbreaks as prompts designed to bypass a model's safety behaviour, and prompt leakage as prompts that try to extract the system prompt or other confidential configuration.
Bedrock Guardrails addresses these with the Prompt Attack content filter. Two details matter. With the InvokeModel API you must wrap user input in guardrail input tags, or prompt attacks are not filtered. Prompt leakage detection is available on the Standard tier only. The prompt attack filter does not evaluate tool results, which matters for agents that read external content.
Data leakage has several routes, and each needs its own control:
- In responses. Sensitive information filters block or mask PII, using probabilistic detection plus custom regular expressions. Detection is not a guarantee.
- In logs. Bedrock model invocation logging is off by default. When enabled, the logged input always holds the original, unmasked request, so protect the log destination as carefully as the data itself.
- In metadata. AWS recommends never putting confidential information, such as customers' email addresses, into tags or free-form name fields, because these may appear in billing or diagnostic logs.
- To model providers. AWS states that model providers have no access to Bedrock's model deployment accounts, so they cannot see Bedrock logs or customer prompts and completions.
Contextual grounding checks add output safety by blocking answers that are not supported by a supplied source.
Which services give you audit, compliance and vulnerability evidence?
Each governance service answers a different question, and the exam often tests whether you can tell them apart.
| Service | The question it answers |
|---|---|
| AWS CloudTrail | Who called which API, on which resource, and when? It captures Bedrock API calls as events. |
| Bedrock model invocation logging | What exactly was sent to and returned by the model? Logs go to CloudWatch Logs, Amazon S3 or both, in the same account and Region. |
| AWS Config | How are my resources configured, how has that changed, and which resources break my rules? Conformance packs group rules. |
| Amazon Inspector | Do my EC2 instances, container images or Lambda functions have software vulnerabilities or unintended network exposure? |
| AWS Artifact | Where can I download AWS compliance reports, such as ISO and SOC reports, and manage agreements with AWS? |
| AWS Trusted Advisor | Where could I save money, improve performance or availability, or close security gaps? |
| Amazon GuardDuty | Is there suspicious activity in my account? It analyses CloudTrail management events, including Amazon Bedrock activity, and its optional AI Protection plan also analyses Bedrock model invocation events. |
Memory hook: CloudTrail records actions, Config records state, Inspector finds vulnerabilities, Artifact holds AWS's compliance evidence.
Worked example: a claims assistant at Harbourline Insurance
This is a fictional illustration. Harbourline Insurance builds a RAG assistant on Amazon Bedrock for its claims staff, which places it in Scope 3 of the Scoping Matrix.
- Macie scans the S3 bucket of claim documents; files with unexpected personal data are removed or redacted before ingestion.
- The application runs in a VPC and reaches Bedrock through a PrivateLink endpoint with a custom endpoint policy.
- An IAM role for the application can invoke one approved model and nothing else; staff never hold long-lived keys.
- A KMS key that Harbourline manages encrypts the knowledge base ingestion job.
- A guardrail applies the prompt attack filter to tagged user input, masks PII in responses and runs a grounding check against retrieved claim documents.
- CloudTrail is on, invocation logging writes to an S3 bucket with tight access, Config rules flag drift, and Inspector scans the container image that hosts the application.
Key takeaways
- Use the Scoping Matrix to decide how much you own, then apply the shared responsibility model inside that scope.
- IAM least privilege, KMS, TLS and PrivateLink protect access and data; Macie finds sensitive data before it enters a prompt or model.
- Guardrails handles prompt attacks and PII in responses, but input tags, tier and tool results all affect what is caught.
- Invocation logs hold the original request, so they need the same protection as the source data.
- CloudTrail records actions, Config records state, Inspector finds vulnerabilities and Artifact provides AWS compliance reports.
FAQ
Does Amazon Bedrock use a private network connection by default?
Bedrock API requests are encrypted in transit with TLS. To keep traffic from your VPC off the public internet, you create an interface VPC endpoint with AWS PrivateLink, and you should restrict its endpoint policy because the default policy allows full access.
What is the difference between AWS CloudTrail and AWS Config?
CloudTrail records API activity: who did what, to which resource and when. Config records resource configurations over time and evaluates them against rules, flagging noncompliant resources.
Can a guardrail stop every prompt injection?
No. It depends on correctly tagged user input with InvokeModel, does not evaluate tool results, and detection is not perfect. Combine it with least-privilege permissions so a successful attack can do little harm.
Where do I get AWS compliance reports for my auditors?
AWS Artifact provides on-demand downloads of AWS security and compliance documents, such as ISO and SOC reports, and lets you review and track agreements with AWS.
Sources
- AWS Certified AI Practitioner (AIF-C01) exam guide: https://docs.aws.amazon.com/aws-certification/latest/ai-practitioner-01/ai-practitioner-01.html
- Generative AI Security Scoping Matrix: https://aws.amazon.com/ai/generative-ai/security/scoping-matrix/
- Data protection in Amazon Bedrock: https://docs.aws.amazon.com/bedrock/latest/userguide/data-protection.html
- Data encryption in Amazon Bedrock: https://docs.aws.amazon.com/bedrock/latest/userguide/data-encryption.html
- Security best practices in IAM: https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html
- Use interface VPC endpoints (AWS PrivateLink) with Amazon Bedrock: https://docs.aws.amazon.com/bedrock/latest/userguide/vpc-interface-endpoints.html
- What is Amazon Macie: https://docs.aws.amazon.com/macie/latest/user/what-is-macie.html
- Amazon Bedrock AgentCore Identity: https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/identity.html
- Policy in Amazon Bedrock AgentCore: https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/policy.html
- Detect prompt attacks with Amazon Bedrock Guardrails: https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-prompt-attack.html
- Sensitive information filters (Amazon Bedrock Guardrails): https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-sensitive-filters.html
- Contextual grounding check (Amazon Bedrock Guardrails): https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-contextual-grounding-check.html
- Monitor model invocation using CloudWatch Logs and Amazon S3: https://docs.aws.amazon.com/bedrock/latest/userguide/model-invocation-logging.html
- Monitor Amazon Bedrock API calls using CloudTrail: https://docs.aws.amazon.com/bedrock/latest/userguide/logging-using-cloudtrail.html
- What is AWS CloudTrail: https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-user-guide.html
- What is AWS Config: https://docs.aws.amazon.com/config/latest/developerguide/WhatIsConfig.html
- What is Amazon Inspector: https://docs.aws.amazon.com/inspector/latest/user/what-is-inspector.html
- What is AWS Artifact: https://docs.aws.amazon.com/artifact/latest/ug/what-is-aws-artifact.html
- AWS Trusted Advisor: https://docs.aws.amazon.com/awssupport/latest/user/trusted-advisor.html
- GuardDuty AI Protection (and Foundational plan detections for AI workloads): https://docs.aws.amazon.com/guardduty/latest/ug/ai-protection.html
Last checked 2026-11-22.
AI Guru Academy is an independent training provider and is not affiliated with or endorsed by Amazon Web Services. AWS service names are trademarks of Amazon.com, Inc. or its affiliates.
Next step: see the full AIF-C01 course at /courses/aif-c01-exam-prep.