Skip to content
AWS

Chat With Your Own Docs: Bedrock Knowledge Bases and S3 Vectors, Deployed with CDK

Turning my own blog posts into a searchable knowledge base on AWS, using Amazon Bedrock Knowledge Bases with S3 Vectors so it costs pennies instead of a standing monthly charge

In the last post I put a model behind an HTTP endpoint. It answers well from what it learned in training, but it knows nothing about me. Ask it what I wrote about budget alerts and it will guess. This post fixes that by giving the model my own blog posts to answer from, using Amazon Bedrock Knowledge Bases. This pattern is called retrieval augmented generation, or RAG.

What We Are Building

The idea in four steps:

  1. The documents are split into chunks of a few hundred words each
  2. Each chunk is turned into a list of numbers (an embedding) that represents its meaning, and stored in a vector index
  3. When you ask a question, the question gets the same treatment, and the index returns the chunks closest in meaning
  4. Those chunks are handed to a model along with the question, so it answers from your text rather than from memory, and tells you which files it used

Bedrock Knowledge Bases does all four, so there is no code to write for the chunking, embedding or search. The pieces are:

  • An S3 bucket holding the documents, which here are the markdown files for this blog
  • An S3 Vectors bucket and index to hold the embeddings
  • A knowledge base, which ties the two together and uses Titan Text Embeddings V2 to create the embeddings
  • An IAM role that lets the knowledge base read the bucket, call the embedding model and write to the index, and nothing more
  • All of it defined in the CDK, in the same style as the last post

I am using a new CDK project for this rather than adding to the chatbot one. That keeps cdk deploy simple, because the chatbot stack insists on an API token, and it means this stack can be destroyed on its own. The next post joins the two together.

Why S3 Vectors

A knowledge base needs somewhere to keep its vectors, and the choice matters more for your bill than any other decision in this post. Bedrock supports several vector stores. Some, such as OpenSearch Serverless, run continuously and have a minimum charge for every hour they exist, whether or not anyone asks a question. That is a poor fit for a demo I plan to delete, and exactly the sort of thing the budget alert is there to catch.

Amazon S3 Vectors is different. You pay for the vectors you store and for the requests you make, with nothing running in between. It is available in eu-west-2, it is supported by Knowledge Bases, and for a few dozen documents the bill is pennies at most.

There are trade-offs, and I think they are fine here:

  • Through Knowledge Bases it does semantic search only, according to the integration documentation. S3 Vectors itself now shows a full-text search option on its indexes in the console, but I did not try it and I do not know whether Knowledge Bases can use it. So assume no keyword or hybrid search here, which means a search for an exact error code or a product name will do worse than a keyword engine
  • Queries are fast enough for a chatbot (the S3 Vectors documentation quotes sub-second cold queries and as low as 100 milliseconds when warm; I did not time them) but it is not built for very high query rates
  • The metadata you can attach to each chunk is limited

If you outgrow it, the knowledge base can be pointed at a different store later, but you would re-ingest your documents.

Before We Start

  • The sandbox account and sandbox profile from the sandbox post, signed in with aws sso login --profile sandbox
  • The IAMFullAccess policy on the sandbox permission set, from the chatbot post. This stack creates IAM roles, so it needs the same extra permission, and you can detach it after the last build in the series
  • The CDK bootstrapped in eu-west-2, which the chatbot post covers. If you skipped that post, run cdk bootstrap first, as shown there
  • The AWS CDK CLI, Python 3 and uv, as before
  • The eu-west-2 Region, as in the rest of the series. Titan Text Embeddings V2 and S3 Vectors are both listed as available there (see the Knowledge Bases supported models page and the S3 Vectors Regions list), and I deployed it there, but check both if you use another Region
  • A folder of documents to search. I am using this blog’s own content/english/blog folder, which is public anyway. If you use private documents, remember that their text is stored in your vector index and sent to the embedding model and the answering model

Create the Project

bash
mkdir docs-kb
cd docs-kb
uv venv
source .venv/bin/activate

Create requirements.txt:

text
aws-cdk-lib>=2.278.0
constructs>=10.0.0,<11.0.0
boto3

The boto3 line is for the query script later. The Lambda function in the chatbot post got it for free, but on your own machine it has to be installed.

bash
uv pip install -r requirements.txt
printf '.venv/\ncdk.out/\n__pycache__/\n' > .gitignore

Create cdk.json:

