You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the issue
Hi, we are using Checkov's custom checks with python to ensure our teams use the right versions of postgres through our self-maintained terraform modules. We use tfvars files to provide values per environment and invoke them using the --var-file flag.
Checkov downloads our private modules from the registry and it works fine for other custom checks.
The problem is that Checkov does not seem to recognize the engine key for the RDS module, even though it is able to parse all other keys with the variables values.
Our custom check code looks like this. Note that we are outputting the contents of conf into a file (out.txt).
fromcheckov.common.models.enumsimportCheckResult, CheckCategoriesfromcheckov.terraform.checks.resource.base_resource_checkimportBaseResourceCheckfromcheckov.terraform.checks.module.base_module_checkimportBaseModuleCheckfrompackagingimportversionclassEnsureRDSPGVersion(BaseModuleCheck):
def__init__(self)->None:
name="Ensure RDS module uses at least PostgreSQL 13"id="CUSTOM_TF_RDS_PG_VERSION"supported_resources= ['module',]
categories= [CheckCategories.CONVENTION]
guideline="Your RDS Database should be using at least PostgreSQL 13. Please upgrade the database to the latest version or you will not be able to deploy your infrastructure starting on 2025-28-02."super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources, guideline=guideline)
defscan_module_conf(self, conf):
""" Validate RDS PostgreSQL engine version is at least 13 :return: <CheckResult> """if'source'inconf.keys() and'version'inconf.keys():
module_source=conf['source'][0]
# Check if this is the specific module we want to enforce the version onif"gitlab.com/blah/blah"==module_source:
withopen('out.txt', 'w') asf:
print(conf, file=f)
if'engine'inconf.keys() and'engine_version'inconf.keys():
engine=conf['engine'][0]
engine_version=conf['engine_version'][0]
# Check if the engine is PostgreSQLif"postgres"==engine:
# Extract major version numbermajor_version=int(engine_version.split(".")[0])
# Check if the major version is at least 13ifmajor_version>=13:
returnCheckResult.PASSEDelse:
returnCheckResult.FAILEDcheck=EnsureRDSPGVersion()
Exception Trace
The command we run is the following (within the terraform folder).
Once we cat the out.txt file, we get the following output, in which as you can see, all parameters are correctly substituted but engine contains the following value '${var.engine}'
So far, we have no clue why this happens, and we have noticed that if we change the module key from engine to db_engine, the substitution works as expected!
Desktop (please complete the following information):
OS: OSx 14.6.1 (sonoma)
Checkov Version 3.2.250
The text was updated successfully, but these errors were encountered:
Describe the issue
Hi, we are using Checkov's custom checks with python to ensure our teams use the right versions of postgres through our self-maintained terraform modules. We use tfvars files to provide values per environment and invoke them using the
--var-file
flag.Checkov downloads our private modules from the registry and it works fine for other custom checks.
The problem is that Checkov does not seem to recognize the
engine
key for the RDS module, even though it is able to parse all other keys with the variables values.Examples
Our module invocation looks like this:
The variables are defined as follows:
The tfvars file looks like this:
Our custom check code looks like this. Note that we are outputting the contents of conf into a file
(out.txt)
.Exception Trace
The command we run is the following (within the terraform folder).
Once we cat the out.txt file, we get the following output, in which as you can see, all parameters are correctly substituted but
engine
contains the following value'${var.engine}'
So far, we have no clue why this happens, and we have noticed that if we change the module key from
engine
todb_engine
, the substitution works as expected!Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: