Skip to Content
Cloud Engineering Academy
16. Generative AI on AWS for Banking

Data privacy and model risk for GenAI in a bank

Trace where prompts and completions go on Amazon Bedrock, apply UK GDPR thinking to GenAI, and build a model inventory with risk tiers, validation, logging and monitoring that a bank's model-risk function can accept.

intermediate⏱ 2 h 30 min🟢 FreeAIF-C01AIP-C01SCS-C03

Assumes: .NET 10 LTS · AWS SDK for .NET v4 · AWS CLI v2 · CDK v2 (Amazon.CDK.Lib 2.277.0) · Terraform AWS provider v6 · Amazon Bedrock · UK GDPR as amended by the Data (Use and Access) Act 2025 · Region us-east-1. Verified against official sources on 2026-11-18.

Read this first

This lesson explains data-protection and model-risk concepts so engineers can design sensibly and ask the right questions. It is not legal advice and it does not make any system compliant. Lawful basis, DPIAs, international transfers, retention periods, regulatory classification (for example under the EU AI Act) and model-risk sign-off belong to Harbourline's DPO, legal, compliance and model-risk teams. Items marked ⚠ VERIFY must be confirmed against the primary source before you rely on them.

Learning objectives

By the end of this lesson you can:

  • Trace a prompt from your .NET code to the model and back, and say what AWS documents about storage, access, retention, encryption and Regional routing on Amazon Bedrock.
  • Explain the Bedrock data retention modes and why some models need aws_review.
  • Choose between a single Region, a geographic cross-Region inference profile and a global profile, and enforce the choice with an SCP.
  • Apply UK GDPR principles to GenAI: lawful basis, minimisation, accuracy, transparency, automated decisions, DPIAs and erasure in logs, memory and vector stores.
  • Build a model inventory with risk tiers and automated rule checks in C#, and write metadata-only audit records.
  • Describe model validation and ongoing monitoring for foundation-model use cases, and name the AWS tools that remain available after the 2026-07-30 closures.

Prerequisites

Why this matters in banking

Three questions arrive in the first model-risk review of any GenAI project, usually in this order:

  1. "Where does our data go?" A prompt that contains an account number or a complaint narrative is personal data. Who processes it, where, for how long, and can the vendor read it?
  2. "How do we know it works, and keep working?" The model is a third-party component that its provider updates or retires on its own schedule. A prompt that behaved well in March may behave differently after a model version change.
  3. "Who is accountable and where is the evidence?" If the assistant mis-states a fee to a customer, you must reconstruct which model, which prompt template, which source documents and which reviewer were involved.

Projects that cannot answer these in a page each stall at the risk committee. This lesson gives you the answers and the artefacts.

The idea in plain language

Data privacy asks: what personal or confidential data enters the system, where it travels and rests, who can see it, and how long it lives. Model risk asks: what harm can come from the model being wrong, biased, unavailable or changed, and what controls keep that harm within the bank's appetite.

GenAI adds three twists to older model-risk practice:

  • The model is not yours. You consume a foundation model from a provider through Bedrock. You cannot inspect its weights or training data, so your assurance comes from testing the behaviour on your own use case, monitoring in production, and contract and vendor due diligence.
  • Outputs are open-ended text. A credit-scoring model returns a number you can back-test. A chatbot returns sentences that can be fluent and wrong (hallucination).
  • Your prompt is the model. Changing the system prompt, the retrieval sources or the guardrail changes the system's behaviour, so each is a controlled change, not a casual edit.

Analogy: treat a foundation model like an outsourced analyst. You do not audit their brain; you check their references, test their work on your cases, supervise them, log what they did, and have a plan for when they leave or change.

What problem the AWS service solves

What AWS documents about Bedrock and your data

Facts below were checked against the Bedrock user guide on 2026-11-18. Re-check before you quote them in a risk paper, because they change.

TopicWhat AWS statesWhat you still own
Model provider accessEach Region has a Model Deployment Account per provider, owned and operated by the Bedrock service team. Providers have no access to those accounts, to Bedrock logs, or to customer prompts and completionsYour DPO still needs the contractual terms and the sub-processor list
Content sharingBedrock does not share your content with model providers under any current retention modeConfirm in the current AWS Service Terms
RetentionControlled by a data retention mode per Region (see below)Choose and enforce the mode
EncryptionData encrypted in transit (TLS 1.2 required, 1.3 recommended); encryption at rest options per feature, including customer managed KMS keys for several resourcesChoose keys; manage key policies
NetworkVPC endpoints through AWS PrivateLink for Bedrock APIsCreate endpoints and endpoint policies
LoggingModel invocation logging is disabled by default. When enabled it writes full request and response bodies to S3 and/or CloudWatch Logs in the same account and RegionYour logs may now contain personal data: classify, encrypt, restrict and expire them
Abuse detectionData may be processed for abuse detection; see the Bedrock abuse-detection pageRead it for each model you use
Cross-Region inferenceRequests can be routed to other Regions via inference profiles; CloudTrail logs them in the source Region with additionalEventData.inferenceRegion showing where processing occurredPick geographic or global; allow the destination Regions in your SCPs

