From 5d4c8143b3390ecb0f88aad1d66bdf88ce102268 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 12 Nov 2024 22:35:03 -0500 Subject: [PATCH] Add lambda alias to live deploy template (#720) 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); }