json
{
  "app": "python3 app.py"
}

Create app.py:

python
#!/usr/bin/env python3
import aws_cdk as cdk

from kb_stack import DocsKnowledgeBaseStack

app = cdk.App()
DocsKnowledgeBaseStack(
    app,
    "DocsKnowledgeBase",
    env=cdk.Environment(region="eu-west-2"),
)
app.synth()

The Infrastructure

Save this as kb_stack.py. It is longer than the chatbot stack, because a knowledge base is five pieces that each need configuring, so I have numbered them in the comments:

python
from aws_cdk import (
    CfnOutput,
    RemovalPolicy,
    Stack,
    aws_bedrock as bedrock,
    aws_iam as iam,
    aws_s3 as s3,
    aws_s3vectors as s3vectors,
)
from constructs import Construct

EMBEDDING_MODEL_ID = "amazon.titan-embed-text-v2:0"
EMBEDDING_DIMENSIONS = 1024


class DocsKnowledgeBaseStack(Stack):
    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)

        # 1. The documents: a private bucket that is emptied when the stack is destroyed.
        docs_bucket = s3.Bucket(
            self,
            "DocsBucket",
            block_public_access=s3.BlockPublicAccess.BLOCK_ALL,
            enforce_ssl=True,
            removal_policy=RemovalPolicy.DESTROY,
            auto_delete_objects=True,
        )

        # 2. The vector store: an S3 vector bucket and one index inside it.
        vector_bucket = s3vectors.CfnVectorBucket(self, "VectorBucket")
        vector_index = s3vectors.CfnIndex(
            self,
            "VectorIndex",
            vector_bucket_arn=vector_bucket.attr_vector_bucket_arn,
            data_type="float32",
            dimension=EMBEDDING_DIMENSIONS,
            distance_metric="cosine",
            # Bedrock keeps each chunk's text and metadata here; they cannot be filtered on.
            metadata_configuration=s3vectors.CfnIndex.MetadataConfigurationProperty(
                non_filterable_metadata_keys=[
                    "AMAZON_BEDROCK_TEXT",
                    "AMAZON_BEDROCK_METADATA",
                ],
            ),
        )

        embedding_model_arn = (
            f"arn:aws:bedrock:{self.region}::foundation-model/{EMBEDDING_MODEL_ID}"
        )

        # 3. The role the knowledge base uses while syncing: read the bucket,
        #    call the embedding model, write to the vector index. Nothing else.
        kb_role = iam.Role(
            self,
            "KnowledgeBaseRole",
            assumed_by=iam.ServicePrincipal(
                "bedrock.amazonaws.com",
                conditions={
                    "StringEquals": {"aws:SourceAccount": self.account},
                    "ArnLike": {
                        "aws:SourceArn": f"arn:aws:bedrock:{self.region}:{self.account}:knowledge-base/*"
                    },
                },
            ),
        )
        kb_role.add_to_policy(
            iam.PolicyStatement(
                actions=["bedrock:InvokeModel"],
                resources=[embedding_model_arn],
            )
        )
        kb_role.add_to_policy(
            iam.PolicyStatement(
                actions=["s3:ListBucket"],
                resources=[docs_bucket.bucket_arn],
                conditions={"StringEquals": {"aws:ResourceAccount": self.account}},
            )
        )
        kb_role.add_to_policy(
            iam.PolicyStatement(
                actions=["s3:GetObject"],
                resources=[docs_bucket.arn_for_objects("*")],
                conditions={"StringEquals": {"aws:ResourceAccount": self.account}},
            )
        )
        kb_role.add_to_policy(
            iam.PolicyStatement(
                actions=[
                    "s3vectors:GetIndex",
                    "s3vectors:PutVectors",
                    "s3vectors:GetVectors",
                    "s3vectors:DeleteVectors",
                    "s3vectors:QueryVectors",
                ],
                resources=[vector_index.attr_index_arn],
            )
        )

        # 4. The knowledge base itself.
        kb = bedrock.CfnKnowledgeBase(
            self,
            "KnowledgeBase",
            name="blog-docs",
            role_arn=kb_role.role_arn,
            knowledge_base_configuration=bedrock.CfnKnowledgeBase.KnowledgeBaseConfigurationProperty(
                type="VECTOR",
                vector_knowledge_base_configuration=bedrock.CfnKnowledgeBase.VectorKnowledgeBaseConfigurationProperty(
                    embedding_model_arn=embedding_model_arn,
                    embedding_model_configuration=bedrock.CfnKnowledgeBase.EmbeddingModelConfigurationProperty(
                        bedrock_embedding_model_configuration=bedrock.CfnKnowledgeBase.BedrockEmbeddingModelConfigurationProperty(
                            dimensions=EMBEDDING_DIMENSIONS,
                            embedding_data_type="FLOAT32",
                        ),
                    ),
                ),
            ),
            storage_configuration=bedrock.CfnKnowledgeBase.StorageConfigurationProperty(
                type="S3_VECTORS",
                s3_vectors_configuration=bedrock.CfnKnowledgeBase.S3VectorsConfigurationProperty(
                    index_arn=vector_index.attr_index_arn,
                ),
            ),
        )
        # Make sure the role's permissions exist before Bedrock tries to use them.
        kb.node.add_dependency(kb_role)

        # 5. The data source: the bucket, split into chunks of about 400 tokens.
        data_source = bedrock.CfnDataSource(
            self,
            "DataSource",
            name="blog-posts",
            knowledge_base_id=kb.attr_knowledge_base_id,
            data_source_configuration=bedrock.CfnDataSource.DataSourceConfigurationProperty(
                type="S3",
                s3_configuration=bedrock.CfnDataSource.S3DataSourceConfigurationProperty(
                    bucket_arn=docs_bucket.bucket_arn,
                ),
            ),
            # Delete the vectors when the data source is deleted, so destroy leaves nothing behind.
            data_deletion_policy="DELETE",
            vector_ingestion_configuration=bedrock.CfnDataSource.VectorIngestionConfigurationProperty(
                chunking_configuration=bedrock.CfnDataSource.ChunkingConfigurationProperty(
                    chunking_strategy="FIXED_SIZE",
                    fixed_size_chunking_configuration=bedrock.CfnDataSource.FixedSizeChunkingConfigurationProperty(
                        max_tokens=400,
                        overlap_percentage=10,
                    ),
                ),
            ),
        )

        CfnOutput(self, "DocsBucketName", value=docs_bucket.bucket_name)
        CfnOutput(self, "KnowledgeBaseId", value=kb.attr_knowledge_base_id)
        CfnOutput(self, "DataSourceId", value=data_source.attr_data_source_id)