Data retention modes

Bedrock lets you set, per Region and at account level, how prompts and outputs are retained:

ModeMeaning
noneZero data retention: nothing written to durable storage by AWS and nothing shared with the model provider
defaultThe model's own policy applies (no change from before). AWS may retain data for safety and abuse prevention; the provider does not receive it
aws_reviewInputs and outputs may be retained and reviewed by AWS (never shared with the provider), required for models whose provider demands human review as a condition of access
provider_data_shareLegacy. Does not cause sharing today; behaves like aws_review
inheritNo opinion at this scope; defer to a broader scope (the default for new accounts)

Key points to remember:

  • Each model declares which modes it allows. Some models (as documented on 2026-11-18, the Claude Fable 5, 5.1 and 5.2 models) require aws_review: prompts and completions are kept within the AWS boundary for up to 30 days and may be reviewed by AWS. If your effective mode is none or default, those models appear unavailable and calls fail with a ValidationException.
  • Most other models do not require review, and setting aws_review does not make them retain data.
  • If cross-Region inference is on, retained data is stored in the destination Regions.
  • Zero data retention for models that require retention is a per-account, per-model eligibility decision made with AWS and the model provider ⚠ VERIFY current eligibility conditions with your AWS account team.
  • Control is enforceable with IAM and SCPs through the condition keys bedrock:DataRetentionMode (control plane) and bedrock-mantle:DataRetentionMode (the OpenAI-compatible endpoint). There was no console toggle at launch; use the API or SDK ⚠ VERIFY current console support.

Banking reading: pick the model after you know your data class and retention rules, not before. A model that needs aws_review is a different conversation with the DPO from a model that allows none.

Where the model runs: Region, geographic and global profiles

OptionProcessing locationSCP implicationFit for bank data
Single Region (in-Region model ID)The Region you callAllow that RegionStrongest residency story; may limit throughput and model choice
Geographic inference profile (for example US or EU prefix)Regions within one geographyAllow every destination Region listed in the profileReasonable when the DPO accepts the geography
Global inference profileAny supported commercial Region worldwide; roughly 10% cheaper according to the AWS comparison tableSCPs must allow aws:RequestedRegion of unspecifiedGenerally not suitable for personal data of UK or EU customers without explicit approval

For a UK bank the usual sequence is: confirm whether the model is available in eu-west-2 (London) or via an EU or UK-appropriate geographic profile ⚠ VERIFY current availability for each model, then decide with the DPO. Module 5's UK GDPR and data residency lesson explains restricted transfers and the UK data bridge; do not repeat its conclusions here without re-checking them.

UK GDPR applied to GenAI

Principle or rightWhat it means for a GenAI system
Lawful basis and purpose limitationEach use case has a recorded lawful basis. "We have the data and the model can use it" is not a purpose
Data minimisationSend the model only the fields it needs. Redact or tokenise account numbers, names and addresses before prompting where the task allows (Bedrock Guardrails can mask PII; do it in your own code too)
AccuracyHallucinated statements about a person are inaccurate personal data. Ground answers in retrieved sources and require citations; keep humans in the loop for anything about a customer
TransparencyTell people when they interact with AI and how decisions are made. A chatbot must not pretend to be a person
Automated decision-making (UK GDPR Article 22, as amended by the Data (Use and Access) Act 2025)Significant decisions about people made solely by automated means are restricted, with safeguards such as human involvement and the right to contest. ⚠ VERIFY the current wording and commencement with legal counsel; treat "meaningful human review" as the default design
Storage limitation and erasurePrompts, completions, invocation logs, agent memory, vector indexes and knowledge-base documents all hold personal data if the content does. Each needs retention and deletion
SecurityEncryption, least privilege, logging, tested backups (Module 5)
Accountability and DPIAA Data Protection Impact Assessment is expected for high-risk processing; new technology on customer data usually qualifies. The DPO decides
Rights requestsYou must be able to find a person's data across all those stores. Design lookup keys (a hashed user ID in logs, for example) before launch

Model risk: the regulators' frame

Banks already have model-risk management. For a UK bank the main reference is the PRA's supervisory statement SS1/23, Model risk management principles for banks, effective 17 May 2024. As described in secondary sources it applies formally to firms with internal-model permissions for regulatory capital and is widely used as the benchmark for others; the Bank of England has said AI and machine-learning models fall within model risk. ⚠ VERIFY the scope paragraph and the current version on the Bank of England site. In the US the equivalent heritage is the Federal Reserve and OCC guidance SR 11-7.

