From b61989cb35949f724518160b1b10c21765466a4b Mon Sep 17 00:00:00 2001 From: cpitchford Date: Tue, 15 May 2018 18:28:35 +0100 Subject: [PATCH 1/3] Bugfix: put_permission action parameter Boto3/AWS requires that the Action parameter of put_permissions is fully qualified as "events:PutEvents" not "PutEvents" --- moto/events/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moto/events/models.py b/moto/events/models.py index 5c1d507ca..038299996 100644 --- a/moto/events/models.py +++ b/moto/events/models.py @@ -210,7 +210,7 @@ class EventsBackend(BaseBackend): raise NotImplementedError() def put_permission(self, action, principal, statement_id): - if action is None or action != 'PutEvents': + if action is None or action != 'events:PutEvents': raise JsonRESTError('InvalidParameterValue', 'Action must be PutEvents') if principal is None or self.ACCOUNT_ID.match(principal) is None: From b6e795ce613cc336a541d948bfd91c406e843751 Mon Sep 17 00:00:00 2001 From: cpitchford Date: Tue, 15 May 2018 18:30:30 +0100 Subject: [PATCH 2/3] Testing using fully qualified Action events:PutEvents The Action parameter to put_permission must be fully qualified as events:PutEvents as per: http://boto3.readthedocs.io/en/latest/reference/services/events.html#CloudWatchEvents.Client.put_permission --- tests/test_events/test_events.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_events/test_events.py b/tests/test_events/test_events.py index e839bde5b..c421ba521 100644 --- a/tests/test_events/test_events.py +++ b/tests/test_events/test_events.py @@ -177,8 +177,8 @@ def test_remove_targets(): def test_permissions(): client = boto3.client('events', 'eu-central-1') - client.put_permission(Action='PutEvents', Principal='111111111111', StatementId='Account1') - client.put_permission(Action='PutEvents', Principal='222222222222', StatementId='Account2') + client.put_permission(Action='events:PutEvents', Principal='111111111111', StatementId='Account1') + client.put_permission(Action='events:PutEvents', Principal='222222222222', StatementId='Account2') resp = client.describe_event_bus() assert len(resp['Policy']['Statement']) == 2 From 176f19136c22f9fb32a6dc0aaed813ddad15915b Mon Sep 17 00:00:00 2001 From: cpitchford Date: Tue, 15 May 2018 18:58:16 +0100 Subject: [PATCH 3/3] Action is now recorded as event:PutEvents (fully qualified) We no longer need to amend how the Action is reported in the describe_event_bus policy --- moto/events/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moto/events/models.py b/moto/events/models.py index 038299996..07f19cbab 100644 --- a/moto/events/models.py +++ b/moto/events/models.py @@ -235,7 +235,7 @@ class EventsBackend(BaseBackend): 'Sid': statement_id, 'Effect': 'Allow', 'Principal': {'AWS': 'arn:aws:iam::{0}:root'.format(data['principal'])}, - 'Action': 'events:{0}'.format(data['action']), + 'Action': data['action'], 'Resource': arn }) return {