@@ -57,17 +57,31 @@ resource "aws_security_group" "gtc_awsrag_aurora_sg" {
57
57
}
58
58
}
59
59
60
+ # Parameter group to enable pgvector extension
61
+ resource "aws_rds_cluster_parameter_group" "pgvector_param_group" {
62
+ name = " pgvector-param-group"
63
+ family = " aurora-postgresql16"
64
+ description = " Parameter group for pgvector extension"
65
+
66
+ parameter {
67
+ name = " shared_preload_libraries"
68
+ value = " pg_stat_statements,pgvector"
69
+ apply_method = " pending-reboot"
70
+ }
71
+ }
72
+
60
73
# First Aurora PostgreSQL Serverless v2 instance
61
74
resource "aws_rds_cluster" "gtc_awsrag_aurora_postgres_1" {
62
75
cluster_identifier = " gtc-awsrag-aurora-postgres-1"
63
76
engine = " aurora-postgresql"
64
77
engine_mode = " provisioned"
65
- engine_version = " 13.9 "
78
+ engine_version = " 16.6 "
66
79
database_name = " mydb1"
67
80
master_username = " dbadmin"
68
81
master_password = " YourStrongPasswordHere1" # Use AWS Secrets Manager in production
69
82
db_subnet_group_name = aws_db_subnet_group. gtc_awsrag_aurora_subnet_group . name
70
83
vpc_security_group_ids = [aws_security_group . gtc_awsrag_aurora_sg . id ]
84
+ db_cluster_parameter_group_name = aws_rds_cluster_parameter_group. pgvector_param_group . name
71
85
skip_final_snapshot = true
72
86
73
87
serverlessv2_scaling_configuration {
@@ -81,11 +95,22 @@ resource "aws_rds_cluster_instance" "gtc_awsrag_aurora_primary" {
81
95
cluster_identifier = aws_rds_cluster. gtc_awsrag_aurora_postgres_1 . id
82
96
instance_class = " db.serverless"
83
97
engine = " aurora-postgresql"
84
- engine_version = " 13.9 "
98
+ engine_version = " 16.6 "
85
99
db_subnet_group_name = aws_db_subnet_group. gtc_awsrag_aurora_subnet_group . name
86
100
identifier = " gtc-awsrag-aurora-primary"
87
101
}
88
102
103
+ # Null resource to create pgvector extension after cluster creation
104
+ resource "null_resource" "create_pgvector_extension" {
105
+ depends_on = [aws_rds_cluster_instance . gtc_awsrag_aurora_primary ]
106
+
107
+ provisioner "local-exec" {
108
+ command = <<- EOT
109
+ PGPASSWORD="YourStrongPasswordHere1" psql -h ${ aws_rds_cluster . gtc_awsrag_aurora_postgres_1 . endpoint } -U dbadmin -d mydb1 -c "CREATE EXTENSION IF NOT EXISTS vector;"
110
+ EOT
111
+ }
112
+ }
113
+
89
114
# Outputs
90
115
output "aurora_postgres_1_endpoint" {
91
116
value = aws_rds_cluster. gtc_awsrag_aurora_postgres_1 . endpoint
0 commit comments