Skip to content

Commit

Permalink
bedrock readonly fix
Browse files Browse the repository at this point in the history
  • Loading branch information
awsandy committed Oct 6, 2024
1 parent eeede6b commit 2d78015
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions .python/get_aws_resources/aws_bedrock.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import common
import boto3
import globals
import inspect
import inspect,sys


def get_aws_bedrock_model_invocation_logging_configuration(type, id, clfn, descfn, topkey, key, filterid):
Expand Down Expand Up @@ -38,20 +38,53 @@ def get_aws_bedrock_guardrail(type, id, clfn, descfn, topkey, key, filterid):
paginator = client.get_paginator(descfn)
for page in paginator.paginate():
response = response + page[topkey]
if response == []: print("Empty response for "+type+ " id="+str(id)+" returning"); return True
if response == []:
print("Empty response for "+type+ " id="+str(id)+" returning")
return True
for j in response:
resp2 = client.list_guardrails(guardrailIdentifier=j[key])
for k in resp2[topkey]:
try:
tresp=client.list_tags_for_resource(resourceARN=k['arn'])
print(str(tresp))
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
exn=str(exc_type.__name__)
if exn=="AccessDeniedException":
print("No Access to tags for "+k['arn']+" returning ...")
pkey=type+"."+k[key]
globals.rproc[pkey]=True
return True
tkey=k[key]+","+k['version']
common.write_import(type,tkey,None)
pkey=type+"."+k[key]
globals.rproc[pkey]=True


else:
response = client.list_guardrails(guardrailIdentifier=id)
if response == []: print("Empty response for "+type+ " id="+str(id)+" returning"); return True
pkey=type+"."+id
if response == []:
print("Empty response for "+type+ " id="+str(id)+" returning")
pkey=type+"."+id
globals.rproc[pkey]=True
return True

for j in response[topkey]:
tkey=j[key]+","+j['version']
try:
tresp=client.list_tags_for_resource(resourceARN=j['arn'])
print(str(tresp))
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
exn=str(exc_type.__name__)
if exn=="AccessDeniedException":
print("No Access to tags for "+j['arn']+" returning ...")
pkey=type+"."+j[key]
globals.rproc[pkey]=True
return True
common.write_import(type,tkey,None)
globals.rproc[pkey]=True

except Exception as e:
common.handle_error(e,str(inspect.currentframe().f_code.co_name),clfn,descfn,topkey,id)
Expand Down

0 comments on commit 2d78015

Please sign in to comment.