Skip to content

Commit f86dec1

Browse files
authored
Merge pull request #8321 from aws/autoMerge/feature/smus
Merge master into feature/smus
2 parents 6d464e0 + 4646030 commit f86dec1

File tree

128 files changed

+16124
-233
lines changed

Some content is hidden

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

128 files changed

+16124
-233
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
packages/core/src/codewhisperer/ @aws/codewhisperer-team
33
packages/core/src/amazonqFeatureDev/ @aws/earlybird
44
packages/core/src/awsService/accessanalyzer/ @aws/access-analyzer
5+
packages/core/src/awsService/cloudformation/ @aws/cfn-dev-productivity

CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,11 @@ Unlike the user setting overrides, not all of these environment variables have t
527527

528528
- `SSMDOCUMENT_LANGUAGESERVER_PORT`: The port the ssm document language server should start debugging on
529529

530+
#### CloudFormation LSP
531+
532+
- `__CLOUDFORMATIONLSP_PATH`: for aws.dev.cloudformationLsp.path
533+
- `__CLOUDFORMATIONLSP_CLOUDFORMATION_ENDPOINT`: for aws.dev.cloudformationLsp.cloudformationEndpoint
534+
530535
#### CI/Testing
531536

532537
- `GITHUB_ACTION`: The name of the current GitHub Action workflow step that is running

packages/core/scripts/test/launchTestUtilities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ async function getVSCodeCliArgs(params: {
121121
['DEVELOPMENT_PATH']: projectRootDir,
122122
['AWS_TOOLKIT_AUTOMATION']: params.suite,
123123
['TEST_DIR']: process.env.TEST_DIR,
124+
['JAVA_HOME']: process.env.JAVA_HOME,
124125
...params.env,
125126
},
126127
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
export const ResourceIdentifierDocumentationUrl =
7+
'https://docs.aws.amazon.com/cloudcontrolapi/latest/userguide/resource-identifier.html'
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import { Disposable } from 'vscode'
7+
import { LanguageClient } from 'vscode-languageclient/node'
8+
import { StacksManager } from '../stacks/stacksManager'
9+
import { ResourcesManager } from '../resources/resourcesManager'
10+
import { CloudFormationRegionManager } from '../explorer/regionManager'
11+
import globals from '../../../shared/extensionGlobals'
12+
import * as jose from 'jose'
13+
import * as crypto from 'crypto'
14+
15+
export const encryptionKey = crypto.randomBytes(32)
16+
17+
export class AwsCredentialsService implements Disposable {
18+
private authChangeListener: Disposable
19+
private client: LanguageClient | undefined
20+
21+
constructor(
22+
private stacksManager: StacksManager,
23+
private resourcesManager: ResourcesManager,
24+
private regionManager: CloudFormationRegionManager
25+
) {
26+
this.authChangeListener = globals.awsContext.onDidChangeContext(() => {
27+
void this.updateCredentialsFromActiveConnection()
28+
})
29+
}
30+
31+
async initialize(client: LanguageClient): Promise<void> {
32+
this.client = client
33+
await this.updateCredentialsFromActiveConnection()
34+
}
35+
36+
private async updateCredentialsFromActiveConnection(): Promise<void> {
37+
if (!this.client) {
38+
return
39+
}
40+
41+
const credentials = await globals.awsContext.getCredentials()
42+
const profileName = globals.awsContext.getCredentialProfileName()
43+
44+
if (credentials && profileName) {
45+
const encryptedRequest = await this.createEncryptedCredentialsRequest({
46+
profile: profileName.replaceAll('profile:', ''),
47+
region: this.regionManager.getSelectedRegion(),
48+
accessKeyId: credentials.accessKeyId,
49+
secretAccessKey: credentials.secretAccessKey,
50+
sessionToken: credentials.sessionToken,
51+
})
52+
53+
await this.client.sendRequest('aws/credentials/iam/update', encryptedRequest)
54+
}
55+
56+
void this.stacksManager.reload()
57+
void this.resourcesManager.reload()
58+
}
59+
60+
async updateRegion(): Promise<void> {
61+
await this.updateCredentialsFromActiveConnection()
62+
}
63+
64+
private async createEncryptedCredentialsRequest(data: any): Promise<any> {
65+
const payload = new TextEncoder().encode(JSON.stringify({ data }))
66+
67+
const jwt = await new jose.CompactEncrypt(payload)
68+
.setProtectedHeader({ alg: 'dir', enc: 'A256GCM' })
69+
.encrypt(encryptionKey)
70+
71+
return {
72+
data: jwt,
73+
encrypted: true,
74+
}
75+
}
76+
77+
dispose(): void {
78+
this.authChangeListener.dispose()
79+
}
80+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import { LanguageClient } from 'vscode-languageclient/node'
7+
import {
8+
ParsedCfnEnvironmentFile,
9+
ParseCfnEnvironmentFilesParams,
10+
ParseCfnEnvironmentFilesRequest,
11+
} from './cfnEnvironmentRequestType'
12+
13+
export async function parseCfnEnvironmentFiles(
14+
client: LanguageClient,
15+
params: ParseCfnEnvironmentFilesParams
16+
): Promise<ParsedCfnEnvironmentFile[]> {
17+
const result = await client.sendRequest(ParseCfnEnvironmentFilesRequest, params)
18+
return result.parsedFiles
19+
}

0 commit comments

Comments
 (0)