-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upd: update policy 369 to be supported by open source Cloud Custodian
- Loading branch information
1 parent
abfff80
commit a5b7b3c
Showing
19 changed files
with
196 additions
and
80 deletions.
There are no files selected for viewing
14 changes: 0 additions & 14 deletions
14
non-compatible/policies/ecc-aws-369-workspaces_cloudwatch_integration.yml
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
...tests/ecc-aws-369-workspaces_cloudwatch_integration/placebo-green/events.ListRules_1.json
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
...e/tests/ecc-aws-369-workspaces_cloudwatch_integration/placebo-red/events.ListRules_1.json
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
non-compatible/tests/ecc-aws-369-workspaces_cloudwatch_integration/red_policy_test.py
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
policies/ecc-aws-369-workspaces_cloudwatch_integration.yml
This file contains 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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright (c) 2023 EPAM Systems, Inc. | ||
# | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
policies: | ||
- name: ecc-aws-369-workspaces_cloudwatch_integration | ||
comment: '010019123100' | ||
description: | | ||
CloudWatch Events is not set up for successful logins to WorkSpaces | ||
resource: account | ||
filters: | ||
- not: | ||
- type: missing | ||
policy: | ||
resource: workspaces | ||
- type: missing | ||
policy: | ||
resource: aws.event-rule | ||
filters: | ||
- type: value | ||
key: EventPattern | ||
value: not-null | ||
- type: value | ||
key: from_json(EventPattern)."source" | ||
op: in | ||
value_type: swap | ||
value: "aws.workspaces" | ||
- or: | ||
- type: value | ||
key: from_json(EventPattern)."detail-type" | ||
op: in | ||
value_type: swap | ||
value: "WorkSpaces Access" | ||
- type: value | ||
key: from_json(EventPattern)."detail-type" | ||
value: absent | ||
|
This file contains 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
This file contains 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
This file contains 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
15 changes: 15 additions & 0 deletions
15
tests/ecc-aws-369-workspaces_cloudwatch_integration/placebo-green/events.ListRules_1.json
This file contains 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"status_code": 200, | ||
"data": { | ||
"Rules": [ | ||
{ | ||
"Name": "369_cloudwatch_rule_green", | ||
"Arn": "arn:aws:events:us-east-1:111111111111:rule/369_cloudwatch_rule_green", | ||
"EventPattern": "{\"detail-type\":[\"WorkSpaces Access\"],\"source\":[\"aws.workspaces\"]}", | ||
"State": "ENABLED", | ||
"EventBusName": "default" | ||
} | ||
], | ||
"ResponseMetadata": {} | ||
} | ||
} |
This file contains 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
22 changes: 22 additions & 0 deletions
22
...s/ecc-aws-369-workspaces_cloudwatch_integration/placebo-green/tagging.GetResources_1.json
This file contains 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"status_code": 200, | ||
"data": { | ||
"PaginationToken": "", | ||
"ResourceTagMappingList": [ | ||
{ | ||
"ResourceARN": "arn:aws:workspaces:us-east-1:111111111111:workspace/ws-3zwmywlx2", | ||
"Tags": [ | ||
{ | ||
"Key": "ComplianceStatus", | ||
"Value": "Green" | ||
}, | ||
{ | ||
"Key": "CustodiaRule", | ||
"Value": "ecc-aws-541-workspaces_cloudwatch_integration" | ||
} | ||
] | ||
} | ||
], | ||
"ResponseMetadata": {} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...s/ecc-aws-369-workspaces_cloudwatch_integration/placebo-green/tagging.GetResources_2.json
This file contains 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"status_code": 200, | ||
"data": { | ||
"PaginationToken": "", | ||
"ResourceTagMappingList": [ | ||
{ | ||
"ResourceARN": "arn:aws:events:us-east-1:111111111111:rule/369_cloudwatch_rule_green", | ||
"Tags": [ | ||
{ | ||
"Key": "ComplianceStatus", | ||
"Value": "Green" | ||
}, | ||
{ | ||
"Key": "CustodiaRule", | ||
"Value": "ecc-aws-541-workspaces_cloudwatch_integration" | ||
} | ||
] | ||
} | ||
], | ||
"ResponseMetadata": {} | ||
} | ||
} |
This file contains 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
15 changes: 15 additions & 0 deletions
15
tests/ecc-aws-369-workspaces_cloudwatch_integration/placebo-red/events.ListRules_1.json
This file contains 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"status_code": 200, | ||
"data": { | ||
"Rules": [ | ||
{ | ||
"Name": "369_cloudwatch_rule_red", | ||
"Arn": "arn:aws:events:us-east-1:111111111111:rule/369_cloudwatch_rule_red", | ||
"EventPattern": "{\"source\":[\"aws.appflow\"],\"detail-type\":[\"AppFlow Start Flow Run Report\"]}", | ||
"State": "ENABLED", | ||
"EventBusName": "default" | ||
} | ||
], | ||
"ResponseMetadata": {} | ||
} | ||
} |
This file contains 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
22 changes: 22 additions & 0 deletions
22
tests/ecc-aws-369-workspaces_cloudwatch_integration/placebo-red/tagging.GetResources_1.json
This file contains 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"status_code": 200, | ||
"data": { | ||
"PaginationToken": "", | ||
"ResourceTagMappingList": [ | ||
{ | ||
"ResourceARN": "arn:aws:workspaces:us-east-1:111111111111:workspace/ws-3zwmywlx2", | ||
"Tags": [ | ||
{ | ||
"Key": "ComplianceStatus", | ||
"Value": "Red" | ||
}, | ||
{ | ||
"Key": "CustodiaRule", | ||
"Value": "ecc-aws-541-workspaces_cloudwatch_integration" | ||
} | ||
] | ||
} | ||
], | ||
"ResponseMetadata": {} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
tests/ecc-aws-369-workspaces_cloudwatch_integration/placebo-red/tagging.GetResources_2.json
This file contains 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"status_code": 200, | ||
"data": { | ||
"PaginationToken": "", | ||
"ResourceTagMappingList": [ | ||
{ | ||
"ResourceARN": "arn:aws:events:us-east-1:111111111111:rule/369_cloudwatch_rule_red", | ||
"Tags": [ | ||
{ | ||
"Key": "ComplianceStatus", | ||
"Value": "Red" | ||
}, | ||
{ | ||
"Key": "CustodiaRule", | ||
"Value": "ecc-aws-541-workspaces_cloudwatch_integration" | ||
} | ||
] | ||
} | ||
], | ||
"ResponseMetadata": {} | ||
} | ||
} |
This file contains 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
12 changes: 12 additions & 0 deletions
12
tests/ecc-aws-369-workspaces_cloudwatch_integration/red_policy_test.py
This file contains 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import json | ||
class PolicyTest(object): | ||
|
||
def test_resources_with_client(self, base_test, resources, local_session): | ||
base_test.assertEqual(len(resources), 1) | ||
rules = local_session.client("events").list_rules() | ||
pattern=json.loads(rules['Rules'][0]['EventPattern']) | ||
base_test.assertNotEqual(pattern["detail-type"], "WorkSpaces Access") | ||
base_test.assertNotEqual(pattern["source"], "aws.workspaces") | ||
workspaces=local_session.client("workspaces").describe_workspaces().get("Workspaces",[]) | ||
base_test.assertNotEqual(len(workspaces), 0) | ||
|