The five habits that every framework shares, translated to GenAI:

HabitGenAI meaning
InventoryEvery GenAI use case, model ID, prompt template, data source and owner is recorded
TieringRisk-based: an internal drafting aid gets lighter treatment than a customer-facing answer
Independent validationSomeone not on the build team tests behaviour on representative and adversarial cases before launch
Ongoing monitoringQuality, safety and drift checks in production, with thresholds and escalation
Change managementModel version, prompt, guardrail and source-document changes go through controlled release

EU AI Act pointer (for the EU subsidiary). Annex III lists AI used to assess the creditworthiness of natural persons as high-risk. The Digital Omnibus agreement on the AI Act postponed the stand-alone high-risk obligations to 2 December 2027 (political agreement reported May 2026; publication in the Official Journal reported July 2026). ⚠ VERIFY the final text and dates with legal counsel. The point for engineers: a GenAI feature that influences credit decisions leaves the "productivity tool" category entirely.

Tools that remain, and those that closed

Several AWS tools that appear in AIF-C01 and AIP-C01 study material are closed to new customers since 2026-07-30: SageMaker AI Clarify and Model Monitor (and Ground Truth and A2I). Learn their names for exams, but do not build on them. Alternatives verified 2026-11-18:

NeedUse instead
Bias and explainability metrics for classic MLSHAP with pandas and scikit-learn bias metrics; SageMaker AI MLflow
Evaluating foundation-model outputsAmazon Bedrock Evaluations and the open-source fmeval library
Runtime content safetyBedrock Guardrails
Monitoring drift and quality in productionCloudWatch metrics and alarms on invocation logs; open-source monitoring solutions (for example MLflow with Evidently AI) from AWS samples
Human review queueBuild your own (see lesson 10)

Microsoft / Azure comparison

You know (Microsoft/Azure)AWS equivalentWhat's different
Azure OpenAI abuse monitoring and data-storage opt-outsBedrock data retention modes and abuse detectionMode is set per Region and enforceable with IAM and SCP condition keys
Azure OpenAI diagnostic logging to Log AnalyticsBedrock model invocation logging to S3 or CloudWatch LogsDisabled by default; same account and Region only; bodies larger than 100 KB go to S3
Azure data zones and global deploymentsGeographic versus global inference profilesGlobal profiles route worldwide; SCPs must allow unspecified
Microsoft Purview and DSPMMacie, your own data inventory, CloudWatch Logs data protectionNo single managed DSAR product
Azure AI Foundry evaluationsBedrock Evaluations and fmevalDifferent metrics and job model
Azure Policy for allowed models and locationsSCPs with bedrock:InvokeModel resource ARNs and aws:RequestedRegionEnforced at API call time
Model cards and registriesYour own model inventory (this lesson); SageMaker Model Registry for self-built modelsFor foundation models the inventory is mostly use-case records

Architecture

Security-boundary view. Personal data crosses four boundaries: from the user into your app (authentication), from your app to Bedrock (minimisation, IAM, VPC endpoint, retention mode, Region), from Bedrock to your log stores (encryption, access, expiry), and from your stores to people who investigate (least privilege, audit of access). Governance controls (inventory, validation, SCPs) sit around the flow and are checked before and after release.

Step-by-step implementation

Step one: draw the data flow and classify it

List every field that can reach a prompt, every store the system writes (logs, memory, vector index, cache), and the data class of each. This single diagram answers most of the DPO's first questions.

Step two: choose Region, profile and model against your data class

Use the table above. Record the decision, the retention mode and the reasons in the inventory entry.

Step three: minimise before you prompt

Remove fields the task does not need, tokenise identifiers (for example replace an account number with a short-lived token), and keep a mapping on your side if you must re-insert values after the model responds.

Step four: decide whether to log bodies, and protect the logs

Invocation logging gives you evidence and a new store of personal data. Decide with the DPO: log bodies in a short-retention, KMS-encrypted bucket for validated pilots; log metadata only for production use cases with sensitive content (lesson 9 shows what to detect in them).

Step five: register the use case and run the rule checks

Create the inventory entry, run the rules in CI, attach the DPIA and validation references, and schedule the next review.

Step six: monitor and review

Track token use, guardrail interventions, refusal and error rates, human-reviewer overrides and complaint volumes. Re-validate when the model ID, prompt, retrieval sources or guardrail change.

AWS Console instructions

