question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot import name 'AVAILABILITY_ZONES'

See original GitHub issue

cfn-lint version: (cfn-lint --version) 0.48.0 (though happens with any prior versions I’ve tried back to 0.3x)

Description of issue. cfn-lint produces the following error on any yaml file I provide (and regardless of any reference to AZs); 2021-04-05 11:02:19,630 - cfnlint - ERROR - Tried to append rules but got an error: cannot import name 'AVAILABILITY_ZONES' I’m running within Windows WSL 2 Ubuntu 18.04, pip3 installed cfn-init, on python 3.6.9.

Here’s an example full debug output;

cfn-lint -D vpc.yml
2021-04-05 11:11:02,895 - cfnlint - DEBUG - Looking for CFLINTRC before attempting to load
2021-04-05 11:11:02,896 - cfnlint - DEBUG - Validating User CFNLINTRC
2021-04-05 11:11:02,896 - cfnlint - DEBUG - Validating CFNLINTRC config with given JSONSchema
2021-04-05 11:11:02,896 - cfnlint - DEBUG - Schema used: {'$id': 'https://github.com/aws-cloudformation/cfn-python-lint/blob/master/src/cfnlint/data/CfnLintCli/config/schema.json', '$schema': 'http://json-schema.org/draft-07/schema#', 'additionalProperties': False, 'description': 'CFNLINTRC configuration schema', 'properties': {'append_rules': {'description': 'Location of directories to append rules from', 'items': {'type': 'string'}, 'type': 'array'}, 'configure_rules': {'additionalProperties': False, 'description': 'Configure rules', 'patternProperties': {'^.*$': {'patternProperties': {'^.*$': {'anyOf': [{'type': 'string'}, {'type': 'integer'}, {'type': 'boolean'}]}}, 'type': 'object'}}, 'type': 'object'}, 'ignore_checks': {'description': 'List of checks to ignore', 'items': {'type': 'string'}, 'type': 'array'}, 'ignore_templates': {'description': 'Templates to ignore', 'items': {'type': 'string'}, 'type': 'array'}, 'include_checks': {'description': 'List of checks to include', 'items': {'type': 'string'}, 'type': 'array'}, 'mandatory_checks': {'description': 'List of mandatory checks to enforce', 'items': {'type': 'string'}, 'type': 'array'}, 'merge_configs': {'description': 'Merges lists between configuration layers', 'type': 'boolean'}, 'custom_rules': {'description': 'custom rule file to use', 'items': {'type': 'string'}, 'type': 'array'}, 'output_file': {'description': 'Path to the file to write the main output to', 'type': 'string'}, 'override_spec': {'description': 'Path to spec file to override with', 'type': 'string'}, 'regions': {'description': 'Regions to test against', 'items': {'type': 'string'}, 'type': 'array'}, 'registry_schemas': {'description': 'One or more directories of CloudFormation Registry Resource Schemas', 'items': {'type': 'string'}, 'type': 'array'}, 'templates': {'description': 'Templates to lint', 'items': {'type': 'string'}, 'type': 'array'}}, 'title': 'CFNLINTRC JSON Schema', 'type': 'object'}
2021-04-05 11:11:02,896 - cfnlint - DEBUG - Config used: {}
2021-04-05 11:11:02,899 - cfnlint - DEBUG - CFNLINTRC looks valid!
2021-04-05 11:11:02,899 - cfnlint - DEBUG - Validating Project CFNLINTRC
2021-04-05 11:11:02,899 - cfnlint - DEBUG - Validating CFNLINTRC config with given JSONSchema
2021-04-05 11:11:02,900 - cfnlint - DEBUG - Schema used: {'$id': 'https://github.com/aws-cloudformation/cfn-python-lint/blob/master/src/cfnlint/data/CfnLintCli/config/schema.json', '$schema': 'http://json-schema.org/draft-07/schema#', 'additionalProperties': False, 'description': 'CFNLINTRC configuration schema', 'properties': {'append_rules': {'description': 'Location of directories to append rules from', 'items': {'type': 'string'}, 'type': 'array'}, 'configure_rules': {'additionalProperties': False, 'description': 'Configure rules', 'patternProperties': {'^.*$': {'patternProperties': {'^.*$': {'anyOf': [{'type': 'string'}, {'type': 'integer'}, {'type': 'boolean'}]}}, 'type': 'object'}}, 'type': 'object'}, 'ignore_checks': {'description': 'List of checks to ignore', 'items': {'type': 'string'}, 'type': 'array'}, 'ignore_templates': {'description': 'Templates to ignore', 'items': {'type': 'string'}, 'type': 'array'}, 'include_checks': {'description': 'List of checks to include', 'items': {'type': 'string'}, 'type': 'array'}, 'mandatory_checks': {'description': 'List of mandatory checks to enforce', 'items': {'type': 'string'}, 'type': 'array'}, 'merge_configs': {'description': 'Merges lists between configuration layers', 'type': 'boolean'}, 'custom_rules': {'description': 'custom rule file to use', 'items': {'type': 'string'}, 'type': 'array'}, 'output_file': {'description': 'Path to the file to write the main output to', 'type': 'string'}, 'override_spec': {'description': 'Path to spec file to override with', 'type': 'string'}, 'regions': {'description': 'Regions to test against', 'items': {'type': 'string'}, 'type': 'array'}, 'registry_schemas': {'description': 'One or more directories of CloudFormation Registry Resource Schemas', 'items': {'type': 'string'}, 'type': 'array'}, 'templates': {'description': 'Templates to lint', 'items': {'type': 'string'}, 'type': 'array'}}, 'title': 'CFNLINTRC JSON Schema', 'type': 'object'}
2021-04-05 11:11:02,900 - cfnlint - DEBUG - Config used: {}
2021-04-05 11:11:02,902 - cfnlint - DEBUG - CFNLINTRC looks valid!
2021-04-05 11:11:02,902 - cfnlint - DEBUG - User configuration loaded as
2021-04-05 11:11:02,902 - cfnlint - DEBUG - {}
2021-04-05 11:11:02,902 - cfnlint - DEBUG - Project configuration loaded as
2021-04-05 11:11:02,902 - cfnlint - DEBUG - {}
2021-04-05 11:11:02,903 - cfnlint - DEBUG - Merging configurations...
2021-04-05 11:11:02,903 - cfnlint - DEBUG - Begin linting of file: vpc.yml
2021-04-05 11:11:02,929 - cfnlint - ERROR - Tried to append rules but got an error: cannot import name 'AVAILABILITY_ZONES'

