From 22f1e7081326f600de27b0fe47b23f817076a86a Mon Sep 17 00:00:00 2001 From: Monty Furmie Date: Mon, 15 Jan 2024 12:21:36 +0200 Subject: [PATCH] adding support for Environment Variables --- src/run.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/run.ts b/src/run.ts index 225279d8..14628394 100644 --- a/src/run.ts +++ b/src/run.ts @@ -18,6 +18,7 @@ type Inputs = { zipPath?: string aliasName: string aliasDescription: string + environmentVariables: string } type Outputs = { @@ -28,6 +29,8 @@ type Outputs = { export const run = async (inputs: Inputs): Promise => { const client = new LambdaClient({}) + const updatedConfiration = await updateFunctionConfiguration(client, inputs) + console.log(updatedConfiration) const updatedFunction = await updateFunctionCode(client, inputs) const functionVersion = updatedFunction.Version const functionVersionARN = updatedFunction.FunctionArn @@ -57,6 +60,18 @@ export const run = async (inputs: Inputs): Promise => { return { functionVersion, functionVersionARN, functionAliasARN } } +const updateFunctionConfiguration = async (client: LambdaClient, inputs: Inputs) => { + core.info(`Updating function ${inputs.functionName} configuration`) + return await client.send( + new UpdateFunctionCodeCommand({ + FunctionName: inputs.functionName, + Environment: { + Variables: JSON.parse(inputs.environmentVariables) as Record, + }, + }), + ) +} + const updateFunctionCode = async (client: LambdaClient, inputs: Inputs) => { if (inputs.zipPath) { core.info(`Updating function ${inputs.functionName} to archive ${inputs.zipPath}`)