Skip to content

Commit c5f0ba5

Browse files
Merge master into feature/emr
2 parents d27ad9d + 86ed46d commit c5f0ba5

File tree

8 files changed

+59
-2
lines changed

8 files changed

+59
-2
lines changed

packages/core/package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,10 @@
11891189
"command": "aws.ec2.openTerminal",
11901190
"when": "aws.isDevMode"
11911191
},
1192+
{
1193+
"command": "aws.ec2.linkToLaunch",
1194+
"when": "aws.isDevMode"
1195+
},
11921196
{
11931197
"command": "aws.ec2.startInstance",
11941198
"when": "aws.isDevMode"
@@ -1411,6 +1415,16 @@
14111415
"group": "inline@1",
14121416
"when": "viewItem =~ /^(awsEc2(Parent|Running)Node)$/"
14131417
},
1418+
{
1419+
"command": "aws.ec2.linkToLaunch",
1420+
"group": "0@1",
1421+
"when": "viewItem =~ /^(awsEc2ParentNode)$/"
1422+
},
1423+
{
1424+
"command": "aws.ec2.linkToLaunch",
1425+
"group": "inline@1",
1426+
"when": "viewItem =~ /^(awsEc2ParentNode)$/"
1427+
},
14141428
{
14151429
"command": "aws.ec2.openRemoteConnection",
14161430
"group": "0@1",
@@ -2253,6 +2267,18 @@
22532267
}
22542268
}
22552269
},
2270+
{
2271+
"command": "aws.ec2.linkToLaunch",
2272+
"title": "%AWS.command.ec2.linkToLaunch%",
2273+
"icon": "$(add)",
2274+
"category": "%AWS.title%",
2275+
"enablement": "isCloud9 || !aws.isWebExtHost",
2276+
"cloud9": {
2277+
"cn": {
2278+
"category": "%AWS.title.cn%"
2279+
}
2280+
}
2281+
},
22562282
{
22572283
"command": "aws.ec2.openRemoteConnection",
22582284
"title": "%AWS.command.ec2.openRemoteConnection%",

packages/core/package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
"AWS.command.ec2.openTerminal": "Open terminal to EC2 instance...",
125125
"AWS.command.ec2.openRemoteConnection": "Connect to EC2 instance in New Window...",
126126
"AWS.command.ec2.startInstance": "Start EC2 Instance",
127+
"AWS.command.ec2.linkToLaunch": "Launch EC2 Instance",
127128
"AWS.command.ec2.stopInstance": "Stop EC2 Instance",
128129
"AWS.command.ec2.rebootInstance": "Reboot EC2 Instance",
129130
"AWS.command.ec2.copyInstanceId": "Copy Instance Id",

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
startInstance,
1616
stopInstance,
1717
refreshExplorer,
18+
linkToLaunchInstance,
1819
} from './commands'
1920

2021
export async function activate(ctx: ExtContext): Promise<void> {
@@ -56,6 +57,12 @@ export async function activate(ctx: ExtContext): Promise<void> {
5657
await rebootInstance(node)
5758
refreshExplorer(node)
5859
})
60+
}),
61+
62+
Commands.register('aws.ec2.linkToLaunch', async (node?: Ec2Node) => {
63+
await telemetry.ec2_launchInstance.run(async (span) => {
64+
await linkToLaunchInstance(node)
65+
})
5966
})
6067
)
6168
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import { Ec2Prompter, instanceFilter, Ec2Selection } from './prompter'
1010
import { SafeEc2Instance, Ec2Client } from '../../shared/clients/ec2Client'
1111
import { copyToClipboard } from '../../shared/utilities/messages'
1212
import { getLogger } from '../../shared/logger'
13+
import { getAwsConsoleUrl } from '../../shared/awsConsole'
14+
import { showRegionPrompter } from '../../auth/utils'
15+
import { openUrl } from '../../shared/utilities/vsCodeUtils'
1316

1417
export function refreshExplorer(node?: Ec2Node) {
1518
if (node) {
@@ -53,6 +56,12 @@ export async function rebootInstance(node?: Ec2Node) {
5356
await client.rebootInstanceWithCancel(selection.instanceId)
5457
}
5558

59+
export async function linkToLaunchInstance(node?: Ec2Node) {
60+
const region = node ? node.regionCode : (await showRegionPrompter('Select Region', '')).id
61+
const url = getAwsConsoleUrl('ec2-launch', region)
62+
await openUrl(url)
63+
}
64+
5665
async function getSelection(node?: Ec2Node, filter?: instanceFilter): Promise<Ec2Selection> {
5766
const prompter = new Ec2Prompter(filter)
5867
const selection = node && node instanceof Ec2InstanceNode ? node.toSelection() : await prompter.promptUser()

packages/core/src/shared/awsConsole.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55

66
import * as vscode from 'vscode'
77

8-
export function getAwsConsoleUrl(service: 'ecr' | 'cloudformation', region: string): vscode.Uri {
8+
export function getAwsConsoleUrl(service: 'ecr' | 'cloudformation' | 'ec2-launch', region: string): vscode.Uri {
99
switch (service) {
1010
case 'ecr':
1111
return vscode.Uri.parse(`https://${region}.console.aws.amazon.com/ecr/repositories?region=${region}`)
1212
case 'cloudformation':
1313
return vscode.Uri.parse(`https://${region}.console.aws.amazon.com/cloudformation/home?region=${region}`)
14+
case 'ec2-launch':
15+
return vscode.Uri.parse(
16+
`https://${region}.console.aws.amazon.com/ec2/home?region=${region}#LaunchInstances:`
17+
)
1418
default:
1519
throw Error()
1620
}

packages/core/src/shared/sshConfig.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,16 @@ export class SshConfig {
170170
private getBaseSSHConfig(proxyCommand: string): string {
171171
// "AddKeysToAgent" will automatically add keys used on the server to the local agent. If not set, then `ssh-add`
172172
// must be done locally. It's mostly a convenience thing; private keys are _not_ shared with the server.
173-
173+
// "IdentitiesOnly yes" forces agent to only use provided identity file.
174+
// More details: https://www.ssh.com/academy/ssh/config
174175
return `
175176
# Created by AWS Toolkit for VSCode. https://github.com/aws/aws-toolkit-vscode
176177
Host ${this.configHostName}
177178
ForwardAgent yes
178179
AddKeysToAgent yes
179180
StrictHostKeyChecking accept-new
180181
ProxyCommand ${proxyCommand}
182+
IdentitiesOnly yes
181183
`
182184
}
183185

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "EC2 connect: remote connection will no longer fail with 'too many authentication attempt'"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "EC2: Launch ec2 instances from AWS Explorer"
4+
}

0 commit comments

Comments
 (0)