Skip to content

Commit

Permalink
Fix regression when using role arn in package command
Browse files Browse the repository at this point in the history
We need a noop method for precreated roles in the template generator.
This was missed in testing because the models were directly
passed to the template generator instead of using the
dependency builder.  In this case we were only passing the
LambdaFunction resource to the template generator, but
in reality we'd also pass the `models.IAMRole` resource
as well because it's a dependency of the lambda function.

Fixes aws#793.
  • Loading branch information
jamesls committed Apr 12, 2018
1 parent 19be95a commit 2a8a187
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Next Release (TBD)
(`#715 <https://github.com/aws/chalice/pull/715>`__)
* Fix parsing empty query strings in local mode
(`#767 <https://github.com/aws/chalice/pull/767>`__)
* Fix regression in ``chalice package`` when using role arns
(`#793 <https://github.com/aws/chalice/issues/793>`__)


1.2.0
Expand Down
4 changes: 4 additions & 0 deletions chalice/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ def _generate_deploymentpackage(self, resource, template):
# type: (models.DeploymentPackage, Dict[str, Any]) -> None
pass

def _generate_precreatediamrole(self, resource, template):
# type: (models.DeploymentPackage, Dict[str, Any]) -> None
pass

def _default(self, resource, template):
# type: (models.Model, Dict[str, Any]) -> None
raise NotImplementedError(resource)
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ def test_sam_generates_sam_template_basic(self, sample_app):
'RestAPI',
]

def test_supports_precreated_role(self):
builder = DependencyBuilder()
resources = builder.build_dependencies(
models.Application(
stage='dev',
resources=[self.lambda_function()],
)
)
template = self.template_gen.generate_sam_template(resources)
assert template['Resources']['Foo']['Properties']['Role'] == 'role:arn'

def test_sam_injects_policy(self, sample_app):
function = models.LambdaFunction(
resource_name='foo',
Expand Down

0 comments on commit 2a8a187

Please sign in to comment.