Skip to content

Commit 5bb3ff8

Browse files
committed
kms assume_role not accessed (used in sts module)
1 parent c4d2279 commit 5bb3ff8

File tree

1 file changed

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

1 file changed

+25
-27
lines changed

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

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
from typing import TYPE_CHECKING
1717
from typing import cast
18-
from typing import Any, Dict
19-
from typing import Literal
2018

2119
if TYPE_CHECKING:
2220
from mypy_boto3_kms.client import KMSClient
@@ -120,31 +118,31 @@ def define_key_policy(self, target_account_id: str, partition: str, home_region:
120118
self.SECRETS_KEY_POLICY = json.dumps(policy_template)
121119
return json.dumps(policy_template)
122120

123-
def assume_role(self, account: str, role_name: str, service: str, region_name: str) -> BaseClient:
124-
"""Get boto3 client assumed into an account for a specified service.
125-
126-
Args:
127-
account: aws account id
128-
service: aws service
129-
region_name: aws region
130-
131-
Returns:
132-
client: boto3 client
133-
"""
134-
sts_client: STSClient = self.MANAGEMENT_ACCOUNT_SESSION.client("sts")
135-
sts_response: AssumeRoleResponseTypeDef = sts_client.assume_role(
136-
RoleArn=f"arn:{self.PARTITION}:iam::{account}:role/{role_name}",
137-
RoleSessionName="SRA-AssumeCrossAccountRole",
138-
DurationSeconds=900,
139-
)
140-
client: BaseClient = self.MANAGEMENT_ACCOUNT_SESSION.client(
141-
service, # type: ignore
142-
region_name=region_name,
143-
aws_access_key_id=sts_response["Credentials"]["AccessKeyId"],
144-
aws_secret_access_key=sts_response["Credentials"]["SecretAccessKey"],
145-
aws_session_token=sts_response["Credentials"]["SessionToken"],
146-
)
147-
return client
121+
# def assume_role(self, account: str, role_name: str, service: str, region_name: str) -> BaseClient:
122+
# """Get boto3 client assumed into an account for a specified service.
123+
124+
# Args:
125+
# account: aws account id
126+
# service: aws service
127+
# region_name: aws region
128+
129+
# Returns:
130+
# client: boto3 client
131+
# """
132+
# sts_client: STSClient = self.MANAGEMENT_ACCOUNT_SESSION.client("sts")
133+
# sts_response: AssumeRoleResponseTypeDef = sts_client.assume_role(
134+
# RoleArn=f"arn:{self.PARTITION}:iam::{account}:role/{role_name}",
135+
# RoleSessionName="SRA-AssumeCrossAccountRole",
136+
# DurationSeconds=900,
137+
# )
138+
# client: BaseClient = self.MANAGEMENT_ACCOUNT_SESSION.client(
139+
# service, # type: ignore
140+
# region_name=region_name,
141+
# aws_access_key_id=sts_response["Credentials"]["AccessKeyId"],
142+
# aws_secret_access_key=sts_response["Credentials"]["SecretAccessKey"],
143+
# aws_session_token=sts_response["Credentials"]["SessionToken"],
144+
# )
145+
# return client
148146

149147
def create_kms_key(self, kms_client: KMSClient, key_policy: str, description: str = "Key description") -> str:
150148
"""Create KMS key

0 commit comments

Comments
 (0)