diff --git a/Part1/create-vector-db.py b/Part1/create-vector-db.py index 489d74e2d19ed478785c27815261864a5da7617a..b92bf31b40d42e03f79c063e8cbc32f8de6315a2 100644 --- a/Part1/create-vector-db.py +++ b/Part1/create-vector-db.py @@ -76,7 +76,7 @@ def createNetworkPolicy(client,policy_name,collection_name): 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.""" try: policy_content = f""" @@ -106,7 +106,7 @@ def createAccessPolicy(client, policy_name, collection_name, IAM_USER): "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): 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' network_policy_name = f'{collection_name}-network-policy' access_policy_name = f'{collection_name}-access-policy' createEncryptionPolicy(client, encryption_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') ENDPOINT= waitForCollectionCreation(client,collection_name) @@ -157,5 +157,6 @@ if __name__== "__main__": parser = argparse.ArgumentParser(description="Create collection") parser.add_argument("--collection_name", help="The name of the collection") parser.add_argument("--iam_user", help="The iam user") + parser.add_argument("--account_id", help="The account id") args = parser.parse_args() - main(args.collection_name,args.iam_user) + main(args.collection_name,args.iam_user,args.account_id) diff --git a/README.md b/README.md index 7b7fb46635f2263d4520e507fa0815d7b346e023..a3bc2a069e857ea1776b032c6ca9cf000c20df7e 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ Where: - **[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. + This script performs the following actions: * Sets up encryption, network, and data access policies for the collection.