amazon web services - Cloudformation linter regions unsupported - Stack Overflow

admin2025-04-17  3

I'm setting up cfn-lint as a pre-commit hook using this guide: /

My .pre-commit-config.yaml:

repos:
-   repo: 
    rev: v1.23.1 # The version of cfn-lint to use
    hooks:
    -   id: cfn-lint
        files: final_stacks/.*\.(json|yml|yaml)$
        args: [--regions, 'eu-west-1']

When I commit a change I get:

(.venv) steyn@Steyns-MacBook-Air aws_ingestion_tools % git commit -m  "Pre-commit test"
AWS CloudFormation Linter................................................Failed
- hook id: cfn-lint
- exit code: 32

2025-01-31 13:31:20,161 - cfnlint.runner - ERROR - Regions ['final_stacks/final_env_client_test_steyn.yml'] are unsupported. Supported regions are ['af-south-1', 'ap-east-1', 'ap-northeast-1', 'ap-northeast-2', 'ap-northeast-3', 'ap-south-1', 'ap-south-2', 'ap-southeast-1', 'ap-southeast-2', 'ap-southeast-3', 'ap-southeast-4', 'ap-southeast-5', 'ap-southeast-7', 'ca-west-1', 'ca-central-1', 'cn-north-1', 'cn-northwest-1', 'eu-central-1', 'eu-central-2', 'eu-north-1', 'eu-south-1', 'eu-south-2', 'eu-west-1', 'eu-west-2', 'eu-west-3', 'il-central-1', 'me-south-1', 'me-central-1', 'sa-east-1', 'us-east-1', 'us-east-2', 'us-gov-east-1', 'us-gov-west-1', 'us-west-1', 'us-west-2']

When I run cfn-lint manually on a template it give no errors:

cfn-lint -t final_stacks/final_env_client_test_steyn.yml --region eu-west-1

Is there a problem with my .pre-commit-config.yaml?

I'm setting up cfn-lint as a pre-commit hook using this guide: https://aws.amazon.com/blogs/mt/git-pre-commit-validation-of-aws-cloudformation-templates-with-cfn-lint/

My .pre-commit-config.yaml:

repos:
-   repo: https://github.com/awslabs/cfn-python-lint
    rev: v1.23.1 # The version of cfn-lint to use
    hooks:
    -   id: cfn-lint
        files: final_stacks/.*\.(json|yml|yaml)$
        args: [--regions, 'eu-west-1']

When I commit a change I get:

(.venv) steyn@Steyns-MacBook-Air aws_ingestion_tools % git commit -m  "Pre-commit test"
AWS CloudFormation Linter................................................Failed
- hook id: cfn-lint
- exit code: 32

2025-01-31 13:31:20,161 - cfnlint.runner - ERROR - Regions ['final_stacks/final_env_client_test_steyn.yml'] are unsupported. Supported regions are ['af-south-1', 'ap-east-1', 'ap-northeast-1', 'ap-northeast-2', 'ap-northeast-3', 'ap-south-1', 'ap-south-2', 'ap-southeast-1', 'ap-southeast-2', 'ap-southeast-3', 'ap-southeast-4', 'ap-southeast-5', 'ap-southeast-7', 'ca-west-1', 'ca-central-1', 'cn-north-1', 'cn-northwest-1', 'eu-central-1', 'eu-central-2', 'eu-north-1', 'eu-south-1', 'eu-south-2', 'eu-west-1', 'eu-west-2', 'eu-west-3', 'il-central-1', 'me-south-1', 'me-central-1', 'sa-east-1', 'us-east-1', 'us-east-2', 'us-gov-east-1', 'us-gov-west-1', 'us-west-1', 'us-west-2']

When I run cfn-lint manually on a template it give no errors:

cfn-lint -t final_stacks/final_env_client_test_steyn.yml --region eu-west-1

Is there a problem with my .pre-commit-config.yaml?

Share Improve this question edited Feb 1 at 5:08 Pat Myron 4,6582 gold badges27 silver badges51 bronze badges asked Jan 31 at 11:40 Steyn van WykSteyn van Wyk 11 bronze badge 1
  • Try changing args: [--regions, 'eu-west-1'] => args: [--region, eu-west-1] – Ketan Doshi Commented Jan 31 at 12:27
Add a comment  | 

1 Answer 1

Reset to default 0

Changing the pre commit config to this seemed to do the trick:

# .pre-commit-config.yaml
repos:
-   repo: https://github.com/aws-cloudformation/cfn-lint
    rev: v1.23.1 # The version of cfn-lint to use
    hooks:
    -   id: cfn-lint
        files: final_stacks/.*\.(json|yml|yaml)$
转载请注明原文地址:http://anycun.com/QandA/1744864420a88699.html