From 6f74ab9a21812a2ef85934f3f77c78ccb71959a9 Mon Sep 17 00:00:00 2001
From: jonathan Ifegunni
Date: Wed, 22 Jan 2025 11:08:40 -0800
Subject: [PATCH 1/3] update support for enVar in the webview
---
.../core/src/awsService/appBuilder/explorer/samProject.ts | 7 ++++++-
.../core/src/lambda/vue/configEditor/samInvokeBackend.ts | 4 ++++
.../core/src/lambda/vue/configEditor/samInvokeFrontend.ts | 5 +++++
packages/core/src/test/lambda/vue/samInvokeBackend.test.ts | 3 +++
4 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/packages/core/src/awsService/appBuilder/explorer/samProject.ts b/packages/core/src/awsService/appBuilder/explorer/samProject.ts
index ce8d0c4878a..da225cc54f2 100644
--- a/packages/core/src/awsService/appBuilder/explorer/samProject.ts
+++ b/packages/core/src/awsService/appBuilder/explorer/samProject.ts
@@ -30,6 +30,9 @@ export interface ResourceTreeEntity {
Events?: ResourceTreeEntity[]
Path?: string
Method?: string
+ Environment?: {
+ Variables: Record
+ }
}
export async function getStackName(projectRoot: vscode.Uri): Promise {
@@ -81,10 +84,12 @@ 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
+ ? resource.Properties?.Environment
+ : template?.Globals?.Function?.Environment,
}
resourceTree.push(resourceEntity)
}
-
return resourceTree
}
diff --git a/packages/core/src/lambda/vue/configEditor/samInvokeBackend.ts b/packages/core/src/lambda/vue/configEditor/samInvokeBackend.ts
index ba624536b0f..8c75380a853 100644
--- a/packages/core/src/lambda/vue/configEditor/samInvokeBackend.ts
+++ b/packages/core/src/lambda/vue/configEditor/samInvokeBackend.ts
@@ -46,6 +46,9 @@ export interface ResourceData {
runtime: string
stackName: string
source: string
+ environment?: {
+ Variables: Record
+ }
}
export type AwsSamDebuggerConfigurationLoose = AwsSamDebuggerConfiguration & {
@@ -441,6 +444,7 @@ export async function registerSamDebugInvokeVueCommand(
runtime: resource.resource.Runtime!,
arn: resource.functionArn ?? '',
stackName: resource.stackName ?? '',
+ environment: resource.resource.Environment ?? undefined,
source: source,
})
await telemetry.sam_openConfigUi.run(async (span) => {
diff --git a/packages/core/src/lambda/vue/configEditor/samInvokeFrontend.ts b/packages/core/src/lambda/vue/configEditor/samInvokeFrontend.ts
index c266abb8a4b..6502accae41 100644
--- a/packages/core/src/lambda/vue/configEditor/samInvokeFrontend.ts
+++ b/packages/core/src/lambda/vue/configEditor/samInvokeFrontend.ts
@@ -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
+ )
+ }
}
}
},
diff --git a/packages/core/src/test/lambda/vue/samInvokeBackend.test.ts b/packages/core/src/test/lambda/vue/samInvokeBackend.test.ts
index 18ae33b67d0..cbad9bfff55 100644
--- a/packages/core/src/test/lambda/vue/samInvokeBackend.test.ts
+++ b/packages/core/src/test/lambda/vue/samInvokeBackend.test.ts
@@ -728,6 +728,9 @@ describe('SamInvokeWebview', () => {
},
lambda: {
runtime: 'python3.9',
+ environmentVariables: {
+ PARAM1: 'VALUE',
+ },
},
sam: {
containerBuild: false,
From 1917e72e73d48a2cfa40dd539e10c8b3408985e2 Mon Sep 17 00:00:00 2001
From: jonathan Ifegunni
Date: Thu, 23 Jan 2025 11:19:09 -0800
Subject: [PATCH 2/3] update changelogs
---
.../core/src/awsService/appBuilder/explorer/samProject.ts | 4 +---
packages/core/src/lambda/vue/configEditor/samInvokeBackend.ts | 2 +-
.../core/src/lambda/vue/configEditor/samInvokeComponent.vue | 3 ---
.../Feature-b2217598-82cb-4268-b731-e137fa6a92e8.json | 4 ++++
4 files changed, 6 insertions(+), 7 deletions(-)
create mode 100644 packages/toolkit/.changes/next-release/Feature-b2217598-82cb-4268-b731-e137fa6a92e8.json
diff --git a/packages/core/src/awsService/appBuilder/explorer/samProject.ts b/packages/core/src/awsService/appBuilder/explorer/samProject.ts
index da225cc54f2..722ec323192 100644
--- a/packages/core/src/awsService/appBuilder/explorer/samProject.ts
+++ b/packages/core/src/awsService/appBuilder/explorer/samProject.ts
@@ -84,9 +84,7 @@ 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
- ? resource.Properties?.Environment
- : template?.Globals?.Function?.Environment,
+ Environment: resource.Properties?.Environment ?? template?.Globals?.Function?.Environment,
}
resourceTree.push(resourceEntity)
}
diff --git a/packages/core/src/lambda/vue/configEditor/samInvokeBackend.ts b/packages/core/src/lambda/vue/configEditor/samInvokeBackend.ts
index 8c75380a853..2c3c8ee40dd 100644
--- a/packages/core/src/lambda/vue/configEditor/samInvokeBackend.ts
+++ b/packages/core/src/lambda/vue/configEditor/samInvokeBackend.ts
@@ -444,7 +444,7 @@ export async function registerSamDebugInvokeVueCommand(
runtime: resource.resource.Runtime!,
arn: resource.functionArn ?? '',
stackName: resource.stackName ?? '',
- environment: resource.resource.Environment ?? undefined,
+ environment: resource.resource.Environment,
source: source,
})
await telemetry.sam_openConfigUi.run(async (span) => {
diff --git a/packages/core/src/lambda/vue/configEditor/samInvokeComponent.vue b/packages/core/src/lambda/vue/configEditor/samInvokeComponent.vue
index 468d7393ac6..6d64291cff6 100644
--- a/packages/core/src/lambda/vue/configEditor/samInvokeComponent.vue
+++ b/packages/core/src/lambda/vue/configEditor/samInvokeComponent.vue
@@ -29,9 +29,6 @@
debugger to the code running in a local Docker container. open
launch.json.
- Note: 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:{"KEY":"VALUE"}
diff --git a/packages/toolkit/.changes/next-release/Feature-b2217598-82cb-4268-b731-e137fa6a92e8.json b/packages/toolkit/.changes/next-release/Feature-b2217598-82cb-4268-b731-e137fa6a92e8.json
new file mode 100644
index 00000000000..8a0f3c45a96
--- /dev/null
+++ b/packages/toolkit/.changes/next-release/Feature-b2217598-82cb-4268-b731-e137fa6a92e8.json
@@ -0,0 +1,4 @@
+{
+ "type": "Feature",
+ "description": "Update support for enVar in the webview"
+}
From acfb7c81509c19f354b774d35e256632643ac25e Mon Sep 17 00:00:00 2001
From: jonathan Ifegunni
Date: Thu, 6 Feb 2025 13:54:01 -0800
Subject: [PATCH 3/3] improve changelog message
---
.../Feature-b2217598-82cb-4268-b731-e137fa6a92e8.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/toolkit/.changes/next-release/Feature-b2217598-82cb-4268-b731-e137fa6a92e8.json b/packages/toolkit/.changes/next-release/Feature-b2217598-82cb-4268-b731-e137fa6a92e8.json
index 8a0f3c45a96..e96232f471c 100644
--- a/packages/toolkit/.changes/next-release/Feature-b2217598-82cb-4268-b731-e137fa6a92e8.json
+++ b/packages/toolkit/.changes/next-release/Feature-b2217598-82cb-4268-b731-e137fa6a92e8.json
@@ -1,4 +1,4 @@
{
"type": "Feature",
- "description": "Update support for enVar in the webview"
+ "description": "Lambda: Support for environment variables in the editor webview."
}