Welcome to terraformlintingcli’s documentation!¶
Contents:
terraformlintingcli¶
A cli to lint and check file positioning for terraform resources
- Documentation: http://terraformlintingcli.readthedocs.io/en/latest/
Features¶
- Lints terraform resources based on provided rules
- Enforces filename positioning for terraform resources based on provided rules
Installation¶
At the command line:
$ pip install terraformlintingcli
Or, if you have virtualenvwrapper installed:
$ mkvirtualenv terraformlintingcli
$ pip install terraformlintingcli
Or, if you are using pipenv:
$ pipenv install terraformlintingcli
Usage¶
To use terraform-lint:
terraform-lint --help
[-h] [--log-config LOGGER_CONFIG]
[--log-level {debug,info,warning,error,critical}]
-r rules.yaml -p positioning.yaml -s
tf_plans_dir
Cli to lint naming conventions of terraform plans based on a provided rule set
optional arguments:
-h, --help show this help message and exit
--log-config LOGGER_CONFIG, -l LOGGER_CONFIG
The location of the logging config json file
--log-level {debug,info,warning,error,critical}, -L {debug,info,warning,error,critical}
Provide the log level. Defaults to INFO.
-n naming.yaml, --naming naming.yaml
-p positioning.yaml, --positioning positioning.yaml
-s tf_plans_dir, --stack tf_plans_dir
terraform-lint -s dir_with_tf_files/ -n naming.yaml -p positioning.yaml
Naming convention not followed on file prfxa015-pc01/compute.tf for resource prfxa015-pc01 for field tags.Name
Regex not matched : ^prfx[dtaps]a[0-9]{3}-[a-z]{1,3}[0-9]{2}$
Value : prfxa015-pc01
# naming.yaml should follow the following schema
#
# Schema([{'resource': basestring,
# 'regex': is_valid_regex,
# Optional('fields'): [{'value': basestring,
# 'regex': is_valid_regex}]}])
#
# Example
---
- resource: terraform_resource_name
regex: .* # regex to lint terraform id
fields:
- value: tags.Name
regex: ^cust[dtaps](?:ew1)-pc[0-9]{2}$ # regex to lint the name of the tag
- value: tags.Other
regex: ^cust[dtaps](?:ew1)-other[0-9]{2}$ # regex to lint the name of the tag
# positioning.yaml should follow the following schema
#
# Schema({And(basestring, lambda x: x.endswith('.tf')): [basestring]})
#
#
# Example
_data.tf:
- terraform
- data
_provider.tf:
- provider
_variables.tf:
- variable
compute.tf:
- azurerm_app_service
- azurerm_app_service_plan
- azurerm_virtual_machine
- aws_instance
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
Submit Feedback¶
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
Get Started!¶
Ready to contribute? Here’s how to set up terraformlintingcli for local development.
Clone your fork locally:
$ git clone git@github.com:schubergphilis/terraformlintingcli.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your clone for local development:
$ mkvirtualenv terraformlintingcli $ cd terraformlintingcli/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
Commit your changes and push your branch to the server:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a merge request
terraformlintingcli¶
terraformlintingcli package¶
Submodules¶
terraformlintingcli.terraformlintingcli module¶
Main code for terraformlintingcli
-
class
terraformlintingcli.terraformlintingcli.
ReadableDirectory
(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]¶ Bases:
argparse.Action
Argparse action for a directory that is readable
-
class
terraformlintingcli.terraformlintingcli.
ReadableFile
(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]¶ Bases:
argparse.Action
Argparse action for a file that is readable
-
terraformlintingcli.terraformlintingcli.
get_arguments
()[source]¶ Gets us the cli arguments.
Returns the args as parsed from the argsparser.
terraformlintingcli.terraformlintingcliexceptions module¶
Custom exception code for terraformlintingcli
Credits¶
Development Lead¶
- Costas Tyfoxylos <ctyfoxylos@schubergphilis.com>
Contributors¶
None yet. Why not be the first?
History¶
0.1 (2018-05-24)¶
- First release