-
Notifications
You must be signed in to change notification settings - Fork 1.4k
AWS::Logs::ResourcePolicy #1936
Ne 8000 w 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
Merged
markpeek
merged 5 commits into
cloudtools:main
from
jerry153fish:feature/Add-AWS-Logs-ResourcePolicy
Aug 22, 2021
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import unittest | ||
|
||
from troposphere import Retain | ||
from troposphere.logs import Destination, LogGroup | ||
from troposphere.logs import Destination, LogGroup, validate_resource_policy, LogResourcePolicy | ||
|
||
|
||
class TestLogs(unittest.TestCase): | ||
|
@@ -35,6 +35,22 @@ def test_log_destination(self): | |
self.assertIn("Type", log_destination_json) | ||
self.assertIn("Properties", log_destination_json) | ||
|
||
def test_validate_resource_policy(self): | ||
for s in ["{ \"Version\": \"2012-10-17\", \"Statement\": [ { \"Sid\": \"Route53LogsToCloudWatchLogs\", \"Effect\": \"Allow\", \"Principal\": { \"Service\": [ \"route53.amazonaws.com\" ] }, \"Action\":\"logs:PutLogEvents\", \"Resource\": \"logArn\" } ] }", {'Version': '2012-10-17', 'Statement': [{'Sid': 'Route53LogsToCloudWatchLogs', 'Effect': 'Allow', 'Principal': {'Service': ['route53.amazonaws.com']}, 'Action': 'logs:PutLogEvents', 'Resource': 'logArn'}]}]: | ||
validate_resource_policy(s) | ||
log_policy = LogResourcePolicy( | ||
"TestLogPolicy", | ||
PolicyName='TestLogPolicy', | ||
PolicyDocument=s | ||
) | ||
expected = log_policy.to_dict() | ||
properties = expected['Properties'] | ||
self.assertEqual(properties.get('PolicyDocument'), s) | ||
|
||
for s in ["", "H"*5121, "TEXT", {}]: | ||
with self.assertRaises(ValueError): | ||
validate_resource_policy(s) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This validation should take into account the other policy document types coming from awacs. This is imported via https://github.com/cloudtools/troposphere/blob/main/troposphere/compat.py
Note: the length checks won't work with some of these awacs types and additional checking needs to be done around the json_checker return types.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @markpeek So the plan will be
Any other cases need to be considered here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks like the right list of items. Thanks.