From c3dcd72d1500b565b9bdf162a1531bde0244d4ec Mon Sep 17 00:00:00 2001 From: jsetton Date: Tue, 12 Nov 2024 22:15:37 -0500 Subject: [PATCH] Add lambda alias to live deploy template Signed-off-by: jsetton --- .github/scripts/generateDeployConfig.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/scripts/generateDeployConfig.js b/.github/scripts/generateDeployConfig.js index aeb9472d..22949ad9 100644 --- a/.github/scripts/generateDeployConfig.js +++ b/.github/scripts/generateDeployConfig.js @@ -93,19 +93,28 @@ function updateSkillInfraTemplate() { Description: `${schema.Resources.AlexaSkillFunction.Properties.Description} (${process.env.RELEASE_VERSION})` } }; - // Define skill function version permission resource name - const permissionResource = `AlexaSkillFunctionPermission${revision}`; - // Add skill function version permission resource - schema.Resources[permissionResource] = { + // Add skill function alias resource + schema.Resources.AlexaSkillFunctionAlias = { + Type: 'AWS::Lambda::Alias', + DeletionPolicy: 'Retain', + Properties: { + Name: 'live', + FunctionName: { Ref: 'AlexaSkillFunction' }, + FunctionVersion: { 'Fn::GetAtt': [versionResource, 'Version'] }, + Description: `${schema.Resources.AlexaSkillFunction.Properties.Description} (Live)` + } + }; + // Add skill function alias permission resource + schema.Resources.AlexaSkillFunctionAliasPermission = { Type: 'AWS::Lambda::Permission', DeletionPolicy: 'Retain', Properties: { ...schema.Resources.AlexaSkillFunctionPermission.Properties, - FunctionName: { Ref: versionResource } + FunctionName: { Ref: 'AlexaSkillFunctionAlias' } } }; // Update skill endpoint output value - schema.Outputs.SkillEndpoint.Value = { Ref: versionResource }; + schema.Outputs.SkillEndpoint.Value = { Ref: 'AlexaSkillFunctionAlias' }; // Save skill infrastructure template schema saveSchema(schema, SKILL_INFRA_TEMPLATE_FILE); }