Securing AI services and agents
DVA-C03 · Lesson 14 of 24 · 1:50:41
YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗
Learning with these videos? Subscribe for new courses and exam-style questions.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the DVA-C03 exam (AWS Certified Developer – Associate). In this lesson: access to models, private connectivity with VPC endpoints, how Bedrock protects your data, Guardrails (content and prompt attack filters, denied topics, word filters, sensitive information, ApplyGuardrail), securing agents with isolated sessions, user confirmation, and least privilege, and masking sensitive data in invocation logs. Includes three original practice questions.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
An assistant that can act
The fan assistant of AnyCompany Tickets no longer just answers questions: it can look up orders, and even start a refund. That makes it useful, and it makes it a target, for prompt attacks, data leaks, and actions that nobody approved. This lesson covers model access, private connectivity and data protection, Bedrock Guardrails, agent safeguards, and invocation logging.
Model access
Access to many Bedrock foundation models is enabled by default, as long as the caller has the right AWS Marketplace permissions, to subscribe to a model's offer. Anthropic models also need a one-time form, with the use case, before the first call. Then IAM decides who can invoke which model: a policy allows InvokeModel or Converse on the ARN of one model, or of an inference profile, and nothing else. So the assistant's role can call one approved model, while a test role can try others.
Private connectivity and data
To keep model traffic off the internet, an interface VPC endpoint for the Bedrock runtime, built on AWS PrivateLink, gives a private connection from the VPC. An endpoint policy can then limit which actions and models go through it. Your prompts and completions are not used to train the base models, and they are not shared with the model providers. Data is encrypted in transit and at rest, and you can encrypt it with your own KMS keys.
Bedrock Guardrails
Bedrock Guardrails filter the inputs and the outputs of a model. Content filters catch harmful content, and include a filter for prompt attacks, like jailbreaks and injected instructions. Denied topics block subjects that the app must avoid, like investment advice, and word filters block exact words. Sensitive information filters find personal data, like phone numbers, and block it or mask it. And the ApplyGuardrail API checks any text, even from a model outside Bedrock, against the same guardrail.
Safeguards for agents
Agents need more than filters, because they act. In AgentCore Runtime, each session runs in its own microVM, so one fan's session can never read another's data, and the microVM is wiped when the session ends. Each tool gets the least privilege it needs, through its own role or credentials, never the agent's full access. For risky actions, like a refund, the agent asks the user, or a human, for confirmation, or returns control to the application before acting. And AgentCore Policy checks every tool call through the gateway against rules, before the tool runs.
Invocation logging
Model invocation logging is disabled by default. Once on, it sends the prompts, the completions, and metadata to CloudWatch Logs, to S3, or to both, in the same account. Those logs can hold personal data, so a data protection policy on the log group masks it, and access to the bucket stays tight. And CloudTrail logs the API calls themselves, like who invoked which model, and when.
Recap
Let's recap. Model access is on by default with AWS Marketplace permissions, Anthropic models need a one-time form, and IAM limits each role to approved models. An interface VPC endpoint keeps traffic private, and your content is not used to train base models. Guardrails filter harmful content and prompt attacks, block denied topics, and mask sensitive information. Agents run in isolated sessions, use tools with least privilege, and ask for confirmation before risky actions. And invocation logging, disabled by default, needs masking for personal data.
Quick checks for this lesson
The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.
Functions in private subnets call Bedrock today through a NAT gateway. Security now requires that this traffic never cross the internet, and that only one model can be reached from the VPC. What should the developer configure?
- A guardrail on every call to the model
- An interface VPC endpoint with a policy
- A security group rule for the NAT gateway
- A gateway VPC endpoint for Bedrock
Show the answer
An interface VPC endpoint with a policy
An interface endpoint keeps the traffic private, and its endpoint policy limits which models the VPC can reach. “A guardrail on every call to the model” would only filter what goes in and out of the model, while the traffic still crosses the internet. “A security group rule for the NAT gateway” would keep the traffic on the internet, through the NAT gateway. And “A gateway VPC endpoint for Bedrock” would add a gateway endpoint, which only exists for S3 and DynamoDB.
The assistant can call a refund tool. The team wants every refund to wait for the fan’s explicit approval, even when the model is convinced that a refund is right. What should the developer add?
- A content filter in a Bedrock guardrail
- A line in the system prompt about refunds
- Invocation logging for every refund call
- User confirmation before the refund tool
Show the answer
User confirmation before the refund tool
A confirmation step makes the app ask the fan before the refund tool runs, whatever the model decides. “A content filter in a Bedrock guardrail” would block harmful content, but a refund is not harmful content. “A line in the system prompt about refunds” would only ask the model nicely, and a model can still act without approval. And “Invocation logging for every refund call” would only log each refund after it happens, without preventing any of them.
To investigate odd answers, the team must keep every prompt and completion of the assistant. Fans sometimes type their phone numbers, which must not be readable in the logs. What should the developer do?
- Turn on invocation logging, and mask the numbers
- Rely on CloudTrail for the prompts and answers
- Keep the requests in memory for a few hours
- Turn invocation logging off for the assistant
Show the answer
Turn on invocation logging, and mask the numbers
Invocation logging keeps the prompts and completions, and a data protection policy masks the phone numbers in the log group. “Rely on CloudTrail for the prompts and answers” would record who called the model, but not the prompts and the completions. “Keep the requests in memory for a few hours” would only keep the requests in memory, with no record. And “Turn invocation logging off for the assistant” would lose the very data that the team needs to investigate.