Console labels change, so ⚠ VERIFY them:

  • Console → Amazon Bedrock → Settings → Model invocation logging. Choose the data types (text, image, embedding, video), the destination (S3, CloudWatch Logs or both) and the bucket or log group. Only destinations in the same account and Region work.
  • Console → Amazon Bedrock → Model catalog to see which models are available in us-east-1 or your chosen Region, and any availability or retention notes.
  • Console → CloudTrail → Event history, filter by event source bedrock.amazonaws.com, and open an event to read additionalEventData.inferenceRegion for cross-Region calls.
  • Console → AWS Organizations → Policies → Service control policies to attach Region, model or retention-mode guard rails.

AWS CLI

# Read the current model invocation logging configuration (read-only)
aws bedrock get-model-invocation-logging-configuration \
  --region us-east-1 --profile learn-sandbox

# Enable invocation logging to the S3 bucket created by the CDK stack below.
# Replace BUCKET with the stack output LogBucketName.
aws bedrock put-model-invocation-logging-configuration \
  --region us-east-1 --profile learn-sandbox \
  --logging-config '{
    "s3Config": { "bucketName": "BUCKET", "keyPrefix": "bedrock" },
    "textDataDeliveryEnabled": true,
    "imageDataDeliveryEnabled": false,
    "embeddingDataDeliveryEnabled": false,
    "videoDataDeliveryEnabled": false
  }'

# Turn logging off again (the logs already written stay in S3 until they expire)
aws bedrock delete-model-invocation-logging-configuration \
  --region us-east-1 --profile learn-sandbox

# Read the account data retention mode for this Region (control plane).
# ⚠ VERIFY: the CLI subcommand name; the documented REST call is GET /data-retention on the bedrock endpoint.
aws bedrock get-account-data-retention --region us-east-1 --profile learn-sandbox

Infrastructure as Code

CloudFormation has no resource for the logging configuration itself (checked 2026-11-18), so the pattern is: CDK builds the encrypted bucket and key with the correct service-principal policies, and the configuration is switched on with the CLI or with Terraform's aws_bedrock_model_invocation_logging_configuration.

BedrockLoggingStack.cs
using Amazon.CDK;
using Amazon.CDK.AWS.IAM;
using Amazon.CDK.AWS.KMS;
using Amazon.CDK.AWS.S3;
using Constructs;

public class BedrockLoggingStack : Stack
{
    public BedrockLoggingStack(Construct scope, string id, IStackProps props) : base(scope, id, props)
    {
        var bedrock = new ServicePrincipal("bedrock.amazonaws.com");
        var sourceConditions = new Dictionary<string, object>
        {
            ["StringEquals"] = new Dictionary<string, object> { ["aws:SourceAccount"] = this.Account },
            ["ArnLike"] = new Dictionary<string, object> { ["aws:SourceArn"] = $"arn:aws:bedrock:{this.Region}:{this.Account}:*" }
        };

        var key = new Key(this, "LogKey", new KeyProps
        {
            Alias = "alias/hl-m16-bedrock-invocation-logs",
            EnableKeyRotation = true,
            RemovalPolicy = RemovalPolicy.DESTROY       // lab only
        });
        key.AddToResourcePolicy(new PolicyStatement(new PolicyStatementProps
        {
            Sid = "AllowBedrockToEncryptLogs",
            Principals = [bedrock],
            Actions = ["kms:GenerateDataKey"],
            Resources = ["*"],
            Conditions = sourceConditions
        }));

        var bucket = new Bucket(this, "LogBucket", new BucketProps
        {
            Encryption = BucketEncryption.KMS,
            EncryptionKey = key,
            BlockPublicAccess = BlockPublicAccess.BLOCK_ALL,
            EnforceSSL = true,
            ObjectOwnership = ObjectOwnership.BUCKET_OWNER_ENFORCED,   // ACLs disabled, as Bedrock requires
            Versioned = true,
            LifecycleRules =
            [
                new LifecycleRule { Id = "expire-after-90-days", Expiration = Duration.Days(90) }
            ],
            RemovalPolicy = RemovalPolicy.DESTROY,       // lab only
            AutoDeleteObjects = true                      // lab only
        });
        bucket.AddToResourcePolicy(new PolicyStatement(new PolicyStatementProps
        {
            Sid = "AmazonBedrockLogsWrite",
            Principals = [bedrock],
            Actions = ["s3:PutObject"],
            Resources = [bucket.ArnForObjects($"bedrock/AWSLogs/{this.Account}/BedrockModelInvocationLogs/*")],
            Conditions = sourceConditions
        }));

        // Mandatory tags. Inside a Stack write Amazon.CDK.Tags, not Tags.
        Amazon.CDK.Tags.Of(this).Add("Project", "cea-lab");
        Amazon.CDK.Tags.Of(this).Add("Lab", "m16-privacy");
        Amazon.CDK.Tags.Of(this).Add("Environment", "learn");

        new CfnOutput(this, "LogBucketName", new CfnOutputProps { Value = bucket.BucketName });
    }
}

