Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow deploys with existing role #96

Merged
merged 1 commit into from
Jan 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions kappa/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ def __init__(self, config_file, environment=None,
if recording_path:
self.pill = placebo.attach(self.session, recording_path)
self.pill.record()
self.policy = kappa.policy.Policy(
self, self.config['environments'][self.environment])
if self.config['environments'][self.environment].get('policy',None):
self.policy = kappa.policy.Policy(
self, self.config['environments'][self.environment])
else:
self.policy = None
self.role = kappa.role.Role(
self, self.config['environments'][self.environment])
self.function = kappa.function.Function(
Expand Down
3 changes: 2 additions & 1 deletion kappa/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ def __init__(self, context, config, iam_client=None):
self._iam_client = kappa.awsclient.create_client(
'iam', context.session)
self._arn = None
self._config_name = config.get('role', None) and config['role'].get('name', None)

@property
def name(self):
return '{}_{}'.format(self._context.name, self._context.environment)
return self._config_name or '{}_{}'.format(self._context.name, self._context.environment)

@property
def arn(self):
Expand Down
16 changes: 16 additions & 0 deletions samples/simple/kappa-existing-role.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: kappa-simple
environments:
dev:
profile: <your profile here>
region: <your region here>
# Noo need to specify a policy since we are using an already existing role
role:
name: some-role-name

lambda:
description: A very simple Kappa example
handler: simple.handler
runtime: python2.7
memory_size: 128
timeout: 3
2 changes: 1 addition & 1 deletion tests/unit/test_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def setUp(self):
self.context.environment),
'Arn': randomword(10)
}
self.role = Role(self.context, None, iam_client=self.iam_client)
self.role = Role(self.context, {'environments': {'dev': {}}}, iam_client=self.iam_client)

def _expect_get_role(self):
get_role_resp = {'Role': self.role_record}
Expand Down