|
15 | 15 | import cfnlint.maintenance
|
16 | 16 | from cfnlint.config import ConfigMixIn, configure_logging
|
17 | 17 | from cfnlint.decode.decode import decode
|
| 18 | +from cfnlint.helpers import REGIONS |
18 | 19 | from cfnlint.rules import Match, Rules
|
19 | 20 | from cfnlint.rules.errors import ParseError, TransformError
|
20 | 21 | from cfnlint.schema import PROVIDER_SCHEMA_MANAGER
|
@@ -122,6 +123,18 @@ def run(self) -> Iterator[Match]:
|
122 | 123 | Match: The matches found by running the rules against the template.
|
123 | 124 | """
|
124 | 125 | LOGGER.info("Run scan of template %s", self.cfn.filename)
|
| 126 | + if not set(self.config.regions).issubset(set(REGIONS)): |
| 127 | + unsupported_regions = list( |
| 128 | + set(self.config.regions).difference(set(REGIONS)) |
| 129 | + ) |
| 130 | + raise InvalidRegionException( |
| 131 | + ( |
| 132 | + f"Regions {unsupported_regions!r} are unsupported. " |
| 133 | + f"Supported regions are {REGIONS!r}" |
| 134 | + ), |
| 135 | + 32, |
| 136 | + ) |
| 137 | + |
125 | 138 | matches = self.cfn.transform()
|
126 | 139 | if matches:
|
127 | 140 | if self.rules.is_rule_enabled(TransformError(), self.config):
|
@@ -425,7 +438,11 @@ def cli(self) -> None:
|
425 | 438 | self.config.parser.print_help()
|
426 | 439 | sys.exit(1)
|
427 | 440 |
|
428 |
| - self._cli_output(list(self.run())) |
| 441 | + try: |
| 442 | + self._cli_output(list(self.run())) |
| 443 | + except CfnLintExitException as e: |
| 444 | + LOGGER.error(str(e)) |
| 445 | + sys.exit(e.exit_code) |
429 | 446 |
|
430 | 447 |
|
431 | 448 | def main() -> None:
|
|
0 commit comments