This stack compiled against Amazon.CDK.Lib 2.277.0 on 2026-11-18.

⚠ Learning shortcut — not for production

RemovalPolicy.DESTROY and AutoDeleteObjects make teardown easy, and they are exactly wrong for audit logs. In production the log bucket lives in a dedicated logging account, uses Object Lock and RETAIN, is readable only by a small audit role, and the 90-day expiry is whatever your retention schedule and DPO decide, not a number copied from a tutorial. Also confirm whether logging full bodies is justified at all for the data class.

Complete code

The inventory rules below compiled and ran in Docker with the .NET 10 SDK on 2026-11-18. They need no NuGet packages.

ModelInventory.cs
using System.Security.Cryptography;
using System.Text;

namespace Harbourline.ModelRisk;

public enum DataClass { Public = 0, Internal = 1, Confidential = 2, Restricted = 3 }

public enum OutputUse { InternalDraft, StaffDecisionSupport, CustomerFacing, AutomatedDecision }

public enum RiskTier { Low = 0, Medium = 1, High = 2 }

/// <summary>One row of the GenAI model inventory. Facts about a use case, not about the model alone.</summary>
public sealed record ModelInventoryEntry(
    string UseCaseId,
    string Name,
    string Owner,
    string ModelId,                 // pinned ID or inference-profile ID, never "latest"
    string Region,
    bool GlobalInferenceProfile,    // true = requests may be processed in any supported Region
    DataClass HighestDataClass,
    OutputUse OutputUse,
    bool HumanReview,
    RiskTier DeclaredTier,
    bool InvocationLoggingEnabled,
    string? DpiaReference,
    string? ValidationReference,
    DateOnly? LastValidated,
    DateOnly NextReview);

public sealed record Finding(string Rule, string Message);

public static class InventoryRules
{
    /// <summary>The lowest tier the facts allow. A declared tier below this is a finding.</summary>
    public static RiskTier MinimumTier(ModelInventoryEntry e)
    {
        if (e.OutputUse is OutputUse.CustomerFacing or OutputUse.AutomatedDecision) return RiskTier.High;
        if (e.HighestDataClass >= DataClass.Confidential) return RiskTier.High;
        if (e.OutputUse == OutputUse.StaffDecisionSupport || e.HighestDataClass == DataClass.Internal)
            return RiskTier.Medium;
        return RiskTier.Low;
    }

    public static IReadOnlyList<Finding> Validate(ModelInventoryEntry e, DateOnly today)
    {
        var f = new List<Finding>();
        var min = MinimumTier(e);

        if (string.IsNullOrWhiteSpace(e.ModelId) || e.ModelId.Contains("latest", StringComparison.OrdinalIgnoreCase))
            f.Add(new("R1", "Model ID must be pinned. Floating aliases change behaviour without a validation."));

        if (e.DeclaredTier < min)
            f.Add(new("R2", $"Declared tier {e.DeclaredTier} is below the minimum {min} for these facts."));

        if (e.HighestDataClass >= DataClass.Confidential && string.IsNullOrWhiteSpace(e.DpiaReference))
            f.Add(new("R3", "Confidential or restricted data requires a DPIA reference."));

        if (e.HighestDataClass == DataClass.Restricted)
            f.Add(new("R4", "Restricted data (for example customer personal data) must not be sent to a model without explicit risk and DPO approval."));

        if (min == RiskTier.High && string.IsNullOrWhiteSpace(e.ValidationReference))
            f.Add(new("R5", "High-tier use requires an independent validation reference."));

        if (e.OutputUse == OutputUse.AutomatedDecision && !e.HumanReview)
            f.Add(new("R6", "Automated decisions about people need meaningful human involvement. Escalate to legal and the DPO."));

        if (e.GlobalInferenceProfile && e.HighestDataClass >= DataClass.Internal)
            f.Add(new("R7", "A global inference profile may process requests in any supported Region. Use a geographic profile or a single Region."));

        if (min >= RiskTier.Medium && !e.InvocationLoggingEnabled)
            f.Add(new("R8", "Medium and high tiers need invocation logging (or equivalent) so decisions can be reconstructed."));

        if (min >= RiskTier.Medium)
        {
            var maxAge = min == RiskTier.High ? 365 : 730;
            if (e.LastValidated is null || today.DayNumber - e.LastValidated.Value.DayNumber > maxAge)
                f.Add(new("R9", $"Validation is missing or older than {maxAge} days."));
        }

        if (e.NextReview < today)
            f.Add(new("R10", "Scheduled review date has passed."));

        return f;
    }
}

