Skip to content

Commit

Permalink
Removing hardcoded values.
Browse files Browse the repository at this point in the history
Signed-off-by: jzonthemtn <jeff.zemerick@mtnfog.com>
  • Loading branch information
jzonthemtn committed Dec 23, 2024
1 parent b141fba commit a24144a
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 40 deletions.
23 changes: 14 additions & 9 deletions osi/create-plugin-package.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash -e

. stack.properties

# This script is just here for an example.
# AWS OpenSearch does not (yet) support ActionPlugins.

# https://docs.aws.amazon.com/opensearch-service/latest/developerguide/custom-plugins.html
# Note that custom plugins cannot implement ActionPlugin.

Expand All @@ -8,34 +13,34 @@ FILE_NAME="search-quality-evaluation-plugin-0.0.1.zip"
wget -O ${FILE_NAME} https://github.com/o19s/opensearch-search-quality-evaluation/releases/download/0.0.1/${FILE_NAME}

aws s3 cp ${FILE_NAME} s3://ubi-queries-events-sink/${FILE_NAME} \
--profile TODO_PUT_YOUR_AWS_PROFILE_NAME_HERE \
--region us-east-1
--profile ${AWS_PROFILE} \
--region ${AWS_REGION}

aws opensearch create-package \
--region us-east-1 \
--profile TODO_PUT_YOUR_AWS_PROFILE_NAME_HERE \
--region ${AWS_REGION} \
--profile ${AWS_PROFILE} \
--package-name search-eval-framework \
--package-type ZIP-PLUGIN \
--package-source S3BucketName=ubi-queries-events-sink,S3Key=search-quality-evaluation-plugin-0.0.1.zip \
--engine-version OpenSearch_2.17

# aws opensearch describe-packages \
# --region us-east-1 \
# --profile TODO_PUT_YOUR_AWS_PROFILE_NAME_HERE \
# --region ${AWS_REGION} \
# --profile ${AWS_PROFILE} \
# --filters '[{"Name": "PackageType","Value": ["ZIP-PLUGIN"]}, {"Name": "PackageName","Value": ["search-eval-framework"]}]'

# when done, grab the package id and put into command:

# PACKAGE_ID="pkg-b618759e2c2d03c7b9934b214ce6d09fcfaa8547"

# aws opensearch associate-package \
# --region us-east-1 \
# --region ${AWS_REGION} \
# --domain-name osi-ubi-domain \
# --profile TODO_PUT_YOUR_AWS_PROFILE_NAME_HERE
# --profile ${AWS_PROFILE}
# --package-id ${PACKAGE_ID}


# aws opensearch list-packages-for-domain
# --domain-name osi-ubi-domain \
# --region $REGION \
# --profile TODO_PUT_YOUR_AWS_PROFILE_NAME_HERE
# --profile ${AWS_PROFILE}
9 changes: 4 additions & 5 deletions osi/delete-indexes.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/bin/bash -e

# pip install awscurl
. stck.properties

# Get from the Terraform output or the AWS Console
OPENSEARCH_ENDPOINT="search-osi-ubi-domain-pjju5yl7neorgz4jcsqhq5o7fq.us-east-1.es.amazonaws.com"
OPENSEARCH_ENDPOINT=`terraform output "opensearch_domain_endpoint" | jq -r .`

awscurl \
"https://${OPENSEARCH_ENDPOINT}/ubi_events,ubi_queries" \
-X DELETE \
--region us-east-1 \
--region ${AWS_REGION} \
--service es \
--profile TODO_PUT_YOUR_AWS_PROFILE_NAME_HERE
--profile ${AWS_PROFILE}
13 changes: 6 additions & 7 deletions osi/get-indexed-events.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
#!/bin/bash -e

# pip install awscurl
. stack.properties

# Get from the Terraform output or the AWS Console
OPENSEARCH_ENDPOINT="search-osi-ubi-domain-pjju5yl7neorgz4jcsqhq5o7fq.us-east-1.es.amazonaws.com"
OPENSEARCH_ENDPOINT=`terraform output "opensearch_domain_endpoint" | jq -r .`

awscurl \
"https://${OPENSEARCH_ENDPOINT}/_cat/indices" \
-X GET \
--region us-east-1 \
--region ${AWS_REGION} \
--service es \
--profile TODO_PUT_YOUR_AWS_PROFILE_NAME_HERE
--profile ${AWS_PROFILE}

awscurl \
"https://${OPENSEARCH_ENDPOINT}/ubi_events/_search" \
-X GET \
--region us-east-1 \
--region ${AWS_REGION} \
--service es \
--profile TODO_PUT_YOUR_AWS_PROFILE_NAME_HERE | jq
--profile ${AWS_PROFILE} | jq
13 changes: 6 additions & 7 deletions osi/get-indexed-queries.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
#!/bin/bash -e

