These files let you try lfpolicy without AWS credentials:
desired.json: a desired Lake Formation LF-Tag and grant policy.desired.yaml: the same desired policy in YAML.policy-exceptions.json: a narrow example of exception-controlled risky access with reason, ticket, owner, approver, and expiry metadata.policy.py: a Python-native permission group policy that can generate desired state.policy-from-import.py: a migration example that keeps an imported desired state reference beside the equivalent Python policy model.policy-bundles.py: a Python-native policy using generic permission bundles such asreader(),producer(),steward(),data_location_access(), andadmin().permission-requests.py: a Python-native policy that models approved access requests as data and compiles them to ordinary desired state.current-snapshot.json: a deliberately incomplete current-state snapshot.access-requests.jsonandaccess-current-snapshot.json: batch access diagnosis inputs for service adapter tests.artifacts/: checked-in report fixtures for audit, plan, review bundles, explain, and explain-batch evidence.github-actions/lakeformation-drift.yml: a copyable GitHub Actions workflow for scheduled or manually dispatched drift checks against live AWS state. It expectspolicy.pyand generatedpolicy/desired.jsonin the policy repository.github-actions/lakeformation-code-scanning.yml: a copyable GitHub Actions workflow that checks generated desired state and uploads lint and audit SARIF reports to GitHub Code Scanning.pre-commit/pre-commit-config.yaml: a copyable local pre-commit hook that regenerates and checks a desired-state policy before commit.
YAML examples require installing lfpolicy[yaml]; JSON examples work with the
base package.
The snapshot is missing two desired LF-Tag values, one table tag assignment, and one LF-Tag policy grant. That makes it useful for seeing audit findings and conservative plans.
The artifacts/ directory contains pre-generated examples of the JSON and
Markdown evidence a pull request or scheduled governance job would attach:
artifacts/lfpolicy-audit.jsonartifacts/lfpolicy-plan.jsonartifacts/lfpolicy-explain.jsonartifacts/lfpolicy-explain-batch.jsonartifacts/review-bundle/artifacts/review-cases/artifacts/explain-batch-cases/
If you installed lfpolicy from PyPI and do not have this repository checked
out, generate the same kind of local demo files with:
lfpolicy sample --output-dir lfpolicy-demolfpolicy check \
--desired examples/desired.json \
--current-snapshot examples/current-snapshot.jsonThis command only reads local files. It validates the desired policy and current snapshot, then catches undefined LF-Tag keys and values in resource tag assignments and LF-Tag policy expressions.
Use policy.py when you want permission groups to be the source of truth:
lfpolicy generate examples/policy.py --output-file /tmp/lfpolicy-desired.json --force
lfpolicy check --desired /tmp/lfpolicy-desired.json --fail-on-findingsThe example assigns LF-Tags to neutral databases, tables, and a sensitive
column. It uses user-defined groups such as dataconsumer, dataengineer,
operations, and catalog_admin, while the package supplies the safer
reader(), editor(), producer(), table_creator(),
database_creator(), steward(), data_location_access(), and admin()
templates.
To see the newer generic bundle names:
lfpolicy generate examples/policy-bundles.py --output-file /tmp/lfpolicy-bundles.json --force
lfpolicy check --desired /tmp/lfpolicy-bundles.json --fail-on-findingsTo see how a reviewed import scaffold can become policy.py:
lfpolicy generate examples/policy-from-import.py --output-file /tmp/lfpolicy-migrated.json --force
lfpolicy check --desired /tmp/lfpolicy-migrated.json --fail-on-findingsTo see access requests represented as policy data, without adding an approval UI
to lfpolicy core:
lfpolicy generate examples/permission-requests.py --output-file /tmp/lfpolicy-requests.json --force
lfpolicy check --desired /tmp/lfpolicy-requests.json --fail-on-findingsThe request records include ticket, requester, owner, approver, review date,
target table, requested permissions, and evidence path metadata. After
generating desired state, use ../docs/permission-request-bundles.md
for the review workflow: write request-specific explain and plan artifacts,
approve exact plan-local change IDs, and pass those IDs to the consuming
service that owns AWS write execution.
Use policy-exceptions.json to see how intentional risky grants are scoped
without globally weakening lint rules:
lfpolicy lint --desired examples/policy-exceptions.jsonThe example suppresses ALL and named database grant lint findings only for the
matching principal, resource, permissions, and non-expired exception rules.
lfpolicy summary \
--desired examples/desired.json \
--current-snapshot examples/current-snapshot.jsonThis produces a compact inventory of LF-Tag keys, resource kinds, grant principals, grant resource kinds, and permissions for reviewers.
lfpolicy audit \
--desired examples/desired.json \
--current-snapshot examples/current-snapshot.jsonExpected summary:
Findings: 3 total, 3 error(s), 0 warning(s).
To use the audit in CI and save evidence for review:
lfpolicy audit \
--desired examples/desired.json \
--current-snapshot examples/current-snapshot.json \
--output json \
--output-file artifacts/lfpolicy-audit.json \
--fail-on-findingsThe command writes artifacts/lfpolicy-audit.json before exiting with status 1.
Use --fail-on-severity error when warnings should be reported but should not
fail the job:
lfpolicy audit \
--desired examples/desired.json \
--current-snapshot examples/current-snapshot.json \
--fail-on-findings \
--fail-on-severity errorlfpolicy plan \
--desired examples/desired.json \
--current-snapshot examples/current-snapshot.jsonExpected summary:
Plan: 3 change(s), 3 safe, 0 destructive.
To save a Markdown plan for pull request review:
lfpolicy plan \
--desired examples/desired.json \
--current-snapshot examples/current-snapshot.json \
--output markdown \
--output-file artifacts/lfpolicy-plan.mdBy default, the plan is additive only. It will add missing LF-Tag values,
resource tag assignments, and permissions, but it will not revoke permissions or
remove tag values unless a matching --allow-* flag is supplied.
Install the YAML extra, then run the same plan against the YAML desired policy:
python -m pip install "lfpolicy[yaml]"
lfpolicy plan \
--desired examples/desired.yaml \
--current-snapshot examples/current-snapshot.jsonUse github-actions/lakeformation-drift.yml
as a starting point when your policy repository already uses GitHub OIDC to
assume an AWS role. Replace the example role ARN, region, and policy paths
before enabling the workflow.
Use github-actions/lakeformation-code-scanning.yml
when your repository can upload SARIF to GitHub Code Scanning. It uploads
separate lfpolicy-lint and lfpolicy-audit categories before enforcing the
check and drift gates.
For the evidence model behind these workflows, see
../docs/ci-evidence-workflows.md.
Use pre-commit/pre-commit-config.yaml as
a starting point when developers should regenerate and check desired-state
policy before committing. Copy it to .pre-commit-config.yaml, update the
policy paths, and install the hook in an environment where lfpolicy is
available:
python -m pip install lfpolicy pre-commit
pre-commit install
pre-commit run --all-files