Skip to content

Terraform Apply

This page walks through the complete deployment process — from cloning the source repo to verifying your running application. The entire stack deploys in a single Terraform
HashiCorp Terraform — infrastructure-as-code tool used to provision all AWS resources in this demo.
apply that takes around 3–5 minutes.

Start by cloning the infrastructure repository:

Terminal
git clone https://github.com/jajera/terraform-aws-s3-vectors-rag-demo.git
cd terraform-aws-s3-vectors-rag-demo

Copy the example variables file and edit it with your values:

Terminal
cp terraform.tfvars.example terraform.tfvars

Open terraform.tfvars in your editor and set the required variables:

terraform.tfvars
project = "s3vec-rag"
environment = "dev"
aws_region = "us-east-1"
cognito_admin_email = "you@example.com"
rss_feeds = [
"https://aws.amazon.com/about-aws/whats-new/recent-announcements/feed/",
]
VariableRequiredDescription
projectYesName prefix for all AWS resources (keep short, lowercase, no spaces)
environmentYes

Deployment environment label (e.g., dev, staging, prod)

aws_regionYes

AWS region — must support both S3 Vectors
Amazon S3 Vectors — a purpose-built vector storage capability within S3 that enables similarity search over embeddings without a separate vector database.
and

Bedrock
Amazon Bedrock — a fully managed service for accessing foundation models (embedding and LLM) via a unified API.
cognito_admin_emailYes

Email for the auto-created admin user in Cognito
Amazon Cognito — a user authentication service providing user pools, JWT tokens, and group-based authorization.

rss_feedsYesList of RSS feed URLs to ingest into the vector store
ingest_schedule_expressionNo

EventBridge
Amazon EventBridge — a serverless event bus. Used here for the daily scheduled corpus ingest cron trigger.
schedule expression (default: cron(0 6 * * ? *) — daily at 06:00 UTC)

embedding_model_idNo

Embedding model
Amazon Titan Embeddings V2 (amazon.titan-embed-text-v2:0) — converts text into 1024-dimensional vectors for similarity search.
ID (default: amazon.titan-embed-text-v2:0)

inference_profile_idNoBedrock inference profile for the LLM (default: Claude via cross-region profile)

Download the required providers and modules:

Terminal
terraform init

You should see output confirming the AWS provider was installed:

Initializing provider plugins...
- Installing hashicorp/aws v6.x.x...
- Installing hashicorp/random v3.x.x...
- Installing hashicorp/null v3.x.x...
Terraform has been successfully initialized!

Before applying, review what Terraform will create:

Terminal
terraform plan

This shows the full list of resources to be provisioned without making any changes. Expect around 40–50 resources including Lambda
AWS Lambda — serverless compute. This project uses two functions: ingest (RSS → embed → store) and query (search → answer).
functions, API Gateway
Amazon API Gateway — a managed HTTP API service with JWT authorization, CORS, and throttling. Routes requests to the Query Lambda.
routes, IAM roles, and the Amplify
AWS Amplify — a managed hosting service for static web applications. Used to host the briefing UI SPA.
app.

Deploy the entire stack:

Terminal
terraform apply

Type yes when prompted to confirm. The deployment takes approximately 3–5 minutes.

Terraform provisions resources in this sequence:

  1. Foundation — IAM roles, S3 buckets, vector bucket
    A specialized S3 bucket type (aws_s3vectors_vector_bucket) that hosts vector indexes for similarity search.
    , and vector index
    A named index (aws_s3vectors_index) within a vector bucket defining dimension, distance metric, and data type.
  2. Compute — Lambda functions for ingest and query, with Python dependencies packaged as layers
  3. API layer — API Gateway HTTP API with JWT authorizer and CORS configuration
  4. Auth — Cognito user pool, app client, admin user, and user groups
  5. Frontend — Amplify app with the React SPA built and deployed
  6. Scheduling — EventBridge rule for daily ingest cron
  7. Bootstrap — A null_resource provisioner triggers the initial ingest, embedding ~120 articles into the vector store

Once the apply finishes, retrieve the key outputs:

Terminal
terraform output

This prints all configured outputs. To get individual values:

Terminal
terraform output -raw app_url
terraform output -raw api_endpoint
terraform output -raw cognito_user_pool_id
OutputDescription
app_urlAmplify HTTPS URL for the web UI — open this in your browser
api_endpointAPI Gateway base URL for the query and ingest endpoints
cognito_user_pool_idCognito user pool ID (needed for CLI user management)
cognito_client_idSPA client ID used by the frontend for authentication
vector_bucket_nameThe S3 Vectors bucket name (useful for debugging)
ingest_function_nameIngest Lambda function name (for manual invocations or log inspection)