Skip to content

Commit

Permalink
adding support for Environment Variables
Browse files Browse the repository at this point in the history
  • Loading branch information
KingMonty committed Jan 15, 2024
1 parent cfd2c3d commit 22f1e70
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Inputs = {
zipPath?: string
aliasName: string
aliasDescription: string
environmentVariables: string
}

type Outputs = {
Expand All @@ -28,6 +29,8 @@ type Outputs = {

export const run = async (inputs: Inputs): Promise<Outputs> => {
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
Expand Down Expand Up @@ -57,6 +60,18 @@ export const run = async (inputs: Inputs): Promise<Outputs> => {
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<string, string>,
},
}),
)
}

const updateFunctionCode = async (client: LambdaClient, inputs: Inputs) => {
if (inputs.zipPath) {
core.info(`Updating function ${inputs.functionName} to archive ${inputs.zipPath}`)
Expand Down

0 comments on commit 22f1e70

Please sign in to comment.