ã¿ãã§ã.
re:Invent ä¸ã« S3 Vectors ã GA ããã¾ãã.æ±äº¬ãªã¼ã¸ã§ã³ã«ããã¦ãã,Terraform aws provider v6.24.0 ã§ S3 Vectors ã®ãµãã¼ããå
¥ã£ã¦ãããã試ãã¦ã¿ã¾ã.
aws.amazon.com
ãªãªã¼ã¹æ¦è¦
v6.24.0 ã§ã¯æ¬¡ã® S3 Vectors ã®ãªã½ã¼ã¹ããµãã¼ãããã¾ãã.
ãããã®ãªã½ã¼ã¹ãæ±äº¬ãªã¼ã¸ã§ã³ã§å®ç¾©ãã¦ä½¿ã£ã¦ã¿ã¾ããã.
以忏ããè¨äºããã¼ã¹ã«ãªã½ã¼ã¹ãä½ãã¾ã.
resource "aws_s3vectors_vector_bucket" "blog" {
vector_bucket_name = "blog-s3-vectors"
}
resource "aws_s3vectors_index" "blog" {
index_name = "blog-s3-vectors-index"
vector_bucket_name = aws_s3vectors_vector_bucket.blog.vector_bucket_name
data_type = "float32"
dimension = 1024
distance_metric = "cosine"
}
ãã®å®ç¾©ã§ãã¨æ¬¡ã®ãããªå®è¡è¨ç»ãã§ããã®ã§ä½æãã¾ã.
Terraform will perform the following actions:
+ resource "aws_s3vectors_index" "blog" {
+ creation_time = (known after apply)
+ data_type = "float32"
+ dimension = 1024
+ distance_metric = "cosine"
+ encryption_configuration = (known after apply)
+ index_arn = (known after apply)
+ index_name = "blog-s3-vectors-index"
+ region = "ap-northeast-1"
+ tags_all = {}
+ vector_bucket_name = "blog-s3-vectors"
}
+ resource "aws_s3vectors_vector_bucket" "blog" {
+ creation_time = (known after apply)
+ encryption_configuration = (known after apply)
+ force_destroy = false
+ region = "ap-northeast-1"
+ tags_all = {}
+ vector_bucket_arn = (known after apply)
+ vector_bucket_name = "blog-s3-vectors"
}
Plan: 2 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
aws_s3vectors_vector_bucket.blog: Creating...
aws_s3vectors_vector_bucket.blog: Creation complete after 0s
aws_s3vectors_index.blog: Creating...
aws_s3vectors_index.blog: Creation complete after 0s
Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
使ããããªã½ã¼ã¹ã使ã§ãããã AWS CLI ã使ã£ã¦ç¢ºèªããã¨ããæå³éãæ±äº¬ãªã¼ã¸ã§ã³ã«ãªã½ã¼ã¹ãåå¨ãã¦ã¾ãã.
⯠aws s3vectors list-vector-buckets --region ap-northeast-1
{
"vectorBuckets": [
{
"vectorBucketName": "blog-s3-vectors",
"vectorBucketArn": "arn:aws:s3vectors:ap-northeast-1:1234567891011:bucket/blog-s3-vectors",
"creationTime": "2025-12-14T12:34:42+09:00"
}
]
}
⯠aws s3vectors get-index --vector-bucket-name blog-s3-vectors --index-name blog-s3-vectors-index --region ap-northeast-1
{
"index": {
"vectorBucketName": "blog-s3-vectors",
"indexName": "blog-s3-vectors-index",
"indexArn": "arn:aws:s3vectors:ap-northeast-1:1234567891011:bucket/blog-s3-vectors/index/blog-s3-vectors-index",
"creationTime": "2025-12-14T12:34:43+09:00",
"dataType": "float32",
"dimension": 1024,
"distanceMetric": "cosine"
}
}
S3 Vectors ã«ãã¹ããã¼ã¿ãæå
¥ãã
ãã¹ããã¼ã¿ãæå
¥ã,æ¤ç´¢ãã¦ã¿ã¾ã.ãã¹ããã¼ã¿ã¯ä»¥ä¸ã®ããã«çæã㦠S3 Vectors ã«ã¢ãããã¼ããã¾ã.
⯠cat input.json
{
"inputText": "This is test vector data."
}
⯠aws bedrock-runtime invoke-model --model-id "amazon.titan-embed-text-v2:0" --body fileb://input.json --content-type application/json --accept application/json --region ap-northeast-1 output.json
{
"contentType": "application/json"
}
⯠jq -c '.embedding' output.json > vector_data.json
⯠cat <<EOF > vector_upload.json
â [
{
"key": "doc1",
"data": {
"float32": $(cat vector_data.json)
},
"metadata": {
"source_text": "This is test vector data.",
"category": "test"
}
}
]
â EOF
⯠aws s3vectors put-vectors --vector-bucket-name blog-s3-vectors --index-name blog-s3-vectors-index --vectors file://vector_upload.json --region ap-northeast-1
æå
¥ãããã¼ã¿ãæ¤ç´¢ãã¾ã.æå³éãã«æ¤ç´¢ã§ãã¾ãã.
⯠jq '{float32: .embedding}' output.json > embedding.json
⯠aws s3vectors query-vectors --vector-bucket-name blog-s3-vectors --index-name blog-s3-vectors-index --top-k 3 --query-vector file://embedding.json --return-metadata --region ap-northeast-1
{
"vectors": [
{
"key": "doc1",
"metadata": {
"category": "test",
"source_text": "This is test vector data."
}
}
],
"distanceMetric": "cosine"
}
ã¾ã¨ã
GA ããã S3 Vectors ã Terraform ã§ãªã½ã¼ã¹ç®¡çã試ãã¦ã¡ã¢ãã¾ã¨ãã¾ãã.