Skip to content

Commit

Permalink
[aws][fix] Handle AWS server errors properly (#2236)
Browse files Browse the repository at this point in the history
  • Loading branch information
1101-1 authored Oct 11, 2024
1 parent 84f055d commit d989475
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
19 changes: 10 additions & 9 deletions plugins/aws/fix_plugin_aws/resource/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def add_tags(job: AwsResource) -> None:
service_name,
"list-tags-for-resource",
"tags",
expected_errors=["ResourceNotFoundException"],
expected_errors=["ResourceNotFoundException", "AccessDenied"],
resourceARN=job.arn,
)
if tags:
Expand Down Expand Up @@ -490,7 +490,7 @@ def add_tags(job: AwsResource) -> None:
service_name,
"list-tags-for-resource",
"tags",
expected_errors=["ResourceNotFoundException"],
expected_errors=["ResourceNotFoundException", "AccessDenied"],
resourceARN=job.arn,
)
if tags:
Expand Down Expand Up @@ -623,7 +623,7 @@ def add_tags(job: AwsResource) -> None:
service_name,
"list-tags-for-resource",
"tags",
expected_errors=["ResourceNotFoundException"],
expected_errors=["ResourceNotFoundException", "AccessDenied"],
resourceARN=job.arn,
)
if tags:
Expand Down Expand Up @@ -767,7 +767,8 @@ class AwsBedrockEvaluationJob(BedrockTaggable, BaseAIJob, AwsResource):
"bedrock",
"list-evaluation-jobs",
"jobSummaries",
expected_errors=["AccessDeniedException"],
# `InternalServerException` is ignored because some AWS regions may not support retrieving evaluation jobs
expected_errors=["AccessDeniedException", "InternalServerException"],
)
mapping: ClassVar[Dict[str, Bender]] = {
"id": S("jobArn"),
Expand Down Expand Up @@ -823,7 +824,7 @@ def add_tags(job: AwsResource) -> None:
service_name,
"list-tags-for-resource",
"tags",
expected_errors=["ResourceNotFoundException"],
expected_errors=["ResourceNotFoundException", "AccessDenied"],
resourceARN=job.arn,
)
if tags:
Expand Down Expand Up @@ -1022,7 +1023,7 @@ def add_tags(agent: AwsResource) -> None:
"bedrock-agent",
"list-tags-for-resource",
"tags",
expected_errors=["ResourceNotFoundException"],
expected_errors=["ResourceNotFoundException", "AccessDenied"],
resourceArn=agent.arn,
)
if tags:
Expand Down Expand Up @@ -1419,7 +1420,7 @@ def add_tags(knowledge_base: AwsResource) -> None:
"bedrock-agent",
"list-tags-for-resource",
"tags",
expected_errors=["ResourceNotFoundException"],
expected_errors=["ResourceNotFoundException", "AccessDenied"],
resourceArn=knowledge_base.arn,
)
if tags:
Expand Down Expand Up @@ -1586,7 +1587,7 @@ def add_tags(prompt: AwsResource) -> None:
"bedrock-agent",
"list-tags-for-resource",
"tags",
expected_errors=["ResourceNotFoundException"],
expected_errors=["ResourceNotFoundException", "AccessDenied"],
resourceArn=prompt.arn,
)
if tags:
Expand Down Expand Up @@ -1914,7 +1915,7 @@ def add_tags(flow: AwsResource) -> None:
"bedrock-agent",
"list-tags-for-resource",
"tags",
expected_errors=["ResourceNotFoundException"],
expected_errors=["ResourceNotFoundException", "AccessDenied"],
resourceArn=flow.arn,
)
if tags:
Expand Down
1 change: 1 addition & 0 deletions plugins/aws/fix_plugin_aws/resource/dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ def add_dynamodb_policy(table: AwsDynamoDbTable) -> None:
"get-resource-policy",
"Policy",
ResourceArn=table.arn,
expected_errors=["PolicyNotFoundException"],
):
table.dynamodb_policy = sort_json(json_loads(raw_policy), sort_list=True) # type: ignore

Expand Down

0 comments on commit d989475

Please sign in to comment.