From c7103450e4c70135723e8c8d9a3e98ad5e762f72 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Thu, 1 Apr 2021 23:18:24 -0400 Subject: [PATCH] Detail how to use Sceptre hooks to deploy lambda (#983) In order to deploy Lambda functions using either the AWS CLI or SAM CLI we need to generate the packaged version of the Lambda functions first. This patch details how to add the "package" command using Sceptre hooks in a way that reuses existing Sceptre config.yaml file information to populate the command details. Signed-off-by: Thanh Ha Co-authored-by: Khai Do <3697686+zaro0508@users.noreply.github.com> --- docs/_source/docs/faq.rst | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/docs/_source/docs/faq.rst b/docs/_source/docs/faq.rst index e889ecce7..32b219af1 100644 --- a/docs/_source/docs/faq.rst +++ b/docs/_source/docs/faq.rst @@ -95,6 +95,38 @@ be found in these projects: - `Sage-Bionetworks Sceptre lambda github template`_ - `Versant SAM Sceptre skeleton example`_ +Another approach is to use the Sceptre `before_launch` hook to run either the +SAM or CFN "package" command to generate the packaged version of the template. + +CloudFormation Example: + +```yaml +template_path: generated/lambda-packaged.json +stack_name: cfn-lambda-example +hooks: + before_launch: + - !cmd > + aws --profile {{ stack_group_config.profile }} cloudformation package + --template-file templates/cfn-lambda.yaml + --s3-bucket {{ stack_group_config.template_bucket_name }} + --output json + --output-template-file templates/generated/lambda-packaged.json +``` + +SAM Example: + +```yaml +template_path: generated/sam-packaged.yaml +stack_name: sam-example +hooks: + before_launch: + - !cmd > + sam package --profile {{ stack_group_config.profile }} + --s3-bucket {{ stack_group_config.template_bucket_name }} + --template-file templates/sam-app.yaml + --output-template-file templates/generated/sam-packaged.yaml +``` + .. _SAM CLI: https://github.com/aws/aws-sam-cli .. _Sage-Bionetworks Sceptre lambda github template: https://github.com/Sage-Bionetworks-IT/lambda-template .. _Versant SAM Sceptre skeleton example: https://github.com/Versent/sam-sceptre