The parts that matter:

  • Dimensions must match everywhere. Titan V2 can produce 256, 512 or 1024 numbers per chunk. The index, the knowledge base and the embedding settings all say 1024. If the index and the model disagree, ingestion fails, and the index setting cannot be changed after it is created.
  • The two AMAZON_BEDROCK_* metadata keys are where the knowledge base stores each chunk’s text. Marking them non-filterable keeps them out of the small size limit that applies to filterable metadata. These too cannot be changed once the index exists.
  • The role can read this one bucket, call this one embedding model and use this one index. The trust policy only lets Bedrock assume it on behalf of knowledge bases in my account. I could not name the exact knowledge base in that trust policy, because the knowledge base does not exist until the role does, so it uses knowledge-base/*. That means any knowledge base in this account can assume the role, but what the role can do is still limited to this one bucket, this one embedding model and this one index. Tighten the trust policy by hand later if you want.
  • Chunking is fixed-size, about 400 tokens with a 10% overlap. That is my choice, not a recommendation: blog posts have code blocks that I would rather not cut in half, so I went a bit larger than the 300-token default. Chunk size is the setting most worth experimenting with.
  • data_deletion_policy="DELETE" means that removing the data source also removes its vectors. The alternative, RETAIN, keeps the vectors in the index after the data source goes. I used DELETE because I want nothing left behind, and I did not test what RETAIN does to the destroy.
  • The bucket has public access blocked, requires HTTPS and is emptied on destroy. The empty-on-destroy part is done by a small helper Lambda function that the CDK adds to the stack, so you will see one extra function in the deploy.

Deploy It

Check what it will create before it creates it:

bash
cdk synth --profile sandbox
cdk diff --profile sandbox
cdk deploy --profile sandbox

As before, the CDK shows the IAM changes and asks for approval. This time, what you are checking for is that the s3vectors: actions are scoped to the index (not *), and that bedrock:InvokeModel names the Titan model only. The bucket helper function will add a role and policy of its own, which is normal.

When it finishes, put the outputs into shell variables. Deploys print them, and you can read them back at any time:

bash
output() {
  aws cloudformation describe-stacks --stack-name DocsKnowledgeBase \
    --profile sandbox --region eu-west-2 \
    --query "Stacks[0].Outputs[?OutputKey=='$1'].OutputValue" --output text
}
DOCS_BUCKET=$(output DocsBucketName)
KB_ID=$(output KnowledgeBaseId)
DS_ID=$(output DataSourceId)
echo $DOCS_BUCKET $KB_ID $DS_ID

Put the Blog In

Copy the markdown files for this blog into the bucket. Run this from the root of the blog repository, and only the .md files go up:

bash
aws s3 sync content/english/blog s3://$DOCS_BUCKET/blog/ \
  --exclude "*" --include "*.md" --exclude "_index.md" \
  --profile sandbox --region eu-west-2

The knowledge base does not watch the bucket. You have to ask it to sync, which is called an ingestion job:

bash
JOB_ID=$(aws bedrock-agent start-ingestion-job \
  --knowledge-base-id $KB_ID --data-source-id $DS_ID \
  --profile sandbox --region eu-west-2 \
  --query 'ingestionJob.ingestionJobId' --output text)

aws bedrock-agent get-ingestion-job \
  --knowledge-base-id $KB_ID --data-source-id $DS_ID --ingestion-job-id $JOB_ID \
  --profile sandbox --region eu-west-2 \
  --query 'ingestionJob.[status,statistics]'

Run the second command again until status says COMPLETE. For my posts it took well under a minute. My run printed numberOfDocumentsScanned: 16, numberOfNewDocumentsIndexed: 16 and numberOfDocumentsFailed: 0, which matched the 16 files I had uploaded (the folder has 18 .md files: I left out _index.md and the draft of this post). If the number scanned does not match the number of files you uploaded, or anything failed, look at the failureReasons in the full output before going further.

Two things I noticed about my own files. First, Hugo front matter (the block at the top with the title, date and tags) goes into the chunks as ordinary text. That is mildly useful, because the title and tags then help the search, but it is also noise. Second, any post with draft: true is uploaded too, because the sync does not know about Hugo. That is not just a theory: my first run included the draft of this very post (17 documents instead of 16), and it turned up as a source when I asked about the series (more on that below). List your drafts with grep -l '^draft: true' content/english/blog/*.md and add an --exclude for each one before you sync.

Look at It in the Console

I clicked through all of this in the console after deploying, so the labels below are what I saw in November 2026. AWS changes its console often, so expect small differences. One thing to know first: the Bedrock console now also pushes a Create Managed KB option. This post builds the classic kind, where you bring your own vector store, so ignore that button.

  1. Bedrock, then Knowledge Bases (KB) (it sits under Build in the left menu): open blog-docs. The Knowledge Base (KB) overview card shows the status (Available) and the service role. Below it, the Data source table lists blog-posts with type S3 and the text chunking strategy Fixed-size chunking. Further down, Embeddings model shows Titan Text Embeddings v2 with 1024 vector dimensions, and Vector store shows the type Amazon S3 Vectors with the index ARN
  2. S3, then Vector buckets: open the vector bucket, and the Vector indexes tab lists the index with its name, creation date and ARN. Open the index and the Vector index overview shows a dimension of 1024 and a distance metric of Cosine, and the Non-filterable metadata tab lists the two AMAZON_BEDROCK_* keys from the stack. I did not find a vector count anywhere on these pages, so use the ingestion statistics for that. The console also offers a newer Full-text search metadata setting on the index, which I did not use
  3. Back on the knowledge base page, choose Test (top right). A Test Knowledge Base (KB): blog-docs page opens with a Configurations panel on the left and the chat on the right. Under Retrieval and response generation, Standard retrieval with answer generation is already selected, and Standard retrieval only is the console’s version of the Retrieve call below. Choose Select model, pick Amazon, then Nova Micro, leave the inference option as On-demand, and choose Apply. Type a question and press Enter (or choose Run). The answer comes back with numbered footnotes, and choosing Details opens a Source chunks panel with the text of each chunk it used, which is the quickest way to see what the search actually found

Here is the test page after I asked “What permission did I add to the sandbox so the CDK could run?”, with Nova Micro selected. The answer names IAMFullAccess and cites its sources with the numbered footnotes:

The Test Knowledge Base page for blog-docs in the Bedrock console. The Configurations panel on the left has Standard retrieval with answer generation selected and Nova Micro on-demand chosen as the model. The Test panel on the right shows an answer that tells the reader to add IAMFullAccess to the sandbox permission set and to detach it after the last cdk destroy, with a numbered footnote.

And the same page with Details switched on, which shows the three source chunks behind the answer:

The same Test Knowledge Base page with the Details panel open on the right, headed Source chunks (3), showing the text of the first chunk, which is from the chatbot post and talks about the shared token.

Ask It Questions

There are two APIs, and the difference between them is the whole idea of RAG:

  • Retrieve returns the matching chunks and their scores, and nothing else. No model writes anything
  • RetrieveAndGenerate does the same search, then sends the chunks and your question to a model and returns its answer with citations

Start with Retrieve, because it shows you what the search found before any model has a chance to make it sound convincing:

bash
aws bedrock-agent-runtime retrieve \
  --knowledge-base-id $KB_ID \
  --retrieval-query text="What permission did I add to the sandbox so the CDK could run?" \
  --retrieval-configuration '{"vectorSearchConfiguration":{"numberOfResults":3}}' \
  --profile sandbox --region eu-west-2 \
  --query 'retrievalResults[].{score:score,file:location.s3Location.uri,text:content.text}'

You get three chunks, most relevant first. Mine came back like this, all from the chatbot post:

text
0.761  aws-bedrock-chatbot-api.md  The change is applied to the sandbox account, which is a different account from the one yo...
0.753  aws-bedrock-chatbot-api.md  **A shared token** that the function checks before it calls the model, plus a cap on messa...
0.735  aws-bedrock-chatbot-api.md  It does appear in the generated `cdk.out` folder and in the function's environment variabl...

The top hit is the right passage, and the other two are about the same post’s security choices rather than the permission itself, which is typical: scores that close together mean the search is finding the right neighbourhood, not the exact sentence. Read the text of each. If the right passage is not in the top three, the model never gets to see it, and no amount of clever prompting afterwards will help. That is the first thing to check when a RAG system gives a bad answer.

Now the full version. Save this as ask.py, which takes a question as arguments and prints the answer and the files it came from:

python
import os
import sys

import boto3

KB_ID = os.environ["KB_ID"]
MODEL_ARN = os.environ.get(
    "MODEL_ARN",
    "arn:aws:bedrock:eu-west-2::foundation-model/amazon.nova-micro-v1:0",
)

client = boto3.client("bedrock-agent-runtime", region_name="eu-west-2")


def ask(question):
    return client.retrieve_and_generate(
        input={"text": question},
        retrieveAndGenerateConfiguration={
            "type": "KNOWLEDGE_BASE",
            "knowledgeBaseConfiguration": {
                "knowledgeBaseId": KB_ID,
                "modelArn": MODEL_ARN,
                "retrievalConfiguration": {
                    "vectorSearchConfiguration": {"numberOfResults": 5}
                },
                "generationConfiguration": {
                    "inferenceConfig": {
                        "textInferenceConfig": {"maxTokens": 400, "temperature": 0.2}
                    }
                },
            },
        },
    )


if __name__ == "__main__":
    response = ask(" ".join(sys.argv[1:]))
    print(response["output"]["text"])

    sources = []
    for citation in response["citations"]:
        for ref in citation["retrievedReferences"]:
            uri = ref["location"]["s3Location"]["uri"]
            if uri not in sources:
                sources.append(uri)
    print("\nSources:")
    for uri in sources:
        print(" -", uri)

A few notes on it:

  • It fetches five chunks per question, and maxTokens caps the answer at 400 tokens. Both limit what each question can cost
  • The default model is the same Nova Micro as the rest of the series. The plain foundation-model ARN worked for me in eu-west-2. If Bedrock rejects it for you, with the on-demand throughput error described in the first call post, set MODEL_ARN to the inference profile instead: arn:aws:bedrock:eu-west-2:<account id>:inference-profile/eu.amazon.nova-micro-v1:0. That routes requests across EU Regions, which is worth knowing if where your data is processed matters
  • The boto3 client for this API is bedrock-agent-runtime, not bedrock-runtime, which catches people out

Run it with your own profile and the knowledge base ID:

bash
export AWS_PROFILE=sandbox
export KB_ID   # the shell variable from earlier, now visible to Python
python ask.py "How does the chatbot API protect itself if someone finds the URL?"
python ask.py "Which Region and model do I use in this series, and why that model?"
python ask.py "What did I add to the sandbox permissions for the CDK, and why is it risky?"

Each of these has an answer in a post I wrote, so you can check the model’s reply against the source. Here is what I got:

  • The leaked URL question was answered correctly from the chatbot post: the rate limit, the token check returning a 401, and the single-model IAM policy. It cited aws-bedrock-chatbot-api.md and nothing else. It also added some generic advice about IP allow-listing that is not in my post, which is the model padding the answer from its own knowledge
  • The sandbox permission question correctly named IAMFullAccess and why it is effectively administrator access, citing the chatbot post
  • The Region and model question named the right Region and model (eu-west-2 and Nova Micro). In my first run it also cited the draft of this post, which should not have been in the index, and it ran into the 400 token cap and stopped mid-sentence. After I excluded the draft and ran it again, it cited only the first call post, but it confidently described eu-west-2 as “European (Ireland)”. That is wrong: eu-west-2 is London, and nothing in my posts says otherwise. The model made it up to fill the gap, so a cited source does not mean every sentence is in the source

Then I asked one the blog cannot answer, “What is the best pizza in Leeds?”. Both times it said it could not find enough information, suggested local reviews instead, and listed no sources. The second time it also drifted into guessing that Leeds pizza places “could include well-known chains”, which is the same habit as the Ireland mistake in a milder form. Mostly good, but do not read too much into one example. This is the default behaviour of the answering prompt, not a guarantee, and stopping the bot reliably from straying outside my writing is the subject of the guardrails post.

What It Cost

Nothing here runs when you are not using it, so the cost is the sum of a few small, per-use charges:

  • Embeddings: ingestion sends the text of every document through Titan Text Embeddings V2, which is charged per input token. My 16 posts are about 93 KB of markdown, which I would estimate at somewhere between 25,000 and 35,000 tokens (code-heavy text uses more tokens per character than prose). I did not measure it, so treat that as a rough guide and use your own sync to check. Each question you ask is embedded too, which is a handful of tokens
  • S3 Vectors: charged for storage and for the write and query requests. A few dozen chunks is a tiny amount of storage
  • S3: the documents themselves, and the requests to read them during a sync
  • The answering model: Nova Micro charges per input and output token, as in the first call post. The input is bigger than in the chatbot, because five chunks of roughly 400 tokens go in with every question, so a question here sends a couple of thousand input tokens rather than a few dozen. Output is capped at 400
  • The helper Lambda that empties the bucket only does any work when you destroy the stack, but the function and its role are created at deploy

I have not quoted prices, because they change. Check the Bedrock and S3 pricing pages (S3 Vectors is on the S3 page) for your Region. The thing to remember is the shape of the bill: a small cost each time you sync, a small cost each time you ask, and a standing cost only for storage, which is tiny at this size. That is the reason for choosing S3 Vectors, and it is a different shape from a vector store that charges by the hour.

Re-running the sync re-reads the documents, but Bedrock only re-embeds the files that changed, so keeping the knowledge base up to date costs less than building it did.

Cleaning Up

bash
cdk destroy --profile sandbox
unset KB_ID DS_ID DOCS_BUCKET JOB_ID MODEL_ARN

This deletes the knowledge base and data source (and, because of the DELETE policy, the vectors), then the index and vector bucket, then empties and removes the documents bucket and the helper function. When I ran it, it finished in a minute or two and exited cleanly. I then checked that the stack, the documents bucket, the vector bucket and the knowledge base were all gone (aws cloudformation describe-stacks, aws s3 ls, aws s3vectors list-vector-buckets and aws bedrock-agent list-knowledge-bases). Do the same check yourself. If the delete fails on the vector bucket or index, open the stack’s events in the CloudFormation console to see which resource is stuck, empty it by hand and delete the stack again.

The bootstrap resources and the IAMFullAccess policy on the permission set are not part of this stack, so they stay, as before.

What I’d Do Next

  • Wire it into the site. The knowledge base is only useful to me at a terminal so far. The next post adds a way to call it from the chatbot API and puts a box on this blog, so that readers can ask it questions
  • Run it automatically. Right now the sync is a command I type. A rebuild of the site could upload the changed files and start the ingestion job
  • Try other chunk sizes. Ask the same ten questions with 200, 400 and 800 tokens per chunk, and check which one finds the right passage most often. That is the cheapest improvement available
  • Keep it honest. Add guardrails, so that when the answer is not in my writing the bot says so, and cite its sources every time