# pip install awscurl
. stack.properties

# Get from the Terraform output or the AWS Console
OPENSEARCH_ENDPOINT="search-osi-ubi-domain-pjju5yl7neorgz4jcsqhq5o7fq.us-east-1.es.amazonaws.com"
OPENSEARCH_ENDPOINT=`terraform output "opensearch_domain_endpoint" | jq -r .`

awscurl \
"https://${OPENSEARCH_ENDPOINT}/_cat/indices" \
-X GET \
--region us-east-1 \
--region ${AWS_REGION} \
--service es \
--profile TODO_PUT_YOUR_AWS_PROFILE_NAME_HERE
--profile ${AWS_PROFILE}

awscurl \
"https://${OPENSEARCH_ENDPOINT}/ubi_queries/_search" \
-X GET \
--region us-east-1 \
--region ${AWS_REGION} \
--service es \
--profile TODO_PUT_YOUR_AWS_PROFILE_NAME_HERE | jq
--profile ${AWS_PROFILE} | jq
12 changes: 10 additions & 2 deletions osi/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ terraform {

provider "aws" {
region = "us-east-1"
profile = "TODO_PUT_YOUR_AWS_PROFILE_NAME_HERE"
profile = "mtnfog"
}

data "aws_region" "current" {}
Expand Down Expand Up @@ -81,7 +81,7 @@ resource "aws_opensearch_domain" "opensearch_ubi" {
volume_size = 10
}

access_policies = data.aws_iam_policy_document.access_policy.json
#access_policies = data.aws_iam_policy_document.access_policy.json
}

resource "aws_iam_policy" "ubi" {
Expand Down Expand Up @@ -192,4 +192,12 @@ resource "aws_osis_pipeline" "ubi_events_pipeline" {
tags = {
Name = "UBI OpenSearch Ingestion Pipeline for UBI"
}
}

output "opensearch_domain_endpoint" {
value = aws_opensearch_domain.opensearch_ubi.endpoint
}

output "opensearch_ingest_pipeline_endpoint" {
value = aws_osis_pipeline.ubi_events_pipeline.ingest_endpoint_urls
}
1 change: 1 addition & 0 deletions osi/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
awscurl==0.36
9 changes: 4 additions & 5 deletions osi/send-event.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/bin/bash -e

# pip install awscurl
. stack.properties

# Get from the Terraform output or the AWS Console
OSIS_PIPELINE_ENDPOINT_URL="ubi-pipeline-xjmot6taz7mmcv76a36mlscgg4.us-east-1.osis.amazonaws.com"
OSIS_PIPELINE_ENDPOINT_URL=`terraform output -json "opensearch_ingest_pipeline_endpoint" | jq -r .[0]`

awscurl \
--service osis \
--region us-east-1 \
--profile TODO_PUT_YOUR_AWS_PROFILE_NAME_HERE \
--region ${AWS_REGION} \
--profile ${AWS_PROFILE} \
-X POST \
-H "Content-Type: application/json" \
-d '[{"type": "event", "action_name": "click", "query_id": "99999999-4455-6677-8899-aabbccddeeff", "event_attributes": {"position": {"ordinal": 1}, "object": {"object_id": "1234", "object_id_field": "ean", "user_id": "abc"}}}]' \
Expand Down
9 changes: 4 additions & 5 deletions osi/send-query.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/bin/bash -e

# pip install awscurl
. stack.properties

# Get from the Terraform output or the AWS Console
OSIS_PIPELINE_ENDPOINT_URL="ubi-pipeline-xjmot6taz7mmcv76a36mlscgg4.us-east-1.osis.amazonaws.com"
OSIS_PIPELINE_ENDPOINT_URL=`terraform output -json "opensearch_ingest_pipeline_endpoint" | jq -r .[0]`

awscurl \
--service osis \
--region us-east-1 \
--profile TODO_PUT_YOUR_AWS_PROFILE_NAME_HERE \
--region ${AWS_REGION} \
--profile ${AWS_PROFILE} \
-X POST \
-H "Content-Type: application/json" \
-d '[{"type": "query", "user_query": "computer", "query_id": "00112233-4455-6677-8899-aabbccddeeff"}]' \
Expand Down
5 changes: 5 additions & 0 deletions osi/stack.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# The name of the AWS profile.
AWS_PROFILE=mtnfog

# The AWS region.
AWS_REGION=us-east-1

0 comments on commit a24144a

Please sign in to comment.