/// <summary>Metadata-only audit record: enough to reconstruct what happened, without storing the prompt text.</summary>
public sealed record InferenceAuditRecord(
    string RequestId,
    DateTimeOffset At,
    string UserIdHash,
    string UseCaseId,
    string ModelId,
    int InputTokens,
    int OutputTokens,
    string PromptHmac,
    string? GuardrailAction)
{
    public static InferenceAuditRecord Create(
        byte[] hmacKey, string requestId, string userId, string useCaseId, string modelId,
        string prompt, int inputTokens, int outputTokens, string? guardrailAction, DateTimeOffset? at = null)
    {
        using var hmac = new HMACSHA256(hmacKey);
        string H(string s) => Convert.ToHexString(hmac.ComputeHash(Encoding.UTF8.GetBytes(s)));
        return new InferenceAuditRecord(requestId, at ?? DateTimeOffset.UtcNow, H("user:" + userId),
            useCaseId, modelId, inputTokens, outputTokens, H("prompt:" + prompt), guardrailAction);
    }
}

A driver with one acceptable and one deliberately bad entry:

Program.cs
using Harbourline.ModelRisk;

var today = new DateOnly(2026, 11, 18);

var good = new ModelInventoryEntry(
    "UC-001", "Policy Q&A (internal)", "ops-knowledge", "anthropic.claude-sonnet-5-5", "us-east-1",
    GlobalInferenceProfile: false, DataClass.Internal, OutputUse.StaffDecisionSupport, HumanReview: true,
    RiskTier.Medium, InvocationLoggingEnabled: true, DpiaReference: null, ValidationReference: "VAL-2026-014",
    LastValidated: new DateOnly(2026, 9, 1), NextReview: new DateOnly(2027, 3, 1));

var bad = good with
{
    UseCaseId = "UC-002", Name = "Complaint auto-reply",
    ModelId = "anthropic.claude-sonnet-latest", GlobalInferenceProfile = true,
    HighestDataClass = DataClass.Restricted, OutputUse = OutputUse.CustomerFacing,
    DeclaredTier = RiskTier.Low, InvocationLoggingEnabled = false, ValidationReference = null,
    LastValidated = null, NextReview = new DateOnly(2026, 6, 1)
};

foreach (var e in new[] { good, bad })
{
    var findings = InventoryRules.Validate(e, today);
    Console.WriteLine($"{e.UseCaseId} {e.Name}: minimum tier {InventoryRules.MinimumTier(e)}, {findings.Count} finding(s)");
    foreach (var f in findings) Console.WriteLine($"  {f.Rule}: {f.Message}");
}

var key = new byte[32]; // lab only: load the HMAC key from Secrets Manager or KMS in real code
var rec = InferenceAuditRecord.Create(key, "req-1", "alice", "UC-001", good.ModelId,
    "What is the overdraft fee policy?", 25, 120, null, new DateTimeOffset(2026, 11, 18, 9, 0, 0, TimeSpan.Zero));
Console.WriteLine($"audit: {rec.RequestId} user={rec.UserIdHash[..8]}... prompt={rec.PromptHmac[..8]}... tokens={rec.InputTokens}/{rec.OutputTokens}");

Verified output:

UC-001 Policy Q&A (internal): minimum tier Medium, 0 finding(s)
UC-002 Complaint auto-reply: minimum tier High, 9 finding(s)
  R1: Model ID must be pinned. Floating aliases change behaviour without a validation.
  R2: Declared tier Low is below the minimum High for these facts.
  R3: Confidential or restricted data requires a DPIA reference.
  R4: Restricted data (for example customer personal data) must not be sent to a model without explicit risk and DPO approval.
  R5: High-tier use requires an independent validation reference.
  R7: A global inference profile may process requests in any supported Region. Use a geographic profile or a single Region.
  R8: Medium and high tiers need invocation logging (or equivalent) so decisions can be reconstructed.
  R9: Validation is missing or older than 365 days.
  R10: Scheduled review date has passed.
audit: req-1 user=17A625E9... prompt=D4F29E01... tokens=25/120

To attach the audit record to a real Bedrock call, put non-sensitive tags in the Converse request's RequestMetadata (for example the use-case ID), which Bedrock copies into invocation-log entries for later filtering ⚠ VERIFY the exact ConverseRequest.RequestMetadata property in your SDK version. Never put personal data in metadata, tags or names.

