Skip to content
Merged
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
)
}
}
}
},
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": "Lambda: Support for environment variables in the editor webview."
}
Loading