Skip to content

Commit e810220

Browse files
authored
Merge pull request aws#6706 from aws/feature/sdkv3
feat(sdkv3): start migration to sdkv3
2 parents 00f9d3f + a1a2756 commit e810220

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+15124
-15076
lines changed

package-lock.json

Lines changed: 13345 additions & 14122 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,11 +504,15 @@
504504
"@aws-sdk/client-lambda": "<3.696.0",
505505
"@aws-sdk/client-sso": "<3.696.0",
506506
"@aws-sdk/client-sso-oidc": "<3.696.0",
507+
"@aws-sdk/client-ssm": "<3.696.0",
508+
"@aws-sdk/client-ec2": "<3.696.0",
509+
"@aws-sdk/client-iam": "<3.696.0",
507510
"@aws-sdk/credential-provider-env": "<3.696.0",
508511
"@aws-sdk/credential-provider-process": "<3.696.0",
509512
"@aws-sdk/credential-provider-sso": "<3.696.0",
510513
"@aws-sdk/property-provider": "<3.696.0",
511514
"@aws-sdk/smithy-client": "<3.696.0",
515+
"@aws-sdk/protocol-http": "<3.696.0",
512516
"@aws-sdk/util-arn-parser": "<3.696.0",
513517
"@aws/mynah-ui": "^4.23.0",
514518
"@gerhobbelt/gitignore-parser": "^0.2.0-9",
@@ -518,6 +522,8 @@
518522
"@smithy/service-error-classification": "^3.0.0",
519523
"@smithy/shared-ini-file-loader": "^3.0.0",
520524
"@smithy/util-retry": "^3.0.0",
525+
"@smithy/fetch-http-handler": "^3.0.0",
526+
"@smithy/node-http-handler": "^3.0.0",
521527
"@vscode/debugprotocol": "^1.57.0",
522528
"@zip.js/zip.js": "^2.7.41",
523529
"adm-zip": "^0.5.10",
@@ -557,7 +563,8 @@
557563
"winston": "^3.11.0",
558564
"winston-transport": "^4.6.0",
559565
"xml2js": "^0.6.1",
560-
"yaml-cfn": "^0.3.2"
566+
"yaml-cfn": "^0.3.2",
567+
"http2": "^3.3.6"
561568
},
562569
"overrides": {
563570
"webfont": {

packages/core/src/awsService/apprunner/wizards/apprunnerCreateServiceWizard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { AppRunnerCodeRepositoryWizard } from './codeRepositoryWizard'
1515
import { GitExtension } from '../../../shared/extensions/git'
1616
import { makeDeploymentButton } from './deploymentButton'
1717
import { createExitPrompter } from '../../../shared/ui/common/exitPrompter'
18-
import { DefaultIamClient } from '../../../shared/clients/iamClient'
18+
import { IamClient } from '../../../shared/clients/iam'
1919
import { DefaultEcrClient } from '../../../shared/clients/ecrClient'
2020
import { DefaultAppRunnerClient } from '../../../shared/clients/apprunnerClient'
2121
import { getAppRunnerCreateServiceDocUrl } from '../../../shared/extensionUtilities'
@@ -102,7 +102,7 @@ export class CreateAppRunnerServiceWizard extends Wizard<AppRunner.CreateService
102102
initState: WizardState<AppRunner.CreateServiceRequest> = {},
103103
implicitState: WizardState<AppRunner.CreateServiceRequest> = {},
104104
clients = {
105-
iam: new DefaultIamClient(region),
105+
iam: new IamClient(region),
106106
ecr: new DefaultEcrClient(region),
107107
apprunner: new DefaultAppRunnerClient(region),
108108
}

packages/core/src/awsService/apprunner/wizards/imageRepositoryWizard.ts

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

6-
import { AppRunner, IAM } from 'aws-sdk'
6+
import { AppRunner } from 'aws-sdk'
77
import { createCommonButtons, QuickInputButton, QuickInputToggleButton } from '../../../shared/ui/buttons'
88
import { toArrayAsync } from '../../../shared/utilities/collectionUtils'
99
import { EcrClient, EcrRepository } from '../../../shared/clients/ecrClient'
@@ -17,7 +17,7 @@ import * as nls from 'vscode-nls'
1717
import { WizardForm } from '../../../shared/wizards/wizardForm'
1818
import { createVariablesPrompter } from '../../../shared/ui/common/variablesPrompter'
1919
import { makeDeploymentButton } from './deploymentButton'
20-
import { IamClient } from '../../../shared/clients/iamClient'
20+
import { IamClient, IamRole } from '../../../shared/clients/iam'
2121
import { createRolePrompter } from '../../../shared/ui/common/roles'
2222
import { getLogger } from '../../../shared/logger/logger'
2323
import { getAppRunnerCreateServiceDocUrl, isCloud9 } from '../../../shared/extensionUtilities'
@@ -35,7 +35,7 @@ interface ImagePrompterOptions {
3535
extraButtons?: QuickInputButton<void | WizardControl>
3636
}
3737

38-
function createEcrRole(client: IamClient): Promise<IAM.Role> {
38+
function createEcrRole(client: IamClient): Promise<IamRole> {
3939
const policy = {
4040
Version: '2008-10-17',
4141
Statement: [
@@ -257,14 +257,13 @@ export class AppRunnerImageRepositoryWizard extends Wizard<AppRunner.SourceConfi
257257
constructor(ecrClient: EcrClient, iamClient: IamClient, autoDeployButton = makeDeploymentButton()) {
258258
super()
259259
const form = this.form
260-
const createAccessRolePrompter = () => {
261-
return createRolePrompter(iamClient, {
260+
const createAccessRolePrompter = () =>
261+
createRolePrompter(iamClient, {
262262
title: localize('AWS.apprunner.createService.selectRole.title', 'Select a role to pull from ECR'),
263263
helpUrl: getAppRunnerCreateServiceDocUrl(),
264264
roleFilter: (role) => (role.AssumeRolePolicyDocument ?? '').includes(appRunnerEcrEntity),
265265
createRole: createEcrRole.bind(undefined, iamClient),
266266
}).transform((resp) => resp.Arn)
267-
}
268267

269268
form.ImageRepository.applyBoundForm(createImageRepositorySubForm(ecrClient, autoDeployButton))
270269
form.AuthenticationConfiguration.AccessRoleArn.bindPrompter(createAccessRolePrompter, {

packages/core/src/awsService/ec2/commands.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
*/
55
import { Ec2InstanceNode } from './explorer/ec2InstanceNode'
66
import { Ec2Node } from './explorer/ec2ParentNode'
7-
import { SafeEc2Instance, Ec2Client } from '../../shared/clients/ec2Client'
7+
import { Ec2Instance, Ec2Client } from '../../shared/clients/ec2'
88
import { copyToClipboard } from '../../shared/utilities/messages'
99
import { ec2LogSchema } from './ec2LogDocumentProvider'
1010
import { getAwsConsoleUrl } from '../../shared/awsConsole'
1111
import { showRegionPrompter } from '../../auth/utils'
1212
import { openUrl } from '../../shared/utilities/vsCodeUtils'
1313
import { showFile } from '../../shared/utilities/textDocumentUtilities'
1414
import { Ec2ConnecterMap } from './connectionManagerMap'
15-
import { Ec2Prompter, Ec2Selection, instanceFilter } from './prompter'
15+
import { getSelection } from './prompter'
1616

1717
export async function openTerminal(connectionManagers: Ec2ConnecterMap, node?: Ec2Node) {
1818
const selection = await getSelection(node)
@@ -27,14 +27,14 @@ export async function openRemoteConnection(connectionManagers: Ec2ConnecterMap,
2727
}
2828

2929
export async function startInstance(node?: Ec2Node) {
30-
const prompterFilter = (instance: SafeEc2Instance) => instance.LastSeenStatus !== 'running'
30+
const prompterFilter = (instance: Ec2Instance) => instance.LastSeenStatus !== 'running'
3131
const selection = await getSelection(node, prompterFilter)
3232
const client = new Ec2Client(selection.region)
3333
await client.startInstanceWithCancel(selection.instanceId)
3434
}
3535

3636
export async function stopInstance(node?: Ec2Node) {
37-
const prompterFilter = (instance: SafeEc2Instance) => instance.LastSeenStatus !== 'stopped'
37+
const prompterFilter = (instance: Ec2Instance) => instance.LastSeenStatus !== 'stopped'
3838
const selection = await getSelection(node, prompterFilter)
3939
const client = new Ec2Client(selection.region)
4040
await client.stopInstanceWithCancel(selection.instanceId)
@@ -52,12 +52,6 @@ export async function linkToLaunchInstance(node?: Ec2Node) {
5252
await openUrl(url)
5353
}
5454

55-
async function getSelection(node?: Ec2Node, filter?: instanceFilter): Promise<Ec2Selection> {
56-
const prompter = new Ec2Prompter(filter)
57-
const selection = node && node instanceof Ec2InstanceNode ? node.toSelection() : await prompter.promptUser()
58-
return selection
59-
}
60-
6155
export async function copyInstanceId(instanceId: string): Promise<void> {
6256
await copyToClipboard(instanceId, 'Id')
6357
}

packages/core/src/awsService/ec2/ec2LogDocumentProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
import * as vscode from 'vscode'
66
import { Ec2Selection } from './prompter'
7-
import { Ec2Client } from '../../shared/clients/ec2Client'
7+
import { Ec2Client } from '../../shared/clients/ec2'
88
import { ec2LogsScheme } from '../../shared/constants'
99
import { UriSchema } from '../../shared/utilities/uriUtils'
1010

packages/core/src/awsService/ec2/explorer/ec2InstanceNode.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55
import * as vscode from 'vscode'
6-
import { Ec2Client, getNameOfInstance } from '../../../shared/clients/ec2Client'
6+
import { Ec2Client, getNameOfInstance } from '../../../shared/clients/ec2'
77
import { AWSResourceNode } from '../../../shared/treeview/nodes/awsResourceNode'
88
import { AWSTreeNodeBase } from '../../../shared/treeview/nodes/awsTreeNodeBase'
9-
import { SafeEc2Instance } from '../../../shared/clients/ec2Client'
9+
import { Ec2Instance } from '../../../shared/clients/ec2'
1010
import globals from '../../../shared/extensionGlobals'
1111
import { getIconCode } from '../utils'
1212
import { Ec2Selection } from '../prompter'
1313
import { Ec2Node, Ec2ParentNode } from './ec2ParentNode'
14-
import { EC2 } from 'aws-sdk'
1514
import { getLogger } from '../../../shared/logger/logger'
15+
import { InstanceStateName } from '@aws-sdk/client-ec2'
1616

1717
export const Ec2InstanceRunningContext = 'awsEc2RunningNode'
1818
export const Ec2InstanceStoppedContext = 'awsEc2StoppedNode'
@@ -27,15 +27,15 @@ export class Ec2InstanceNode extends AWSTreeNodeBase implements AWSResourceNode
2727
public override readonly regionCode: string,
2828
private readonly partitionId: string,
2929
// XXX: this variable is marked as readonly, but the 'status' attribute is updated when polling the nodes.
30-
public readonly instance: SafeEc2Instance
30+
public readonly instance: Ec2Instance
3131
) {
3232
super('')
3333
this.parent.addChild(this)
3434
this.updateInstance(instance)
3535
this.id = this.InstanceId
3636
}
3737

38-
public updateInstance(newInstance: SafeEc2Instance) {
38+
public updateInstance(newInstance: Ec2Instance) {
3939
this.setInstanceStatus(newInstance.LastSeenStatus)
4040
this.label = `${this.name} (${this.InstanceId}) ${this.instance.LastSeenStatus.toUpperCase()}`
4141
this.contextValue = this.getContext()
@@ -68,7 +68,7 @@ export class Ec2InstanceNode extends AWSTreeNodeBase implements AWSResourceNode
6868
return Ec2InstancePendingContext
6969
}
7070

71-
public setInstanceStatus(instanceStatus: string) {
71+
public setInstanceStatus(instanceStatus: InstanceStateName) {
7272
this.instance.LastSeenStatus = instanceStatus
7373
}
7474

@@ -79,12 +79,12 @@ export class Ec2InstanceNode extends AWSTreeNodeBase implements AWSResourceNode
7979
}
8080
}
8181

82-
public getStatus(): EC2.InstanceStateName {
82+
public getStatus(): InstanceStateName {
8383
return this.instance.LastSeenStatus
8484
}
8585

8686
public get name(): string {
87-
return getNameOfInstance(this.instance) ?? `(no name)`
87+
return this.instance.Name ?? getNameOfInstance(this.instance) ?? `(no name)`
8888
}
8989

9090
public get InstanceId(): string {

packages/core/src/awsService/ec2/explorer/ec2ParentNode.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { AWSTreeNodeBase } from '../../../shared/treeview/nodes/awsTreeNodeBase'
77
import { makeChildrenNodes } from '../../../shared/treeview/utils'
88
import { PlaceholderNode } from '../../../shared/treeview/nodes/placeholderNode'
99
import { Ec2InstanceNode } from './ec2InstanceNode'
10-
import { Ec2Client } from '../../../shared/clients/ec2Client'
10+
import { Ec2Client } from '../../../shared/clients/ec2'
1111
import { updateInPlace } from '../../../shared/utilities/collectionUtils'
1212
import { PollingSet } from '../../../shared/utilities/pollingSet'
1313

@@ -30,7 +30,7 @@ export class Ec2ParentNode extends AWSTreeNodeBase {
3030
}
3131

3232
public override async getChildren(): Promise<AWSTreeNodeBase[]> {
33-
return await makeChildrenNodes({
33+
const result = await makeChildrenNodes({
3434
getChildNodes: async () => {
3535
await this.updateChildren()
3636

@@ -39,6 +39,7 @@ export class Ec2ParentNode extends AWSTreeNodeBase {
3939
getNoChildrenPlaceholderNode: async () => new PlaceholderNode(this, this.placeHolderMessage),
4040
sort: (nodeA, nodeB) => nodeA.name.localeCompare(nodeB.name),
4141
})
42+
return result
4243
}
4344

4445
public trackPendingNode(instanceId: string) {
@@ -47,15 +48,18 @@ export class Ec2ParentNode extends AWSTreeNodeBase {
4748
}
4849
this.pollingSet.add(instanceId)
4950
}
50-
51+
// TODO: make use of childNodeLoader to avoid loading all of this at once.
5152
public async updateChildren(): Promise<void> {
52-
const ec2Instances = await (await this.ec2Client.getInstances()).toMap((instance) => instance.InstanceId)
53+
const instanceMap = await this.ec2Client
54+
.getInstances()
55+
.flatten()
56+
.toMap((instance) => instance.InstanceId)
57+
5358
updateInPlace(
5459
this.ec2InstanceNodes,
55-
ec2Instances.keys(),
56-
(key) => this.ec2InstanceNodes.get(key)!.updateInstance(ec2Instances.get(key)!),
57-
(key) =>
58-
new Ec2InstanceNode(this, this.ec2Client, this.regionCode, this.partitionId, ec2Instances.get(key)!)
60+
instanceMap.keys(),
61+
(key) => this.ec2InstanceNodes.get(key)!.updateInstance(instanceMap.get(key)!),
62+
(key) => new Ec2InstanceNode(this, this.ec2Client, this.regionCode, this.partitionId, instanceMap.get(key)!)
5963
)
6064
}
6165

0 commit comments

Comments
 (0)