Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(appbuilder): Update support for enVar in the webview #6413

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export interface ResourceTreeEntity {
Events?: ResourceTreeEntity[]
Path?: string
Method?: string
Environment?: {
Variables: Record<string, any>
}
}

export async function getStackName(projectRoot: vscode.Uri): Promise<any> {
Expand Down Expand Up @@ -81,10 +84,10 @@ function getResourceEntity(template: any): ResourceTreeEntity[] {
Handler: resource.Properties?.Handler ?? template?.Globals?.Function?.Handler,
Events: resource.Properties?.Events ? getEvents(resource.Properties.Events) : undefined,
CodeUri: resource.Properties?.CodeUri ?? template?.Globals?.Function?.CodeUri,
Environment: resource.Properties?.Environment ?? template?.Globals?.Function?.Environment,
}
resourceTree.push(resourceEntity)
}

return resourceTree
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export interface ResourceData {
runtime: string
stackName: string
source: string
environment?: {
Variables: Record<string, any>
}
}

export type AwsSamDebuggerConfigurationLoose = AwsSamDebuggerConfiguration & {
Expand Down Expand Up @@ -441,6 +444,7 @@ export async function registerSamDebugInvokeVueCommand(
runtime: resource.resource.Runtime!,
arn: resource.functionArn ?? '',
stackName: resource.stackName ?? '',
environment: resource.resource.Environment,
source: source,
})
await telemetry.sam_openConfigUi.run(async (span) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
debugger to the code running in a local Docker container. open
<a href="#" @click.prevent="openLaunchJson">launch.json</a>.<br />
<br />
<strong>Note:</strong> If you are accessing environment variables in your function code, ensure you
input them in the "Additional fields -> Lambda -> Environment variables" section, following JSON
format:<code>{"KEY":"VALUE"}</code>
</em>
</p>
<settings-panel id="config-panel" title="General configuration" description="" :start-collapsed="false">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@ export default defineComponent({
this.launchConfig.invokeTarget.lambdaHandler = this.resourceData.handler
if (this.launchConfig.lambda) {
this.launchConfig.lambda.runtime = this.resourceData.runtime
if (this.resourceData.environment?.Variables !== undefined) {
this.environmentVariables.value = JSON.stringify(
this.resourceData.environment?.Variables
)
}
Comment on lines +348 to +352
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty deeply nested, does it really depend on if (this.launchConfig.lambda) ? If not, can you pull it out a little, e.g. after if (this.launchConfig && this.resourceData) { ... }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it does

}
}
},
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/test/lambda/vue/samInvokeBackend.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,9 @@ describe('SamInvokeWebview', () => {
},
lambda: {
runtime: 'python3.9',
environmentVariables: {
PARAM1: 'VALUE',
},
},
sam: {
containerBuild: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Feature",
"description": "Update support for enVar in the webview"
Copy link
Contributor

@hayemaxi hayemaxi Feb 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"description": "Update support for enVar in the webview"
"description": "Lambda: Support for environment variables in the editor webview."

}
Loading