It doesn’t matter what yaml I provide, all the previously successfully parsed files all produce this error. Obviously unrelated to the file being parsed.

Until a few days ago there was no issue. I started seeing an odd error on a relatively new resource AWS Network Firewall, which I attributed to an old version of cfn-init (0.34.0). However, following upgrade to the latest version, the above errors are now consistent with what ever version I use. Returning to the previous version does not help.

I’ve confirmed 0.46.0 on MacOS Big Sur is fine - installed via brew. So it appears to be a local thing, or specific to (WSL) Ubuntu, any thoughts?

Thanks.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mrdevnullcommented, Apr 21, 2021

Not sure if people were waiting for me to do something.

I’ve been playing a little with the related cache files as mentioned in the previous comments.

Following cfn-lint removal via pip3 the following home path python files remain.

./.local/lib/python3.6/site-packages/cfnlint/rules/resources/ectwo/__pycache__/Vpc.cpython-36.pyc
./.local/lib/python3.6/site-packages/cfnlint/rules/resources/ectwo/__pycache__/Subnet.cpython-36.pyc
./.local/lib/python3.6/site-packages/cfnlint/rules/resources/rds/__pycache__/InstanceEngine.cpython-36.pyc
./.local/lib/python3.6/site-packages/cfnlint/rules/resources/rds/__pycache__/AuroraScalingConfiguration.cpython-36.pyc
./.local/lib/python3.6/site-packages/cfnlint/rules/resources/rds/__pycache__/AuroraDBInstanceProperties.cpython-36.pyc
./.local/lib/python3.6/site-packages/cfnlint/rules/resources/lmbd/__pycache__/FunctionMemorySize.cpython-36.pyc
./.local/lib/python3.6/site-packages/cfnlint/rules/resources/dynamodb/__pycache__/BillingMode.cpython-36.pyc
./.local/lib/python3.6/site-packages/cfnlint/rules/resources/route53/__pycache__/HealthCheck.cpython-36.pyc
./.local/lib/python3.6/site-packages/cfnlint/rules/parameters/__pycache__/CidrAllowedValues.cpython-36.pyc
./.local/lib/python3.6/site-packages/cfnlint/rules/parameters/__pycache__/Cidr.cpython-36.pyc

I removed all those files, reinstalled and the error is gone. 😃

Now using cfn-lint 0.48.3.

0reactions
bnguyen-bgscommented, Apr 15, 2021

I had this issue also. My investigation found by switching users, cfn-lint would work. Specifically, the cfn-lint, which gave me the error Tried to append rules..., was not installed in /usr/local/bin.

I’m not sure but I suspect that it played a part in muddling up the pathing for finding important files like the cfnlintrc file. It fits closely to where the code sends the exception…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot import name 'AssetManifestOptions' from 'aws_cdk ...
I am using virual env in python for this app. ANy help would be really heplful. Exception : ImportError: cannot import name 'AssetManifestOptions'...
Read more >
Regions, Availability Zones, and Local Zones
Region Name Region Protocol US East (Ohio) us‑east‑2 HTTPS. HTTPS. HTTPS. HTTPS US East (N. Virginia) us‑east‑1 HTTPS. HTTPS. HTTPS. HTTPS US West (N. California) us‑west‑1...
Read more >
python - AWS CDK - ImportError: cannot import name ...
Its the same here, I think the issue can be in wrong package version. cloud-assembly-schema==2.50.0 contains AssetManifestOptions.
Read more >
Timeline of Amazon Web Services - Wikipedia
This is a timeline of Amazon Web Services, which offers a suite of cloud computing services that make up an on-demand computing platform....
Read more >
Unable to run AWS CLI: "ImportError: cannot import name ...
try running pip3 install --upgrade awscli. or pip install --upgrade awscli.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found