Skip to content

arm-ttk

arm-ttk documentation

arm-ttk - GitHub

Configuration in MegaLinter

Variable Description Default value
ARM_ARM_TTK_ARGUMENTS User custom arguments to add in linter CLI call
Ex: -s --foo "bar"
ARM_ARM_TTK_FILTER_REGEX_INCLUDE Custom regex including filter
Ex: (src\|lib)
Include every file
ARM_ARM_TTK_FILTER_REGEX_EXCLUDE Custom regex excluding filter
Ex: (test\|examples)
Exclude no file
ARM_ARM_TTK_CLI_LINT_MODE Override default CLI lint mode
- file: Calls the linter for each file
- list_of_files: Call the linter with the list of files as argument
- project: Call the linter from the root of the project
file
ARM_ARM_TTK_FILE_EXTENSIONS Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all files
Ex: [".py", ""]
[".json"]
ARM_ARM_TTK_FILE_NAMES_REGEX File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files
Ex: ["Dockerfile(-.+)?", "Jenkinsfile"]
Include every file
ARM_ARM_TTK_PRE_COMMANDS List of bash commands to run before the linter None
ARM_ARM_TTK_POST_COMMANDS List of bash commands to run after the linter None
ARM_ARM_TTK_CONFIG_FILE arm-ttk configuration file name
Use LINTER_DEFAULT to let the linter find it
.arm-ttk.psd1
ARM_ARM_TTK_RULES_PATH Path where to find linter configuration file Workspace folder, then MegaLinter default rules
ARM_ARM_TTK_DISABLE_ERRORS Run linter but consider errors as warnings false
ARM_ARM_TTK_DISABLE_ERRORS_IF_LESS_THAN Maximum number of errors allowed 0

IDE Integration

Use arm-ttk in your favorite IDE to catch errors before MegaLinter !

IDE Extension Name Install
Visual Studio Code ARMTTKExtension Install in VsCode

MegaLinter Flavours

This linter is available in the following flavours

Flavor Description Embedded linters Info
all Default MegaLinter Flavor 97 Docker Image Size (tag) Docker Pulls
dotnet Optimized for C, C++, C# or VB based projects 49 Docker Image Size (tag) Docker Pulls

Behind the scenes

How are identified applicable files

  • File extensions: .json
  • Detected file content (regex): schema\.management\.azure\.com

How the linting is performed

  • arm-ttk is called one time by identified file

Example calls

pwsh -NoProfile -NoLogo -Command "
    Import-Module /usr/bin/arm-ttk;
    Test-AzTemplate -TemplatePath myfile.json;
    if (${Error}.Count) {exit 1}"
    "

"pwsh -NoProfile -NoLogo -Command "
    Import-Module /usr/bin/arm-ttk;
    ${config} = $(Import-PowerShellDataFile -Path ".arm-ttk.psd1");
    Test-AzTemplate @config -TemplatePath myfile.json;
    if (${Error}.Count) {exit 1}
    "

Help content

Test-AzTemplate:
Line |
   2 |  $TAZ_V = (Test-AzTemplate -help);
     |                            ~~~~~
     | A parameter cannot be found that matches parameter name 'help'.

Installation on mega-linter Docker image

  • Dockerfile commands :
ARG ARM_TTK_NAME='master.zip'
ARG ARM_TTK_URI='https://github.com/Azure/arm-ttk/archive/master.zip'
ARG ARM_TTK_DIRECTORY='/opt/microsoft'
ENV ARM_TTK_PSD1="${ARM_TTK_DIRECTORY}/arm-ttk-master/arm-ttk/arm-ttk.psd1"
RUN curl --retry 5 --retry-delay 5 -sLO "${ARM_TTK_URI}" \
    && unzip "${ARM_TTK_NAME}" -d "${ARM_TTK_DIRECTORY}" \
    && rm "${ARM_TTK_NAME}" \
    && ln -sTf "${ARM_TTK_PSD1}" /usr/bin/arm-ttk \
    && chmod a+x /usr/bin/arm-ttk

