diff --git a/install.py b/install.py index c8ce738..7f161c3 100644 --- a/install.py +++ b/install.py @@ -2,53 +2,60 @@ import subprocess +def execute_subprocess(command_list): + print(f'Executing command list: {command_list}') + try: + subprocess.run(command_list, shell=False, check=True) + except subprocess.CalledProcessError as e: + print(f'Error: {e}') + raise Exception(e) + def main(): - package_command = 'sam package --template-file template.yaml --output-template-file deploy.yaml' - deploy_command = 'sam deploy --template-file deploy.yaml --capabilities CAPABILITY_NAMED_IAM ' + package_command_list = ['sam', 'package', '--template-file', 'template.yaml', '--output-template-file', 'deploy.yaml'] + deploy_command_list = ['sam', 'deploy', '--template-file', 'deploy.yaml', '--capabilities', 'CAPABILITY_NAMED_IAM'] s3_bucket = input('Enter the s3 bucket name created as part of pre-requisite: ') if s3_bucket: - package_command = package_command + ' --s3-bucket ' + s3_bucket + package_command_list.append('--s3-bucket') + package_command_list.append(s3_bucket) region = input('Enter the region [for instance, us-west-2]: ') if region: - package_command = package_command + ' --region ' + region - deploy_command = deploy_command + ' --region ' + region + package_command_list.append('--region') + package_command_list.append(region) + + deploy_command_list.append('--region') + deploy_command_list.append(region) print() - print ('packaging trapheus for use ...') - try: - subprocess.run(package_command, shell=False, check=True) - except subprocess.CalledProcessError as e: - print(f'Error: {e}') + print ('packaging trapheus for use...') + execute_subprocess(package_command_list) stack_name = input('Enter a stack name: ') if stack_name: - deploy_command = deploy_command + ' --stack-name ' + stack_name - deploy_command = deploy_command + ' --parameter-overrides' + deploy_command_list.append('--stack-name') + deploy_command_list.append(stack_name) + deploy_command_list.append('--parameter-overrides') sender_email = input('Enter sender email to send email FROM in case of failure: ') if sender_email: - deploy_command = deploy_command + ' SenderEmail=' + sender_email - recipient_email = input('Enter recipeint email to send email TO in case of failure: ') + deploy_command_list.append('SenderEmail=' + sender_email) + recipient_email = input('Enter recipient email to send email TO in case of failure: ') if recipient_email: - deploy_command = deploy_command + ' RecipientEmail=' + recipient_email + deploy_command_list.append('RecipientEmail=' + recipient_email) slack_webhook_urls = input('Enter slack webhooks to publish failure notifications to: ') if slack_webhook_urls: - deploy_command = deploy_command + ' --SlackWebhookUrls=' + slack_webhook_urls + deploy_command_list.append('--SlackWebhookUrls=' + slack_webhook_urls) vpc = input('Are ypu using vpc[y/n]: ') if vpc == 'y' or vpc == 'Y': - deploy_command = deploy_command + ' UseVPCAndSubnets=true' + deploy_command_list.append('UseVPCAndSubnets=true') vpc_id = input('Enter vpc ID: ') if vpc_id: - deploy_command = deploy_command + ' vpcId=' + vpc_id - subnets = input('Enter comman seperated list of PRIVATE subnets: ') + deploy_command_list.append('vpcId=' + vpc_id) + subnets = input('Enter comma seperated list of PRIVATE subnets: ') if subnets: - deploy_command = deploy_command + ' Subnets=' +subnets + deploy_command_list.append('Subnets=' +subnets) print() - print('Deploying trapheus to AWS ...') - try: - subprocess.run(deploy_command, shell=False, check=True) - except subprocess.CalledProcessError as e: - print(f'Error: {e}') + print('Deploying trapheus to AWS...') + execute_subprocess(deploy_command_list) if __name__ == "__main__": diff --git a/labs/TrapheusAI/requirements.txt b/labs/TrapheusAI/requirements.txt index ebbc1a8..7295227 100644 --- a/labs/TrapheusAI/requirements.txt +++ b/labs/TrapheusAI/requirements.txt @@ -15,3 +15,4 @@ streamlit-agraph streamlit-extras pandasai tk +safetensors diff --git a/template.yaml b/template.yaml index e4454b0..9a455ce 100644 --- a/template.yaml +++ b/template.yaml @@ -192,6 +192,9 @@ Resources: Layers: - !Ref CommonLambdaLayer Timeout: 900 + Architectures: + - arm64 # Specify arm64 for Graviton architecture + VpcConfig: !If [UseVPCAndSubnetsCondition, { SecurityGroupIds: !Split [ "," , !GetAtt LambdaSecurityGroup.GroupId ] , @@ -211,6 +214,9 @@ Resources: Layers: - !Ref CommonLambdaLayer Timeout: 900 + Architectures: + - arm64 # Specify arm64 for Graviton architecture + VpcConfig: !If [UseVPCAndSubnetsCondition, { SecurityGroupIds: !Split [ "," , !GetAtt LambdaSecurityGroup.GroupId ] , @@ -230,6 +236,9 @@ Resources: Layers: - !Ref CommonLambdaLayer Timeout: 900 + Architectures: + - arm64 # Specify arm64 for Graviton architecture + VpcConfig: !If [UseVPCAndSubnetsCondition, { SecurityGroupIds: !Split [ "," , !GetAtt LambdaSecurityGroup.GroupId ] , @@ -249,6 +258,9 @@ Resources: Layers: - !Ref CommonLambdaLayer Timeout: 900 + Architectures: + - arm64 # Specify arm64 for Graviton architecture + VpcConfig: !If [UseVPCAndSubnetsCondition, { SecurityGroupIds: !Split [ "," , !GetAtt LambdaSecurityGroup.GroupId ] , @@ -268,6 +280,9 @@ Resources: Layers: - !Ref CommonLambdaLayer Timeout: 900 + Architectures: + - arm64 # Specify arm64 for Graviton architecture + VpcConfig: !If [UseVPCAndSubnetsCondition, { SecurityGroupIds: !Split [ "," , !GetAtt LambdaSecurityGroup.GroupId ] , @@ -287,6 +302,9 @@ Resources: Layers: - !Ref CommonLambdaLayer Timeout: 900 + Architectures: + - arm64 # Specify arm64 for Graviton architecture + VpcConfig: !If [UseVPCAndSubnetsCondition, { SecurityGroupIds: !Split [ "," , !GetAtt LambdaSecurityGroup.GroupId ] , @@ -312,6 +330,9 @@ Resources: Layers: - !Ref CommonLambdaLayer Timeout: 900 + Architectures: + - arm64 # Specify arm64 for Graviton architecture + VpcConfig: !If [UseVPCAndSubnetsCondition, { SecurityGroupIds: !Split [ "," , !GetAtt LambdaSecurityGroup.GroupId ] , @@ -335,6 +356,9 @@ Resources: Layers: - !Ref CommonLambdaLayer Timeout: 900 + Architectures: + - arm64 # Specify arm64 for Graviton architecture + VpcConfig: !If [UseVPCAndSubnetsCondition, { SecurityGroupIds: !Split [ "," , !GetAtt LambdaSecurityGroup.GroupId ] , @@ -354,6 +378,9 @@ Resources: Layers: - !Ref CommonLambdaLayer Timeout: 900 + Architectures: + - arm64 # Specify arm64 for Graviton architecture + VpcConfig: !If [UseVPCAndSubnetsCondition, { SecurityGroupIds: !Split [ "," , !GetAtt LambdaSecurityGroup.GroupId ] , @@ -373,6 +400,9 @@ Resources: Layers: - !Ref CommonLambdaLayer Timeout: 900 + Architectures: + - arm64 # Specify arm64 for Graviton architecture + VpcConfig: !If [UseVPCAndSubnetsCondition, { SecurityGroupIds: !Split [ "," , !GetAtt LambdaSecurityGroup.GroupId ] , @@ -392,6 +422,9 @@ Resources: Layers: - !Ref CommonLambdaLayer Timeout: 900 + Architectures: + - arm64 # Specify arm64 for Graviton architecture + VpcConfig: !If [UseVPCAndSubnetsCondition, { SecurityGroupIds: !Split [ "," , !GetAtt LambdaSecurityGroup.GroupId ] , @@ -411,6 +444,9 @@ Resources: Layers: - !Ref CommonLambdaLayer Timeout: 900 + Architectures: + - arm64 # Specify arm64 for Graviton architecture + VpcConfig: !If [UseVPCAndSubnetsCondition, { SecurityGroupIds: !Split [ "," , !GetAtt LambdaSecurityGroup.GroupId ] , @@ -470,6 +506,9 @@ Resources: Layers: - !Ref CommonLambdaLayer Timeout: 900 + Architectures: + - arm64 # Specify arm64 for Graviton architecture + Environment: Variables: SNAPSHOT_EXPORT_TASK_ROLE: !GetAtt LambdaExecutionRole.Arn @@ -491,6 +530,9 @@ Resources: Layers: - !Ref CommonLambdaLayer Timeout: 900 + Architectures: + - arm64 # Specify arm64 for Graviton architecture + Environment: Variables: SNAPSHOT_EXPORT_TASK_ROLE: !GetAtt LambdaExecutionRole.Arn @@ -1224,4 +1266,4 @@ Resources: "identifier": "identifier-Y", "task": "create_snapshot", "isCluster": true - }' \ No newline at end of file + }'