Skip to content

Commit

Permalink
Detail how to use Sceptre hooks to deploy lambda (#983)
Browse files Browse the repository at this point in the history
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 <[email protected]>

Co-authored-by: Khai Do <[email protected]>
  • Loading branch information
zxiiro and zaro0508 authored Apr 2, 2021
1 parent 1ac6d30 commit c710345
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/_source/docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c710345

Please sign in to comment.