Example success log

Results of arm-ttk linter (version 0.0.0)
See documentation on https://megalinter.github.io/descriptors/arm_arm_ttk/
-----------------------------------------------

[SUCCESS] .automation/test/arm/arm_good_1.json
                                                                                                                                                                                                                                                                                                                                                                                                                    Validating arm\arm_good_1.json  deploymentTemplate
        [+] adminUsername Should Not Be A Literal (70 ms)

        [+] apiVersions Should Be Recent (67 ms)
        [+] artifacts parameter (12 ms)
        [+] DependsOn Best Practices (8 ms)
        [+] Deployment Resources Must Not Be Debug (8 ms)
        [+] DeploymentTemplate Must Not Contain Hardcoded Uri (17 ms)
        [+] DeploymentTemplate Schema Is Correct (4 ms)
        [+] Dynamic Variable References Should Not Use Concat (69 ms)
        [+] IDs Should Be Derived From ResourceIDs (33 ms)
        [+] Location Should Not Be Hardcoded (30 ms)
        [+] ManagedIdentityExtension must not be used (2 ms)
        [+] Min And Max Value Are Numbers (6 ms)
        [+] Outputs Must Not Contain Secrets (9 ms)
        [+] Parameters Must Be Referenced (9 ms)
        [+] Parameters Property Must Exist (3 ms)
        [+] providers apiVersions Is Not Permitted (2 ms)
        [+] ResourceIds should not contain (9 ms)
        [+] Resources Should Have Location (2 ms)
        [+] Secure String Parameters Cannot Have Default (3 ms)
        [+] Template Should Not Contain Blanks (6 ms)
        [+] Variables Must Be Referenced (28 ms)
        [+] Virtual Machines Should Not Be Preview (16 ms)
        [+] VM Images Should Use Latest Version (1 ms)
        [+] VM Size Should Be A Parameter (15 ms)

Example error log

Results of arm-ttk linter (version 0.0.0)
See documentation on https://megalinter.github.io/descriptors/arm_arm_ttk/
-----------------------------------------------

[ERROR] .automation/test/arm/arm_bad_1.json
                                                                                                                                                                                                                                                                                                                                                                                                                    Validating arm\arm_bad_1.json  deploymentTemplate
        [+] adminUsername Should Not Be A Literal (69 ms)

        [+] apiVersions Should Be Recent (97 ms)
        [+] artifacts parameter (11 ms)
        [+] DependsOn Best Practices (6 ms)
        [+] Deployment Resources Must Not Be Debug (7 ms)
        [+] DeploymentTemplate Must Not Contain Hardcoded Uri (17 ms)
        [+] DeploymentTemplate Schema Is Correct (4 ms)
        [+] Dynamic Variable References Should Not Use Concat (3 ms)
        [+] IDs Should Be Derived From ResourceIDs (18 ms)
        [+] Location Should Not Be Hardcoded (27 ms)
        [+] ManagedIdentityExtension must not be used (3 ms)
        [+] Min And Max Value Are Numbers (7 ms)
        [+] Outputs Must Not Contain Secrets (10 ms)
        [+] Parameters Must Be Referenced (10 ms)
        [+] Parameters Property Must Exist (3 ms)
        [+] providers apiVersions Is Not Permitted (2 ms)
        [+] ResourceIds should not contain (10 ms)
        [+] Resources Should Have Location (2 ms)
        [+] Secure String Parameters Cannot Have Default (3 ms)
        [-] Template Should Not Contain Blanks (21 ms) 
    ::error::        Empty property:  [] found on line: 28 Index:1331
    ::error::        Empty property:  "" found on line: 3 Index:121

        [-] Variables Must Be Referenced (80 ms) 
    ::error::        Unreferenced variable: Network.Location
    ::error::        Unreferenced variable: Test.Blank.Variable

        [+] Virtual Machines Should Not Be Preview (18 ms)
        [+] VM Images Should Use Latest Version (1 ms)
        [+] VM Size Should Be A Parameter (13 ms)