Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
chatbot-lab
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LSDS
Teaching
Master
Cloud
chatbot-lab
Commits
db781a18
Commit
db781a18
authored
1 month ago
by
abir.chebbi
Browse files
Options
Downloads
Patches
Plain Diff
add account_id as an argument
parent
079ccc62
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Part1/create-vector-db.py
+6
-5
6 additions, 5 deletions
Part1/create-vector-db.py
README.md
+1
-0
1 addition, 0 deletions
README.md
with
7 additions
and
5 deletions
Part1/create-vector-db.py
+
6
−
5
View file @
db781a18
...
@@ -76,7 +76,7 @@ def createNetworkPolicy(client,policy_name,collection_name):
...
@@ -76,7 +76,7 @@ def createNetworkPolicy(client,policy_name,collection_name):
raise
error
raise
error
def
createAccessPolicy
(
client
,
policy_name
,
collection_name
,
IAM_USER
):
def
createAccessPolicy
(
client
,
policy_name
,
collection_name
,
IAM_USER
,
ACCOUNT_ID
):
"""
Creates a data access policy for the specified collection.
"""
"""
Creates a data access policy for the specified collection.
"""
try
:
try
:
policy_content
=
f
"""
policy_content
=
f
"""
...
@@ -106,7 +106,7 @@ def createAccessPolicy(client, policy_name, collection_name, IAM_USER):
...
@@ -106,7 +106,7 @@ def createAccessPolicy(client, policy_name, collection_name, IAM_USER):
"
ResourceType
"
:
"
index
"
"
ResourceType
"
:
"
index
"
}}
}}
],
],
"
Principal
"
: [
"
arn:aws:iam::
768034348959
:user/
{
IAM_USER
}
"
]
"
Principal
"
: [
"
arn:aws:iam::
{
ACCOUNT_ID
}
:user/
{
IAM_USER
}
"
]
}}
}}
]
]
"""
"""
...
@@ -140,13 +140,13 @@ def waitForCollectionCreation(client,collection_name):
...
@@ -140,13 +140,13 @@ def waitForCollectionCreation(client,collection_name):
return
final_host
return
final_host
def
main
(
collection_name
,
IAM_USER
):
def
main
(
collection_name
,
IAM_USER
,
ACCOUNT_ID
):
encryption_policy_name
=
f
'
{
collection_name
}
-encryption-policy
'
encryption_policy_name
=
f
'
{
collection_name
}
-encryption-policy
'
network_policy_name
=
f
'
{
collection_name
}
-network-policy
'
network_policy_name
=
f
'
{
collection_name
}
-network-policy
'
access_policy_name
=
f
'
{
collection_name
}
-access-policy
'
access_policy_name
=
f
'
{
collection_name
}
-access-policy
'
createEncryptionPolicy
(
client
,
encryption_policy_name
,
collection_name
)
createEncryptionPolicy
(
client
,
encryption_policy_name
,
collection_name
)
createNetworkPolicy
(
client
,
network_policy_name
,
collection_name
)
createNetworkPolicy
(
client
,
network_policy_name
,
collection_name
)
createAccessPolicy
(
client
,
access_policy_name
,
collection_name
,
IAM_USER
)
createAccessPolicy
(
client
,
access_policy_name
,
collection_name
,
IAM_USER
,
ACCOUNT_ID
)
collection
=
client
.
create_collection
(
name
=
collection_name
,
type
=
'
VECTORSEARCH
'
)
collection
=
client
.
create_collection
(
name
=
collection_name
,
type
=
'
VECTORSEARCH
'
)
ENDPOINT
=
waitForCollectionCreation
(
client
,
collection_name
)
ENDPOINT
=
waitForCollectionCreation
(
client
,
collection_name
)
...
@@ -157,5 +157,6 @@ if __name__== "__main__":
...
@@ -157,5 +157,6 @@ if __name__== "__main__":
parser
=
argparse
.
ArgumentParser
(
description
=
"
Create collection
"
)
parser
=
argparse
.
ArgumentParser
(
description
=
"
Create collection
"
)
parser
.
add_argument
(
"
--collection_name
"
,
help
=
"
The name of the collection
"
)
parser
.
add_argument
(
"
--collection_name
"
,
help
=
"
The name of the collection
"
)
parser
.
add_argument
(
"
--iam_user
"
,
help
=
"
The iam user
"
)
parser
.
add_argument
(
"
--iam_user
"
,
help
=
"
The iam user
"
)
parser
.
add_argument
(
"
--account_id
"
,
help
=
"
The account id
"
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
main
(
args
.
collection_name
,
args
.
iam_user
)
main
(
args
.
collection_name
,
args
.
iam_user
,
args
.
account_id
)
This diff is collapsed.
Click to expand it.
README.md
+
1
−
0
View file @
db781a18
...
@@ -33,6 +33,7 @@ Where:
...
@@ -33,6 +33,7 @@ Where:
-
**[Name_of_colletion]**
: Name of the collection that you want to create.
-
**[Name_of_colletion]**
: Name of the collection that you want to create.
-
**[YourIAM_user]**
: the IAM user is
`CloudSys-group-XX`
, with "XX" representing your group number.
-
**[YourIAM_user]**
: the IAM user is
`CloudSys-group-XX`
, with "XX" representing your group number.
This script performs the following actions:
This script performs the following actions:
*
Sets up encryption, network, and data access policies for the collection.
*
Sets up encryption, network, and data access policies for the collection.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment