Skip to content

Commit 003941e

Browse files
authored
feat(ec2): enable EC2 experiment #6222
## Problem EC2 is currently hidden behind dev mode. ## Solution Make it an experimental feature that customers can enable. Also, remove some old experiments from settings page description.
1 parent ce5e05b commit 003941e

File tree

7 files changed

+43
-33
lines changed

7 files changed

+43
-33
lines changed

packages/core/package.nls.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"AWS.configuration.description.suppressPrompts": "Prompts which ask for confirmation. Checking an item suppresses the prompt.",
2121
"AWS.configuration.enableCodeLenses": "Enable SAM hints in source code and template.yaml files",
2222
"AWS.configuration.description.resources.enabledResources": "AWS resources to display in the 'Resources' portion of the explorer.",
23-
"AWS.configuration.description.experiments": "Try experimental features and give feedback. Note that experimental features may be removed at any time.\n * `jsonResourceModification` - Enables basic create, update, and delete support for cloud resources via the JSON Resources explorer component.\n * `samSyncCode` - Adds an additional code-only option when synchronizing SAM applications. Code-only synchronizations are faster but can cause drift in the CloudFormation stack. Does nothing when using the legacy SAM deploy feature.\n * `iamPolicyChecks` - Enables IAM Policy Checks feature, allowing users to validate IAM policies against IAM policy grammar, AWS best practices, and specified security standards.",
23+
"AWS.configuration.description.experiments": "Try experimental features and give feedback. Note that experimental features may be removed at any time.\n * `jsonResourceModification` - Enables basic create, update, and delete support for cloud resources via the JSON Resources explorer component.\n * `ec2RemoteConnect` - Allows interfacing with EC2 instances with options to start, stop, and establish remote connections. Remote connections are done over SSM and can be through a terminal or a remote VSCode window.",
2424
"AWS.stepFunctions.asl.format.enable.desc": "Enables the default formatter used with Amazon States Language files",
2525
"AWS.stepFunctions.asl.maxItemsComputed.desc": "The maximum number of outline symbols and folding regions computed (limited for performance reasons).",
2626
"AWS.configuration.description.awssam.debug.api": "API Gateway configuration",

packages/core/src/awsexplorer/regionNode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ import { DefaultSchemaClient } from '../shared/clients/schemaClient'
2929
import { getEcsRootNode } from '../awsService/ecs/model'
3030
import { compareTreeItems, TreeShim } from '../shared/treeview/utils'
3131
import { Ec2ParentNode } from '../awsService/ec2/explorer/ec2ParentNode'
32-
import { DevSettings } from '../shared/settings'
3332
import { Ec2Client } from '../shared/clients/ec2Client'
3433
import { isCloud9 } from '../shared/extensionUtilities'
34+
import { Experiments } from '../shared/settings'
3535

