def generate_policy()

in chalice/policy.py [0:0]


    def generate_policy(self, config: Config) -> Dict[str, Any]:
        """Auto generate policy for an application."""
        # Admittedly, this is pretty bare bones logic for the time
        # being.  All it really does it work out, given a Config instance,
        # which files need to analyzed and then delegates to the
        # appropriately analyzer functions to do the real work.
        # This may change in the future.
        app_py = os.path.join(config.project_dir, 'app.py')
        assert self._osutils.file_exists(app_py)
        app_source = self._osutils.get_file_contents(app_py, binary=False)
        app_policy = policy_from_source_code(app_source)
        app_policy['Statement'].append(CLOUDWATCH_LOGS)
        if config.subnet_ids and config.security_group_ids:
            app_policy['Statement'].append(VPC_ATTACH_POLICY)
        if config.xray_enabled:
            app_policy['Statement'].append(XRAY_POLICY)
        return app_policy