Skip to content

Commit

Permalink
Merge pull request aws#1130 from nkeyes/package-layers
Browse files Browse the repository at this point in the history
add layers to SAM template for package command
  • Loading branch information
stealthycoin authored Jun 5, 2019
2 parents d7dd8d9 + 953c716 commit 31acf9e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Next Release (TBD)
(`#1110 <https://github.com/aws/chalice/issues/1110>`__)
* Support repeating values in the query string
(`#1131 <https://github.com/aws/chalice/issues/1131>`__)
* Add layer support to chalice package
(`#1130 <https://github.com/aws/chalice/issues/1130>`__)


1.8.0
Expand Down
6 changes: 6 additions & 0 deletions chalice/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ def _generate_lambdafunction(self, resource, template):
}
lambdafunction_definition['Properties'].update(
reserved_concurrency_config)
if resource.layers:
layers_config = {
'Layers': resource.layers
} # type: Dict[str, List[str]]
lambdafunction_definition['Properties'].update(layers_config)

resources[cfn_name] = lambdafunction_definition
self._add_iam_role(resource, resources[cfn_name])

Expand Down
10 changes: 10 additions & 0 deletions tests/unit/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@ def test_adds_reserved_concurrency_when_provided(self, sample_app):
cfn_resource = list(template['Resources'].values())[0]
assert cfn_resource['Properties']['ReservedConcurrentExecutions'] == 5

def test_adds_layers_when_provided(self, sample_app):
function = self.lambda_function()
function.layers = ['arn:aws:layer1', 'arn:aws:layer2']
template = self.template_gen.generate_sam_template([function])
cfn_resource = list(template['Resources'].values())[0]
assert cfn_resource['Properties']['Layers'] == [
'arn:aws:layer1',
'arn:aws:layer2'
]

def test_duplicate_resource_name_raises_error(self):
one = self.lambda_function()
two = self.lambda_function()
Expand Down

0 comments on commit 31acf9e

Please sign in to comment.