def _ensure_listeners_default_action_has_arn(self, listeners): """ If a listener DefaultAction has been passed with a Target Group Name instead of ARN, lookup the ARN and replace the name. :param listeners: a list of listener dicts :return: the same list of dicts ensuring that each listener DefaultActions dict has TargetGroupArn key. If a TargetGroupName key exists, it is removed. """ if not listeners: listeners = [] fixed_listeners = [] for listener in listeners: fixed_actions = [] for action in listener['DefaultActions']: if 'TargetGroupName' in action: action['TargetGroupArn'] = convert_tg_name_to_arn(self.connection, self.module, action['TargetGroupName']) del action['TargetGroupName'] fixed_actions.append(action) listener['DefaultActions'] = fixed_actions fixed_listeners.append(listener) return fixed_listeners
def _ensure_rules_action_has_arn(self, rules): """ If a rule Action has been passed with a Target Group Name instead of ARN, lookup the ARN and replace the name. :param rules: a list of rule dicts :return: the same list of dicts ensuring that each rule Actions dict has TargetGroupArn key. If a TargetGroupName key exists, it is removed. """ for rule in rules: if 'TargetGroupName' in rule['Actions'][0]: rule['Actions'][0]['TargetGroupArn'] = convert_tg_name_to_arn(self.connection, self.module, rule['Actions'][0]['TargetGroupName']) del rule['Actions'][0]['TargetGroupName'] return rules
def _ensure_listeners_default_action_has_arn(self, listeners): """ If a listener DefaultAction has been passed with a Target Group Name instead of ARN, lookup the ARN and replace the name. :param listeners: a list of listener dicts :return: the same list of dicts ensuring that each listener DefaultActions dict has TargetGroupArn key. If a TargetGroupName key exists, it is removed. """ if not listeners: listeners = [] for listener in listeners: if 'TargetGroupName' in listener['DefaultActions'][0]: listener['DefaultActions'][0]['TargetGroupArn'] = convert_tg_name_to_arn(self.connection, self.module, listener['DefaultActions'][0]['TargetGroupName']) del listener['DefaultActions'][0]['TargetGroupName'] return listeners
def _ensure_rules_action_has_arn(self, rules): """ If a rule Action has been passed with a Target Group Name instead of ARN, lookup the ARN and replace the name. :param rules: a list of rule dicts :return: the same list of dicts ensuring that each rule Actions dict has TargetGroupArn key. If a TargetGroupName key exists, it is removed. """ fixed_rules = [] for rule in rules: fixed_actions = [] for action in rule['Actions']: if 'TargetGroupName' in action: action['TargetGroupArn'] = convert_tg_name_to_arn(self.connection, self.module, action['TargetGroupName']) del action['TargetGroupName'] fixed_actions.append(action) rule['Actions'] = fixed_actions fixed_rules.append(rule) return fixed_rules