|
15 | 15 |
|
16 | 16 | from typing import TYPE_CHECKING |
17 | 17 | from typing import cast |
18 | | -from typing import Any, Dict |
19 | | -from typing import Literal |
20 | 18 |
|
21 | 19 | if TYPE_CHECKING: |
22 | 20 | from mypy_boto3_kms.client import KMSClient |
@@ -120,31 +118,31 @@ def define_key_policy(self, target_account_id: str, partition: str, home_region: |
120 | 118 | self.SECRETS_KEY_POLICY = json.dumps(policy_template) |
121 | 119 | return json.dumps(policy_template) |
122 | 120 |
|
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 |
148 | 146 |
|
149 | 147 | def create_kms_key(self, kms_client: KMSClient, key_policy: str, description: str = "Key description") -> str: |
150 | 148 | """Create KMS key |
|
0 commit comments