|
50 | 50 | from mypy_boto3_dynamodb.client import DynamoDBClient |
51 | 51 | from mypy_boto3_dynamodb.service_resource import DynamoDBServiceResource, Table |
52 | 52 | from mypy_boto3_dynamodb.type_defs import KeysAndAttributesTypeDef |
| 53 | +from mypy_boto3_ecs.client import ECSClient |
53 | 54 | from mypy_boto3_events import EventBridgeClient |
54 | 55 | from mypy_boto3_firehose import FirehoseClient |
55 | 56 | from mypy_boto3_glue import GlueClient |
| 57 | +from mypy_boto3_healthlake.client import HealthLakeClient |
| 58 | +from mypy_boto3_iam import IAMClient |
56 | 59 | from mypy_boto3_kms.client import KMSClient |
57 | 60 | from mypy_boto3_lambda.client import LambdaClient |
58 | 61 | from mypy_boto3_logs.client import CloudWatchLogsClient |
|
72 | 75 | from mypy_boto3_sqs.client import SQSClient |
73 | 76 | from mypy_boto3_ssm.client import SSMClient |
74 | 77 | from mypy_boto3_stepfunctions import SFNClient |
| 78 | +from mypy_boto3_sts.client import STSClient |
| 79 | +from mypy_boto3_sts.type_defs import AssumeRoleRequestTypeDef |
75 | 80 |
|
76 | 81 | from nhs_aws_helpers.common import run_in_executor |
77 | 82 | from nhs_aws_helpers.s3_object_writer import S3ObjectWriter |
@@ -191,6 +196,10 @@ def backup_client(session: Optional[Session] = None, config: Optional[Config] = |
191 | 196 | return _aws("backup", "client", session, config) # type: ignore[no-any-return] |
192 | 197 |
|
193 | 198 |
|
| 199 | +def iam_client(session: Optional[Session] = None, config: Optional[Config] = None) -> IAMClient: |
| 200 | + return _aws("iam", "client", session, config) # type: ignore[no-any-return] |
| 201 | + |
| 202 | + |
194 | 203 | def register_retry_handler( |
195 | 204 | client_or_resource: Union[S3ServiceResource, S3Client], |
196 | 205 | on_error: Optional[Callable] = None, |
@@ -349,6 +358,18 @@ def events_client(session: Optional[Session] = None, config: Optional[Config] = |
349 | 358 | return _aws("events", "client", session, config) # type: ignore[no-any-return] |
350 | 359 |
|
351 | 360 |
|
| 361 | +def healthlake_client(session: Optional[Session] = None, config: Optional[Config] = None) -> HealthLakeClient: |
| 362 | + return _aws("healthlake", "client", session, config) # type: ignore[no-any-return] |
| 363 | + |
| 364 | + |
| 365 | +def sts_client(session: Optional[Session] = None, config: Optional[Config] = None) -> STSClient: |
| 366 | + return _aws("sts", "client", session, config) # type: ignore[no-any-return] |
| 367 | + |
| 368 | + |
| 369 | +def ecs_client(session: Optional[Session] = None, config: Optional[Config] = None) -> ECSClient: |
| 370 | + return _aws("ecs", "client", session, config) # type: ignore[no-any-return] |
| 371 | + |
| 372 | + |
352 | 373 | def s3_bucket(bucket: str, session: Optional[Session] = None, config: Optional[Config] = None) -> Bucket: |
353 | 374 | return s3_resource(session=session, config=config).Bucket(bucket) |
354 | 375 |
|
@@ -1041,19 +1062,19 @@ def assumed_credentials( |
1041 | 1062 |
|
1042 | 1063 | sts_client = boto3.client("sts", region_name=region, endpoint_url=endpoint_url) |
1043 | 1064 |
|
1044 | | - params = { |
1045 | | - "RoleArn": f"arn:aws:iam::{account_id}:role/{role}", |
1046 | | - "RoleSessionName": role_session_name, |
1047 | | - "DurationSeconds": duration_seconds, |
1048 | | - } |
| 1065 | + params = AssumeRoleRequestTypeDef( |
| 1066 | + RoleArn=f"arn:aws:iam::{account_id}:role/{role}", |
| 1067 | + RoleSessionName=role_session_name, |
| 1068 | + DurationSeconds=duration_seconds, |
| 1069 | + ) |
1049 | 1070 |
|
1050 | | - response = sts_client.assume_role(**params).get("Credentials") |
| 1071 | + response = sts_client.assume_role(**params)["Credentials"] |
1051 | 1072 |
|
1052 | 1073 | credentials = { |
1053 | | - "access_key": response.get("AccessKeyId"), |
1054 | | - "secret_key": response.get("SecretAccessKey"), |
1055 | | - "token": response.get("SessionToken"), |
1056 | | - "expiry_time": response.get("Expiration").isoformat(), |
| 1074 | + "access_key": response["AccessKeyId"], |
| 1075 | + "secret_key": response["SecretAccessKey"], |
| 1076 | + "token": response["SessionToken"], |
| 1077 | + "expiry_time": response["Expiration"].isoformat(), |
1057 | 1078 | } |
1058 | 1079 | return credentials |
1059 | 1080 |
|
|
0 commit comments