Skip to content

Commit

Permalink
Removed deprecated resource.snstopics
Browse files Browse the repository at this point in the history
  • Loading branch information
gitwater committed Feb 4, 2021
1 parent 9f6112d commit 69c4ccc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
8 changes: 6 additions & 2 deletions src/paco/cftemplates/cw_alarms.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ class CFBaseAlarm(StackTemplate):
def create_notification_params(self, alarm):
"Create a Parameter for each SNS Topic an alarm should notify. Return a list of Refs to those Params."
notification_paco_refs = []
alarm_parent = get_parent_by_interface(alarm, schemas.IResource)
alarm_account = alarm_parent.get_account()
for group in alarm.notification_groups:
if not self.notification_region:
region = alarm.region_name
else:
region = self.notification_region
notification_paco_refs.append(
self.paco_ctx.project['resource']['snstopics'][region][group].paco_ref + '.arn'
self.paco_ctx.project['resource']['sns'].computed[alarm_account.name][region][group].paco_ref + '.arn'
)

notification_cfn_refs = []
Expand All @@ -51,7 +53,9 @@ def create_notification_params(self, alarm):
def set_alarm_actions_to_cfn_export(self, alarm, cfn_export_dict):
"Sets the AlarmActions, OKActions and InsufficientDataActions for a Troposphere dict"
alarm_action_list = []
notification_groups = self.paco_ctx.project['resource']['snstopics'][alarm.region_name]
alarm_parent = get_parent_by_interface(alarm, schemas.IResource)
alarm_account = alarm_parent.get_account()
notification_groups = self.paco_ctx.project['resource']['sns'].computed[alarm_account.name][alarm.region_name]
for alarm_action in alarm.get_alarm_actions_paco_refs(notification_groups):
# Create parameter
param_name = 'AlarmAction{}'.format(utils.md5sum(str_data=alarm_action))
Expand Down
12 changes: 0 additions & 12 deletions src/paco/commands/display/jsonoutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,6 @@ def display_project_as_json(project):
for sns in sns.topics.values():
sns_dict = recursive_resource_export(sns)
json_docs['sns'].append(sns_dict)
# legacy 'snstopics' which are exported as if they were 'sns' for simplicity
if 'snstopics' in project['resource']:
snstopics = project['resource']['snstopics']
regions = snstopics.regions
if snstopics.regions == ['ALL']:
regions = project.active_regions
for region in regions:
for snstopic in project['resource']['snstopics'][region].values():
sns_dict = recursive_resource_export(snstopic)
sns_dict['ref'] = f"resource.sns.topics.{snstopic.name}"
sns_dict['locations'] = [{'account': snstopics.account, 'regions': regions}]
json_docs['sns'].append(sns_dict)
if 'iam' in project['resource']:
for user in project['resource']['iam'].users.values():
user_dict = recursive_resource_export(user)
Expand Down
7 changes: 4 additions & 3 deletions src/paco/config/paco_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@ def load_project(
self.get_controller('Route53')
self.get_controller('CodeCommit')
self.get_controller('S3')
self.get_controller('SNSTopics')
self.get_controller('SNS')

# Load the Service plug-ins
Expand Down Expand Up @@ -467,7 +466,7 @@ def check_notification_config(self):
"""Detect misconfigured alarm notification situations.
This happens after both MonitorConfig and NetworkEnvironments have loaded.
"""
if 'snstopics' in self.project['resource']:
if 'sns' in self.project['resource']:
for app in self.project.get_all_applications():
if app.is_enabled():
for alarm_info in app.list_alarm_info():
Expand All @@ -479,9 +478,11 @@ def check_notification_config(self):
app.name
))
# alarms with groups that do not exist
alarm_parent = get_parent_by_interface(alarm, schemas.IResource)
alarm_account = alarm_parent.get_account()
region = self.project.active_regions[0] # regions are all the same, just choose the first
for groupname in alarm.notification_groups:
if groupname not in self.project['resource']['snstopics'][region]:
if groupname not in self.project['resource']['sns'].computed[alarm_account.name][region]:
raise InvalidPacoProjectFile(
"Alarm {} for app {} notifies to group '{}' which does belong in Notification service group names.".format(
alarm.name,
Expand Down
1 change: 0 additions & 1 deletion src/paco/controllers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
'project': ProjectController,
'ec2': EC2Controller,
'cloudwatch': CloudWatchController,
'snstopics': SNTopicsGroupsController,
'sns': SNSController,
'cloudtrail': CloudTrailController,
'ssm': SSMController,
Expand Down

0 comments on commit 69c4ccc

Please sign in to comment.