Code explained line by line

  1. The three enums encode vocabulary the risk team already uses. DataClass is ordered so comparisons such as >= Confidential work.
  2. ModelInventoryEntry is a record of facts about a use case. The model ID is a string so it can be an inference-profile ID. GlobalInferenceProfile captures the Regional-routing decision explicitly.
  3. MinimumTier computes the lowest acceptable tier from the facts. Customer-facing or automated output, or confidential data, forces High. A declared tier below it is finding R2, which stops teams from "self-certifying" Low.
  4. Validate returns findings instead of throwing, so CI can print all problems at once and the risk team can read them.
  5. R1 rejects blank or latest IDs. Floating aliases change behaviour without a validation event.
  6. R4 is deliberately blunt: restricted data in a prompt is a finding every time until a human approves it with a DPO sign-off, so the exception is visible.
  7. R7 flags global inference profiles for anything above public data, reflecting the routing rules above.
  8. R9 uses a validation age limit (365 days for High, 730 for Medium). The numbers are illustrative; your policy sets them.
  9. InferenceAuditRecord.Create stores HMAC-SHA256 of the user ID and the prompt, not the text. The HMAC proves later that a given prompt was the one sent (recompute and compare) without keeping the prompt in the audit store. Use a secret key from a managed store, and note that hashing is pseudonymisation, not anonymisation: it is still personal data.
  10. The audit record keeps counts, the model ID and the guardrail action: enough to reconstruct the event and charge costs.

Security considerations

  • Logs are a data store. When invocation logging is on, full prompts and completions land in S3 or CloudWatch. Encrypt with a customer managed key, block public access, restrict read access to an audit role, set retention, and include the bucket in your erasure and DSAR procedures.
  • Least privilege for invocation. Allow bedrock:InvokeModel on specific model or inference-profile ARNs only; deny the rest by SCP. Remember geographic profiles need all destination-Region foundation-model ARNs in the policy ⚠ VERIFY the exact resource ARNs for the profile you use.
  • VPC endpoints. Use the Bedrock runtime interface endpoint with an endpoint policy for workloads in private subnets so traffic does not need a NAT or the public internet.
  • Do not put personal data in free-text names or tags (the Bedrock data-protection page says tags and name fields may be used in billing and diagnostic logs).
  • Memory, vector stores and caches hold derived personal data. Give each a retention rule and a deletion path keyed to the data subject.
  • Model lifecycle. Providers retire model versions. Pin IDs, subscribe to deprecation notices ⚠ VERIFY where Bedrock publishes them, and treat a model change like any other material change: re-validate before switching.
  • Never claim compliance. Say "the design supports the bank's DPIA and model-risk process", not "this is GDPR compliant".

⚠ Learning shortcut — not for production

The HMAC key in the sample is 32 zero bytes, the inventory is an in-memory record, and the rules are checked on a console run. In production the key comes from AWS Secrets Manager or KMS and is rotated, the inventory lives in a governed system of record (for example a database with change history, owned by model risk), the rules run in CI for every change to a prompt template or model ID, and findings block the release rather than printing a line.

Banking use case

Harbourline internal policy Q&A (inventory UC-001). Staff ask questions about fee policies. Data class Internal, no customer data in prompts, output is staff decision support with citations. Minimum tier Medium. Region us-east-1 for the lab; production would use the Region and profile the DPO approves. Invocation logging on with 90-day expiry for the pilot. Validation: a set of 200 fictional questions with known answers plus 50 adversarial prompts, scored by two reviewers who did not build it. Monitoring: weekly sample of 25 answers, guardrail intervention rate, thumbs-down rate, and a trigger to re-validate if the model ID, prompt or document set changes. The recommendation to the risk committee is go for a staff pilot, with a no-go for any customer-facing version until it has its own tier-High assessment.

Common mistakes

  • Treating "Bedrock does not train on my data" as the whole answer. Retention, logging, Region routing, memory and vector stores are separate questions.
  • Enabling invocation logging and forgetting it is now a personal-data store.
  • Choosing a global inference profile for cost without checking residency and the SCP consequences.
  • Letting model IDs float. A silent model change is an unvalidated change.
  • Self-assigning the lowest tier to avoid review. Compute the minimum tier from the facts.
  • Hashing as anonymisation. A hashed user ID can still be linked back; it is pseudonymised.
  • Validating once. Prompts, sources, models and guardrails drift. Schedule re-validation and trigger it on change.
  • Building on SageMaker Clarify or Model Monitor after the 2026-07-30 closure.

Troubleshooting

SymptomLikely causeFix
ValidationException when invoking a modelThe model requires a retention mode (for example aws_review) that the account's effective mode does not satisfyCheck the model's allowed modes and the account setting with your AWS team and DPO; choose another model if review is not acceptable
Model shows as unavailable in the catalogRegion availability or retention-mode mismatchCheck the Region and the data-retention setting
Logging configuration fails with access deniedBucket policy missing the Bedrock service principal, ACLs enabled, or KMS key policy lacks kms:GenerateDataKey for BedrockUse the policies shown above; set object ownership to bucket owner enforced
No log objects appearLogging disabled, wrong Region, or calls made through a different endpointLogging is per Region and covers bedrock-runtime calls; confirm with get-model-invocation-logging-configuration
SCP blocks a cross-Region profileDestination Region not allowedAllow all Regions in the profile (or unspecified for global) or pick a single-Region model
Large prompts missing from logsBodies over 100 KB are stored as separate S3 objectsProvide an S3 location for large data delivery and look under the data prefix
Inventory check passes locally, fails in CIDifferent today date or stale fixtureInject the date and keep fixtures in source control

