def _set_approval_flag()

in source/state_machine_handler.py [0:0]


    def _set_approval_flag(self, response):
        try:
            self.logger.info("Executing: " + self.__class__.__name__ + "/" + inspect.stack()[0][3])
            # set approval required to 'No', assuming if tag is not present it does not require approval
            self.event.update({'ApprovalRequired': 'no'})
            for table in response:
                # iterate through tags for each route table
                for tag in table.get('Tags'):
                    approval_key = environ.get('APPROVAL_KEY')
                    if tag.get('Key').lower().strip() == approval_key.lower().strip():
                        self.logger.info("Found approval tag key set to '{}')".format(tag.get('Value').lower()))
                        if tag.get('Value').lower().strip() == 'yes':
                            # if approval required for this route table change
                            self.logger.info('Any change to this route domain require approval.')
                            self.event.update({table.get('TransitGatewayRouteTableId'): 'approvalrequired'})
            # set approval on association changes
            if self.event.get(self.event.get('AssociationRouteTableId')) == 'approvalrequired':
                # condition to check if already existing associated VPC settings are being changed.
                # example: change in propagation, add or remove subnet.
                if self.event.get('AssociationRouteTableId') == self.event.get('ExistingAssociationRouteTableId'):
                    self.logger.info('Updating other setting for an existing association, no approval required.')
                else:
                    self.logger.info('Found association route table that requires approval')
                    self.event.update({'ApprovalRequired': 'yes'})
                    self.event.update({'AssociationNeedsApproval': 'yes'})

            # set approval on propagation changes
            # iterate through the route table ids with enabled propagations routes tables
            # in the tagging event in the propagate-to key
            for route_table in self.event.get('PropagationRouteTableIds'):
                self.logger.info("<<<<< Set approval on propagation changes for - {}".format(route_table))
                # check if this route table change requires approval
                if self.event.get(route_table) == 'approvalrequired':
                    self.logger.info("Found approval required tag on: {}".format(route_table))
                    if self.event.get('ExistingPropagationRouteTableIds') is not None and \
                            route_table in self.event.get('ExistingPropagationRouteTableIds'):
                        self.logger.info("Route table: {} is not in the existing propagation list,"
                                         " NO approval required.")
                    else:
                        self.logger.info("Route table: {} is not in the existing propagation list. "
                                         "Requires Approval.".format(route_table))
                        self.event.update({'ApprovalRequired': 'yes'})
                        self.event.update({'PropagationNeedsApproval': 'yes'})
                else:
                    self.logger.info(">>>>> Approval not required for Route Table: {}".format(route_table))

        except Exception as e:
            message = self._message(inspect.stack()[0][3], e)
            self.logger.exception(message)
            self._update_ddb_failed(e)
            raise