Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
noah-paige committed Nov 5, 2024
1 parent b5c0c08 commit 25334bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
1 change: 1 addition & 0 deletions backend/api_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
from argparse import Namespace
from time import perf_counter

from ariadne import (
gql,
graphql_sync,
Expand Down
27 changes: 3 additions & 24 deletions deploy/stacks/lambda_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ def __init__(
retention=getattr(logs.RetentionDays, self.log_retention_duration),
),
description='dataall graphql function',
role=self.create_function_role(
envname, resource_prefix, 'graphql', pivot_role_name, vpc, self._get_bedrock_policy_statement() or []
),
role=self.create_function_role(envname, resource_prefix, 'graphql', pivot_role_name, vpc),
code=_lambda.DockerImageCode.from_ecr(
repository=ecr_repository, tag=image_tag, cmd=['api_handler.handler']
),
Expand Down Expand Up @@ -365,25 +363,7 @@ def create_lambda_sgs(self, envname, name, resource_prefix, vpc):
)
return lambda_sg

@run_if(['modules.worksheets.features.nlq.active'])
def _get_bedrock_policy_statement(self):
return [
iam.PolicyStatement(
actions=[
'bedrock:InvokeModel',
'bedrock:GetPrompt',
'bedrock:CreateFoundationModelAgreement',
'bedrock:InvokeFlow',
],
resources=[
f'arn:aws:bedrock:{self.region}:{self.account}:flow/*',
f'arn:aws:bedrock:{self.region}:{self.account}:prompt/*',
f'arn:aws:bedrock:{self.region}::foundation-model/*',
],
)
]

def create_function_role(self, envname, resource_prefix, fn_name, pivot_role_name, vpc, extra_statements=[]):
def create_function_role(self, envname, resource_prefix, fn_name, pivot_role_name, vpc):
role_name = f'{resource_prefix}-{envname}-{fn_name}-role'

role_inline_policy = iam.Policy(
Expand Down Expand Up @@ -511,8 +491,7 @@ def create_function_role(self, envname, resource_prefix, fn_name, pivot_role_nam
actions=['events:EnableRule', 'events:DisableRule'],
resources=[f'arn:aws:events:{self.region}:{self.account}:rule/dataall*'],
),
]
+ extra_statements,
],
)
role = iam.Role(
self,
Expand Down

0 comments on commit 25334bc

Please sign in to comment.