Skip to content

Commit 6c122ca

Browse files
committed
refactor(core): migrate sts
1 parent 999eaa9 commit 6c122ca

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

packages/core/src/shared/clients/stsClient.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,41 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { STS } from 'aws-sdk'
7-
import { Credentials } from '@aws-sdk/types'
6+
import { STSClient, AssumeRoleCommand, GetCallerIdentityCommand } from '@aws-sdk/client-sts'
7+
import type { AssumeRoleRequest, AssumeRoleResponse, GetCallerIdentityResponse } from '@aws-sdk/client-sts'
8+
import { AwsCredentialIdentityProvider } from '@smithy/types'
89
import globals from '../extensionGlobals'
910
import { ClassToInterfaceType } from '../utilities/tsUtils'
1011

11-
export type GetCallerIdentityResponse = STS.GetCallerIdentityResponse
12+
export type { GetCallerIdentityResponse }
1213
export type StsClient = ClassToInterfaceType<DefaultStsClient>
1314
export class DefaultStsClient {
1415
public constructor(
1516
public readonly regionCode: string,
16-
private readonly credentials?: Credentials,
17+
private readonly credentials?: AwsCredentialIdentityProvider,
1718
private readonly endpointUrl?: string
1819
) {}
1920

20-
public async assumeRole(request: STS.AssumeRoleRequest): Promise<STS.AssumeRoleResponse> {
21-
const sdkClient = await this.createSdkClient()
22-
const response = await sdkClient.assumeRole(request).promise()
21+
public async assumeRole(request: AssumeRoleRequest): Promise<AssumeRoleResponse> {
22+
const sdkClient = this.createSdkClient()
23+
const response = await sdkClient.send(new AssumeRoleCommand(request))
2324
return response
2425
}
2526

26-
public async getCallerIdentity(): Promise<STS.GetCallerIdentityResponse> {
27-
const sdkClient = await this.createSdkClient()
28-
const response = await sdkClient.getCallerIdentity().promise()
27+
public async getCallerIdentity(): Promise<GetCallerIdentityResponse> {
28+
const sdkClient = this.createSdkClient()
29+
const response = await sdkClient.send(new GetCallerIdentityCommand({}))
2930
return response
3031
}
3132

32-
private async createSdkClient(): Promise<STS> {
33-
return await globals.sdkClientBuilder.createAwsService(
34-
STS,
35-
{
33+
private createSdkClient(): STSClient {
34+
return globals.sdkClientBuilderV3.createAwsService({
35+
serviceClient: STSClient,
36+
clientOptions: {
37+
region: this.regionCode,
3638
credentials: this.credentials,
37-
stsRegionalEndpoints: 'regional',
3839
endpoint: this.endpointUrl,
3940
},
40-
this.regionCode
41-
)
41+
})
4242
}
4343
}

0 commit comments

Comments
 (0)