3636
interface ServiceNode {
3737
allRegions?: boolean
@@ -65,7 +65,7 @@ const serviceCandidates: ServiceNode[] = [
6565
},
6666
{
6767
serviceId: 'ec2',
68-
when: () => DevSettings.instance.isDevMode(),
68+
when: () => Experiments.instance.isExperimentEnabled('ec2RemoteConnect'),
6969
createFn: (regionCode: string, partitionId: string) =>
7070
new Ec2ParentNode(regionCode, partitionId, new Ec2Client(regionCode)),
7171
},

packages/core/src/shared/settings-toolkit.gen.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ export const toolkitSettings = {
4141
"ssoCacheError": {}
4242
},
4343
"aws.experiments": {
44-
"jsonResourceModification": {}
44+
"jsonResourceModification": {},
45+
"ec2RemoteConnect": {}
4546
},
4647
"aws.resources.enabledResources": {},
4748
"aws.lambda.recentlyUploaded": {},

packages/core/src/shared/settings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,12 +726,12 @@ export class Experiments extends Settings.define(
726726
'aws.experiments',
727727
toRecord(keys(experiments), () => Boolean)
728728
) {
729-
public async isExperimentEnabled(name: ExperimentName): Promise<boolean> {
729+
public isExperimentEnabled(name: ExperimentName): boolean {
730730
try {
731731
return this._getOrThrow(name, false)
732732
} catch (error) {
733733
this._log(`experiment check for ${name} failed: %s`, error)
734-
await this.reset()
734+
this.reset().catch((e) => getLogger().error(`failed to reset experiment settings: %O`, e))
735735

736736
return false
737737
}

packages/core/src/test/shared/settings.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,17 +521,17 @@ describe('Experiments', function () {
521521
// The `Experiments` class is basically an immutable form of `PromptSettings`
522522

523523
it('returns false when the setting is missing', async function () {
524-
assert.strictEqual(await sut.isExperimentEnabled('jsonResourceModification'), false)
524+
assert.strictEqual(sut.isExperimentEnabled('jsonResourceModification'), false)
525525
})
526526

527527
it('returns false for invalid types', async function () {
528528
await sut.update('jsonResourceModification', 'definitely a boolean' as unknown as boolean)
529-
assert.strictEqual(await sut.isExperimentEnabled('jsonResourceModification'), false)
529+
assert.strictEqual(sut.isExperimentEnabled('jsonResourceModification'), false)
530530
})
531531

532532
it('returns true when the flag is set', async function () {
533533
await sut.update('jsonResourceModification', true)
534-
assert.strictEqual(await sut.isExperimentEnabled('jsonResourceModification'), true)
534+
assert.strictEqual(sut.isExperimentEnabled('jsonResourceModification'), true)
535535
})
536536

537537
it('fires events from nested settings', async function () {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "Enable the EC2 experiment (setting id: `aws.experiments`) in VSCode settings to try the new EC2 features of AWS Toolkit! Remote Connect and Open Terminal to EC2 instances, list EC2 instances and view their status in AWS Explorer. "
4+
}

packages/toolkit/package.json

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,17 @@
240240
"type": "object",
241241
"markdownDescription": "%AWS.configuration.description.experiments%",
242242
"default": {
243-
"jsonResourceModification": false
243+
"jsonResourceModification": false,
244+
"ec2RemoteConnect": false
244245
},
245246
"properties": {
246247
"jsonResourceModification": {
247248
"type": "boolean",
248249
"default": false
250+
},
251+
"ec2RemoteConnect": {
252+
"type": "boolean",
253+
"default": false
249254
}
250255
},
251256
"additionalProperties": false
@@ -1203,27 +1208,27 @@
12031208
},
12041209
{
12051210
"command": "aws.ec2.openRemoteConnection",
1206-
"when": "aws.isDevMode"
1211+
"when": "config.aws.experiments.ec2RemoteConnect"
12071212
},
12081213
{
12091214
"command": "aws.ec2.openTerminal",
1210-
"when": "aws.isDevMode"
1215+
"when": "config.aws.experiments.ec2RemoteConnect"
12111216
},
12121217
{
12131218
"command": "aws.ec2.linkToLaunch",
1214-
"when": "aws.isDevMode"
1219+
"when": "config.aws.experiments.ec2RemoteConnect"
12151220
},
12161221
{
12171222
"command": "aws.ec2.startInstance",
1218-
"when": "aws.isDevMode"
1223+
"when": "config.aws.experiments.ec2RemoteConnect"
12191224
},
12201225
{
12211226
"command": "aws.ec2.stopInstance",
1222-
"when": "aws.isDevMode"
1227+
"when": "config.aws.experiments.ec2RemoteConnect"
12231228
},
12241229
{
12251230
"command": "aws.ec2.rebootInstance",
1226-
"when": "aws.isDevMode"
1231+
"when": "config.aws.experiments.ec2RemoteConnect"
12271232
},
12281233
{
12291234
"command": "aws.dev.openMenu",
@@ -1448,62 +1453,67 @@
14481453
{
14491454
"command": "aws.ec2.openTerminal",
14501455
"group": "0@1",
1451-
"when": "viewItem =~ /^(awsEc2(Parent|Running)Node)$/"
1456+
"when": "viewItem =~ /^(awsEc2(Parent|Running)Node)$/ && config.aws.experiments.ec2RemoteConnect"
14521457
},
14531458
{
14541459
"command": "aws.ec2.openTerminal",
14551460
"group": "inline@1",
1456-
"when": "viewItem =~ /^(awsEc2(Parent|Running)Node)$/"
1461+
"when": "viewItem =~ /^(awsEc2(Parent|Running)Node)$/ && config.aws.experiments.ec2RemoteConnect"
14571462
},
14581463
{
14591464
"command": "aws.ec2.linkToLaunch",
14601465
"group": "0@1",
1461-
"when": "viewItem =~ /^(awsEc2ParentNode)$/"
1466+
"when": "viewItem =~ /^(awsEc2ParentNode)$/ && config.aws.experiments.ec2RemoteConnect"
14621467
},
14631468
{
14641469
"command": "aws.ec2.linkToLaunch",
14651470
"group": "inline@1",
1466-
"when": "viewItem =~ /^(awsEc2ParentNode)$/"
1471+
"when": "viewItem =~ /^(awsEc2ParentNode)$/ && config.aws.experiments.ec2RemoteConnect"
14671472
},
14681473
{
14691474
"command": "aws.ec2.openRemoteConnection",
14701475
"group": "0@1",
1471-
"when": "viewItem =~ /^(awsEc2(Parent|Running)Node)$/"
1476+
"when": "viewItem =~ /^(awsEc2(Parent|Running)Node)$/ && config.aws.experiments.ec2RemoteConnect"
14721477
},
14731478
{
14741479
"command": "aws.ec2.openRemoteConnection",
14751480
"group": "inline@1",
1476-
"when": "viewItem =~ /^(awsEc2(Parent|Running)Node)$/"
1481+
"when": "viewItem =~ /^(awsEc2(Parent|Running)Node)$/ && config.aws.experiments.ec2RemoteConnect"
14771482
},
14781483
{
14791484
"command": "aws.ec2.startInstance",
14801485
"group": "0@1",
1481-
"when": "viewItem == awsEc2StoppedNode"
1486+
"when": "viewItem == awsEc2StoppedNode && config.aws.experiments.ec2RemoteConnect"
14821487
},
14831488
{
14841489
"command": "aws.ec2.startInstance",
14851490
"group": "inline@1",
1486-
"when": "viewItem == awsEc2StoppedNode"
1491+
"when": "viewItem == awsEc2StoppedNode && config.aws.experiments.ec2RemoteConnect"
14871492
},
14881493
{
14891494
"command": "aws.ec2.stopInstance",
14901495
"group": "0@1",
1491-
"when": "viewItem == awsEc2RunningNode"
1496+
"when": "viewItem == awsEc2RunningNode && config.aws.experiments.ec2RemoteConnect"
14921497
},
14931498
{
14941499
"command": "aws.ec2.stopInstance",
14951500
"group": "inline@1",
1496-
"when": "viewItem == awsEc2RunningNode"
1501+
"when": "viewItem == awsEc2RunningNode && config.aws.experiments.ec2RemoteConnect"
14971502
},
14981503
{
14991504
"command": "aws.ec2.rebootInstance",
15001505
"group": "0@1",
1501-
"when": "viewItem == awsEc2RunningNode"
1506+
"when": "viewItem == awsEc2RunningNode && config.aws.experiments.ec2RemoteConnect"
15021507
},
15031508
{
15041509
"command": "aws.ec2.rebootInstance",
15051510
"group": "inline@1",
1506-
"when": "viewItem == awsEc2RunningNode"
1511+
"when": "viewItem == awsEc2RunningNode && config.aws.experiments.ec2RemoteConnect"
1512+
},
1513+
{
1514+
"command": "aws.ec2.copyInstanceId",
1515+
"when": "view == aws.explorer && viewItem =~ /^(awsEc2(Running|Stopped|Pending)Node)$/ && config.aws.experiments.ec2RemoteConnect",
1516+
"group": "2@0"
15071517
},
15081518
{
15091519
"command": "aws.ecr.createRepository",
@@ -1605,11 +1615,6 @@
16051615
"when": "!config.aws.samcli.legacyDeploy && view == aws.explorer && viewItem =~ /^(awsLambdaNode|awsRegionNode|awsCloudFormationRootNode)$/",
16061616
"group": "1@2"
16071617
},
1608-
{
1609-
"command": "aws.ec2.copyInstanceId",
1610-
"when": "view == aws.explorer && viewItem =~ /^(awsEc2(Running|Stopped|Pending)Node)$/",
1611-
"group": "2@0"
1612-
},
16131618
{
16141619
"command": "aws.ecr.copyTagUri",
16151620
"when": "view == aws.explorer && viewItem == awsEcrTagNode",

0 commit comments

Comments
 (0)