Templates
Who this is for: anyone who runs InvenTag more than once and wants the same report layout, the same tag rules or the same scan settings every time.
What you can do after reading: pick a built-in template, use it with
--template, and know when to make your own.
What a template is
A template is a short YAML file that tells InvenTag how to do one part of a run. There are three kinds:
| Kind | Controls | Example built-in |
|---|---|---|
report | How the Excel workbook and Word document look: title, colours, columns, which sheets and sections appear | standard-bom, executive-summary |
tag-policy | Which tags every resource must have, and which values are allowed | finops-cost-allocation, security-baseline |
config | What to scan and what to produce: accounts, regions, output files, and which report and tag policy to use | single-account, org-multi-account, ci-pipeline |
InvenTag ships eight built-in templates. You can copy any of them into your project and adapt it.
Use a template
Add --template to a normal run. You can give a name or a file path:
inventag --template executive-summary --create-word
inventag --template ./my-templates/acme-bom.yaml --create-excel
Repeat --template to combine one template of each kind:
inventag --template standard-bom --template security-baseline --create-excel
A few rules decide what wins when settings overlap:
- Flags you type win. If a config template says
outputs: [excel]and you also type--create-word, you get both files. - A template on the command line wins over a reference inside another
template.
--template security-baselinereplaces the tag policy thatfinops-cost-reportnames. - Without a report template, InvenTag uses
standard-bom.
Runs without --template use the original report layout.
--tag-mappings and --service-descriptions add columns to that original
layout. With --template, a report shows only the columns it lists, so those
columns stay out until you list them under columns, for example
- field: service_description. InvenTag logs a warning that names the missing
columns. See the field list.
What a tag policy adds to your reports
When a tag policy is active, InvenTag checks every resource in scope and adds:
- a Tag Compliance sheet in the workbook, one row per resource, with what is missing or wrong;
- a Tag compliance section in the Word document;
- a
tag_compliance_<timestamp>.jsonfile you can use in scripts or CI; - a one-line summary in the terminal.
Sample output from an offline run with --template finops-cost-report
(sample data):
inventag - WARNING - - No account specification method provided. Using default AWS credentials.
Wrote bom_output/tag_compliance_20261112_090000.json
Wrote bom_output/multi_account_bom_20261112_090000.docx
Wrote bom_output/multi_account_bom_20261112_090000.xlsx
Tag policy 'finops-cost-allocation': 1 of 23 resources compliant (4.3%), 22 non-compliant, 14 out of scope.
A config template can set fail_on_tag_violations: true to make InvenTag exit
with code 3 when something breaks the policy. The built-in ci-pipeline
template does this.
Two opt-in flags have their own exit codes: --fail-on-account-error exits
with code 5 when an account could not be scanned, and --fail-if-empty exits
with code 6 when no resources were found. Both win over code 3. The reports
are still written.
Where InvenTag looks for templates
When you give a name, InvenTag checks these folders in order and uses the first match:
- Each folder in the
INVENTAG_TEMPLATE_PATHenvironment variable (separate folders with:on Linux and macOS,;on Windows). .inventag/templates/in the folder you run InvenTag from (your project).~/.config/inventag/templates/(or$XDG_CONFIG_HOME/inventag/templates/).- The built-in templates.
So a file called .inventag/templates/standard-bom.yaml replaces the built-in
standard-bom for that project. It can still build on the original with
extends: standard-bom. Run inventag templates list to see what is
found and from where.
Safe by design
Templates are plain data:
- InvenTag reads them with a safe YAML loader. YAML tags that create Python
objects, such as
!!python/object, are rejected. - Templates cannot run code, evaluate expressions or fetch anything from the internet.
- File references inside a template (
extends,tag_policy,report_template,logo) must be relative paths that stay inside the template's folder. - Config templates cannot contain access keys. Use
profile_nameorrole_arn. - Values from AWS that start with
=are written to Excel as text, so a tag value cannot become a spreadsheet formula.
Next steps
- Built-in templates: what each one produces.
- Adapt a template: copy, edit, validate, run.
- Template reference: every field.
- Examples: complete recipes that use templates.