Cost and cleanup

Costs. The inventory code is free. The optional logging exercise costs a few cents for an S3 bucket, a KMS key (USD 1 per month if left for a month) and a handful of Bedrock calls ⚠ VERIFY current prices. Deploy-and-destroy within the hour.

Teardown.

# 1. Turn off invocation logging first, so nothing writes while you delete
aws bedrock delete-model-invocation-logging-configuration \
  --region us-east-1 --profile learn-sandbox

# 2. Destroy the infrastructure (CDK path)
cdk destroy hl-m16-bedrock-logging --profile learn-sandbox
#    or (Terraform path)
terraform destroy

# 3. Confirm nothing tagged for the lab remains
aws resourcegroupstaggingapi get-resources \
  --tag-filters Key=Project,Values=cea-lab \
  --region us-east-1 --profile learn-sandbox \
  --query "ResourceTagMappingList[].ResourceARN"

A KMS key is scheduled for deletion with a waiting period (7 to 30 days), so it may still appear briefly and bill until deletion completes.

Exercises

  • 🟢 Guided: run the sample, then add a third inventory entry that passes with zero findings at tier High (customer-facing assistant with human review). List every field you had to fill in.
  • 🟡 Challenge: add rule R11: a use case whose HighestDataClass is Internal or above must have Region equal to an approved Region from a configurable list. Add rule R12: an AutomatedDecision use case must always produce a finding that says "legal review required" even if everything else passes.
  • 🔴 Live problem: a vendor offers a GenAI "customer sentiment" service for complaint emails, hosted outside the UK, which stores the emails for 30 days "to improve the service". Write the model-risk and privacy questions you would send back, and say what evidence would let you approve a pilot.

Assignment

Write a one-page GenAI data-flow and retention note for the policy Q&A assistant: a data-flow diagram, a table of every store with its data class, retention period and deletion method, the Region and inference-profile decision, the retention-mode setting, and the inventory entry with rule results. Attach the verified output of the rules.

Solutions

Knowledge check

Interview questions

  • Where does a prompt go when you call Bedrock, and who can see it? From your app over TLS to the Bedrock runtime endpoint in a chosen Region (or the destination Region of an inference profile), processed in an AWS-operated model deployment account the model provider cannot access. Retention depends on the mode and model; AWS may retain for abuse detection and, for some models, review. Your own logging adds another copy you control.
  • How would you explain model risk for a foundation model you cannot inspect? Assurance shifts from inspecting the model to testing behaviour on your use case, monitoring in production, controlling changes and vendor due diligence.
  • How do you handle a right-to-erasure request when prompts are logged? Identify all stores (logs, memory, vector index, caches), use data-subject-keyed identifiers so records can be found, delete or crypto-shred, and note any legal retention exceptions with the DPO. Prefer logging metadata over bodies to make this tractable.
  • Why pin the model ID? A model change alters behaviour; pinning makes the change visible and gives you a validation checkpoint.
  • What makes a GenAI use case high risk in a bank? Customer-facing output, influence on credit or eligibility decisions, restricted data in prompts, or autonomy over actions.

Certification practice

Completion checklist

  • I can explain Bedrock's retention modes and when a model requires aws_review
  • I can choose between single-Region, geographic and global inference and defend the choice
  • I ran the inventory rules and understand each finding
  • I can list every store that may hold personal data in a GenAI system
  • I ran the cleanup steps and confirmed nothing tagged Project=cea-lab is still billing

Key takeaways

  • Bedrock model providers cannot access your prompts, but retention, logging, Region routing, memory and vector stores are your responsibility to design and justify.
  • Retention is a mode per Region and a per-model requirement; some models need aws_review. Enforce choices with IAM and SCP condition keys.
  • Global inference profiles trade residency for cost; geographic or single-Region is the default for bank personal data.
  • Model risk for GenAI means inventory, tiering, independent validation, monitoring and change control, with prompts and sources inside the change scope.
  • Compute the minimum risk tier from the facts, log metadata not bodies where possible, and never claim compliance.

Further reading

Independent learning resource — not affiliated with, endorsed or sponsored by Amazon Web Services. AWS and related marks are trademarks of Amazon.com, Inc. or its affiliates. All banking data in examples is fictional. Sample architectures are for learning and are not automatically compliant with GDPR, PCI DSS or any banking regulation.

On this page