Machine learning and generative AI
Securing Amazon Bedrock and SageMaker AI with IAM, KMS, PrivateLink, guardrails and logging, plus the status of Q and CodeGuru Security.
Generative AI security on the exam is ordinary AWS security applied to new resources. Control who can call a model, keep traffic private, encrypt customer data with KMS, filter prompts and responses, and log usage. Bedrock serves foundation models through an API. SageMaker AI trains and hosts your own models.
Service table
| Service | What it is | Exam fact | Security controls |
|---|---|---|---|
| Amazon Bedrock | Foundation models behind one API, plus agents, knowledge bases, guardrails and model customization | Model providers have no access to the service-owned deployment accounts, so they see no prompts, completions or logs | IAM and resource policies, TLS 1.2, KMS for custom models, agents and ingestion jobs, PrivateLink endpoints with policies, guardrails, invocation logging, CloudTrail |
| Amazon SageMaker AI | Build, train and host ML models | Containers have internet access by default. Network isolation removes it | Execution role, VPC config, EnableNetworkIsolation, KMS, optional inter-node encryption, CloudTrail, CVE-scanned prebuilt containers |
| Amazon Q Business | Enterprise assistant over company data | No longer open to new customers. AWS points to Amazon Quick | PrivateLink endpoints, ACL Analyzer, IAM for administration |
| Amazon Q Developer | Coding assistant that also scans code in the IDE | IDE plugin support ends April 30, 2027. Console chat is now the AWS assistant | AWS Builder ID sign-in in the IDE. Built on Bedrock with automated abuse detection |
| Amazon CodeGuru Security | Static code security scanner | AWS ended support on November 20, 2025 | Not a current exam target. Do not pick it for new designs |
Bedrock security
| Area | What to remember |
|---|---|
| Transit | TLS 1.2 or later. API and console use a secure connection |
| Encryption with KMS | Model customization jobs and output custom models, agents, knowledge base data source ingestion jobs, OpenSearch Service vector stores, model evaluation jobs. Training, validation and output data in S3 use SSE-KMS. Third-party vector store credentials sit in Secrets Manager |
| Private access | Interface endpoints for bedrock, bedrock-runtime, bedrock-agent, bedrock-agent-runtime and bedrock-mantle. FIPS variants exist for bedrock and bedrock-runtime in some Regions |
| Endpoint policy | Default allows everything. Attach a custom policy to limit principals, actions such as bedrock:InvokeModel, and resources |
| Private DNS | With it on, the standard Regional hostname resolves to the endpoint and no code change is needed. With it off, call the vpce URL explicitly |
| Agent service role | Trust policy for bedrock.amazonaws.com with aws:SourceAccount and aws:SourceArn conditions. Needs model access, knowledge base Retrieve, and bedrock:ApplyGuardrail when a guardrail is attached |
| Action group Lambda | Needs a resource-based policy that lets the Bedrock service principal invoke it, scoped to the agent |
Guardrails
A guardrail screens user input and model output. Use it in an inference call by passing the guardrail ID and version. Call ApplyGuardrail to screen text without invoking a Bedrock model, for example with a third-party model.
| Safeguard | Purpose |
|---|---|
| Content filters | Hate, insults, sexual, violence, misconduct and prompt attack, with strength set per category |
| Denied topics | Topics your app must not discuss |
| Word filters | Custom words and phrases. Case-insensitive whole-word match |
| Sensitive information filters | Block or mask PII and custom regex patterns |
| Contextual grounding checks | Detect hallucinations, mainly in RAG answers |
| Automated Reasoning checks | Validate answers against logical rules |
- A guardrail has a working draft and numbered versions. Applications use a version.
- Guardrails do not check reasoning content blocks.
- A role that only calls
ApplyGuardrailneedsbedrock:ApplyGuardrailon the guardrail ARN. It does not needInvokeModel. - Cross-account safeguards through guardrail enforcements exist for organization-wide control.
Invocation logging
- It is off by default. When on, it records full request and response bodies and metadata for
Converse,ConverseStream,InvokeModelandInvokeModelWithResponseStream. - Destinations are S3, CloudWatch Logs or both. The bucket or log group must be in the same account and Region.
- Bodies over 100 KB, and binary data, go to S3 as separate objects.
- Only calls through the
bedrock-runtimeendpoint are logged. Calls throughbedrock-mantleare not. - S3 delivery needs a bucket policy for
bedrock.amazonaws.comlimited by source account and ARN. If the bucket uses SSE-KMS, the key policy must allowkms:GenerateDataKeyfor the service. - Each record includes the caller's
identity.arn, so you can attribute usage to a role.
Exam signal
"Keep prompts off the public internet" is an interface VPC endpoint for bedrock-runtime. "Block PII in responses" is a guardrail sensitive information filter. "Audit exactly what users asked" is model invocation logging. It is the feature that records request and response bodies.
SageMaker AI security
| Control | Fact |
|---|---|
| Default at-rest encryption | SSE-S3 for Studio notebooks, notebook instances, model-building data, model artifacts and training, batch transform and processing output |
| Cross-account | Specify your own customer managed KMS key. The default key cannot be shared across accounts |
| Containers | Training and inference containers are internet-enabled by default |
| VPC | Supply VpcConfig on training jobs, tuning jobs and models, then control egress with security groups and routes |
| Network isolation | Set EnableNetworkIsolation to true. No outbound calls to any service, including S3, and no AWS credentials in the container. SageMaker still moves data using your execution role. Required for AWS Marketplace algorithms |
| Isolation with VPC | S3 transfers go through your subnet, but the containers themselves still reach nothing |
| In transit | TLS 1.2 across networks. Traffic between nodes in distributed training and processing is not encrypted by default. Inter-container encryption is optional and can slow training |
| Containers scanned | Prebuilt SageMaker images and Marketplace listings are scanned for CVEs |
Exam trap
Putting a training job in a VPC does not stop its code from sending data out if the subnet has a route to the internet. To guarantee no egress, use network isolation.
Legacy
Study notes that list Amazon CodeGuru Security or the Amazon Q Developer console chat as current describe retired or renamed products. Use the status shown in the table above.
Related
GuardDuty AI Protection watches CloudTrail data events for Bedrock and SageMaker AI. Analytics covers querying invocation logs delivered to S3.
Further reading
- https://docs.aws.amazon.com/bedrock/latest/userguide/data-protection.html
- https://docs.aws.amazon.com/bedrock/latest/userguide/data-encryption.html
- https://docs.aws.amazon.com/bedrock/latest/userguide/vpc-interface-endpoints.html
- https://docs.aws.amazon.com/bedrock/latest/userguide/model-invocation-logging.html
- https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails.html
- https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-permissions.html
- https://docs.aws.amazon.com/bedrock/latest/userguide/agents-permissions.html
- https://docs.aws.amazon.com/sagemaker/latest/dg/security.html
- https://docs.aws.amazon.com/sagemaker/latest/dg/encryption-at-rest.html
- https://docs.aws.amazon.com/sagemaker/latest/dg/encryption-in-transit.html
- https://docs.aws.amazon.com/sagemaker/latest/dg/infrastructure-security.html
- https://docs.aws.amazon.com/sagemaker/latest/dg/mkt-algo-model-internet-free.html
- https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/what-is.html
- https://docs.aws.amazon.com/amazonq/latest/qbusiness-ug/security.html
- https://docs.aws.amazon.com/codeguru/latest/security-ug/end-of-support.html