Skip to content

Commit f439e42

Browse files
committed
fixing role state record
1 parent 457b01e commit f439e42

File tree

1 file changed

+32
-32
lines changed
  • aws_sra_examples/solutions/genai/bedrock_org/lambda/src

1 file changed

+32
-32
lines changed

aws_sra_examples/solutions/genai/bedrock_org/lambda/src/app.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,40 +1434,40 @@ def deploy_iam_role(account_id: str, rule_name: str) -> str:
14341434
LOGGER.info(f"{rule_name} IAM role already exists.")
14351435
role_arn = iam_role_search[1]
14361436

1437-
# IAM role state table record
1438-
# TODO(liamschn): move dynamodb resource to the dynamo class object/module
1439-
dynamodb_resource = sts.assume_role_resource(ssm_params.SRA_SECURITY_ACCT, sts.CONFIGURATION_ROLE, "dynamodb", sts.HOME_REGION)
1437+
# IAM role state table record
1438+
# TODO(liamschn): move dynamodb resource to the dynamo class object/module
1439+
dynamodb_resource = sts.assume_role_resource(ssm_params.SRA_SECURITY_ACCT, sts.CONFIGURATION_ROLE, "dynamodb", sts.HOME_REGION)
14401440

1441-
item_found, find_result = dynamodb.find_item(
1442-
STATE_TABLE,
1443-
dynamodb_resource,
1444-
SOLUTION_NAME,
1445-
{
1446-
"arn": role_arn,
1447-
},
1448-
)
1449-
if item_found is False:
1450-
role_record_id, role_date_time = dynamodb.insert_item(STATE_TABLE, dynamodb_resource, SOLUTION_NAME)
1451-
else:
1452-
role_record_id = find_result["record_id"]
1441+
item_found, find_result = dynamodb.find_item(
1442+
STATE_TABLE,
1443+
dynamodb_resource,
1444+
SOLUTION_NAME,
1445+
{
1446+
"arn": role_arn,
1447+
},
1448+
)
1449+
if item_found is False:
1450+
role_record_id, role_date_time = dynamodb.insert_item(STATE_TABLE, dynamodb_resource, SOLUTION_NAME)
1451+
else:
1452+
role_record_id = find_result["record_id"]
14531453

1454-
dynamodb.update_item(
1455-
STATE_TABLE,
1456-
dynamodb_resource,
1457-
SOLUTION_NAME,
1458-
role_record_id,
1459-
{
1460-
"aws_service": "iam",
1461-
"component_state": "implemented",
1462-
"account": account_id,
1463-
"description": "role for config rule",
1464-
"component_region": "Global",
1465-
"component_type": "role",
1466-
"component_name": rule_name,
1467-
"arn": role_arn,
1468-
"date_time": dynamodb.get_date_time(),
1469-
},
1470-
)
1454+
dynamodb.update_item(
1455+
STATE_TABLE,
1456+
dynamodb_resource,
1457+
SOLUTION_NAME,
1458+
role_record_id,
1459+
{
1460+
"aws_service": "iam",
1461+
"component_state": "implemented",
1462+
"account": account_id,
1463+
"description": "role for config rule",
1464+
"component_region": "Global",
1465+
"component_type": "role",
1466+
"component_name": rule_name,
1467+
"arn": role_arn,
1468+
"date_time": dynamodb.get_date_time(),
1469+
},
1470+
)
14711471

14721472
iam.SRA_POLICY_DOCUMENTS["sra-lambda-basic-execution"]["Statement"][0]["Resource"] = iam.SRA_POLICY_DOCUMENTS["sra-lambda-basic-execution"][
14731473
"Statement"

0 commit comments

Comments
 (0)